From 87f6a020e80de4446c35ab06fd0da72eae90f521 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin <622599+aaronjorbin@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:40:22 -0500 Subject: [PATCH 1/7] Add explicit variables to fix `use strict`. Each of the variables declared at the top are included either are already used in the global scope or are prefixed. Trac Ticket: https://core.trac.wordpress.org/ticket/65515 AI Disclosure: Debugged and initial patch including tests generated with Opencode and gpt-5.5. Manually checked and adjusted to reduce the number of variables in the global scope. --- src/js/_enqueues/vendor/thickbox/thickbox.js | 13 +- tests/qunit/index.html | 5042 +++++++++++------- tests/qunit/wp-includes/js/thickbox.js | 48 + 3 files changed, 3216 insertions(+), 1887 deletions(-) create mode 100644 tests/qunit/wp-includes/js/thickbox.js diff --git a/src/js/_enqueues/vendor/thickbox/thickbox.js b/src/js/_enqueues/vendor/thickbox/thickbox.js index 2c7b7f95260fa..136dbe1668265 100644 --- a/src/js/_enqueues/vendor/thickbox/thickbox.js +++ b/src/js/_enqueues/vendor/thickbox/thickbox.js @@ -9,6 +9,9 @@ if ( typeof tb_pathToImage != 'string' ) { var tb_pathToImage = thickboxL10n.loadingAnimation; } +var imgLoader, TB_PrevCaption, TB_PrevURL, TB_PrevHTML, TB_NextCaption, TB_NextURL, + TB_NextHTML, TB_imageCount, TB_FoundURL, TB_TempArray, TB_Counter, TB_WIDTH, TB_HEIGHT; + /*!!!!!!!!!!!!!!!!! edit below this line at your own risk !!!!!!!!!!!!!!!!!!!!!!!*/ //on page load call tb_init @@ -117,7 +120,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } } - imgPreloader = new Image(); + var imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; @@ -201,14 +204,14 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic var queryString = url.replace(/^[^\?]+\??/,''); var params = tb_parseQuery( queryString ); + var ajaxContentW = TB_WIDTH - 30; + var ajaxContentH = TB_HEIGHT - 45; TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL - ajaxContentW = TB_WIDTH - 30; - ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window - urlNoQuery = url.split('TB_'); + var urlNoQuery = url.split('TB_'); jQuery("#TB_iframeContent").remove(); if(params['modal'] != "true"){//iframe no modal jQuery("#TB_window").append("
"+caption+"
"); @@ -333,7 +336,7 @@ function tb_getPageSize(){ var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; - arrayPageSize = [w,h]; + var arrayPageSize = [w,h]; return arrayPageSize; } diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 9fd35f0c1ffc2..799e69bee6ebd 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -1,4 +1,4 @@ - + WordPress QUnit Test Suite @@ -14,15 +14,15 @@ @@ -32,26 +32,291 @@ @@ -59,17 +324,23 @@ - + @@ -101,11 +372,26 @@ - - - - - + + + + + @@ -118,31 +404,284 @@ - - + @@ -154,6 +693,7 @@ + @@ -169,28 +709,40 @@ - - - + + + - @@ -443,1818 +1221,2277 @@

- - + +
-
-
- -

Search

-
+
+
+
+ +
+

+ Search +

+
+
+ +
+
+
+

+ +

+
+ + + + + + + + +
+
+ Delete + | + Close +
+
+ + +
+
+
+
+ +
-
-
-
-

+
+ A search form for your site. +
+
+
+
+ +
+
- - - - - - - - -
-
- Delete | - Close + + + + + + + + + + if ( settings.contentWidth && data.model.width >= settings.contentWidth ) { + w = settings.contentWidth; + } else { + w = data.model.width; + } + + if ( w !== data.model.width ) { + h = Math.ceil( ( data.model.height * w ) / data.model.width ); + } else { + h = data.model.height; + } + + if ( w ) { + w_rule = 'width: ' + w + 'px; '; + } - + + + + - + + + + +

+ +

+
+ - + - + + <# _.defaults( data, {"settings":[],"type":"date_time","priority":10,"active":true,"section":"","content":"
  • \n\t\t\t\t\t<\/li>","label":"","description":"","instanceNumber":73,"maxYear":9999,"minYear":1000,"allowPastDate":true,"twelveHourFormat":true,"includeTime":true,"defaultValue":null,"month_choices":{"1":{"text":"1-Jan","value":1},"2":{"text":"2-Feb","value":2},"3":{"text":"3-Mar","value":3},"4":{"text":"4-Apr","value":4},"5":{"text":"5-May","value":5},"6":{"text":"6-Jun","value":6},"7":{"text":"7-Jul","value":7},"8":{"text":"8-Aug","value":8},"9":{"text":"9-Sep","value":9},"10":{"text":"10-Oct","value":10},"11":{"text":"11-Nov","value":11},"12":{"text":"12-Dec","value":12}}} ); #> + <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> - - - - - - - - - + + + - + - - - + + - <# if ( data.suggestedWidth && data.suggestedHeight ) { #> -

    - Suggested image dimensions: {{data.suggestedWidth}} × {{data.suggestedHeight}} -

    - <# } #> + -
  • -
    - - - - - - - - - - - + + + + + + + + + + - - - - + + - <# var maybeReadOnly = data.can.save || data.allowLocalEdits ? '' : 'readonly'; #> - <# if ( 'image' === data.type ) { #> - - - - -

    Describe the purpose of the image (opens in a new tab). Leave empty if the image is purely decorative.

    - <# } #> - - <# if ( 'audio' === data.type ) { #> - - - <# } #> - - - - - - - - - - - - - - - - - - - - - - + + + + + + - <# if ( ! _.isEmpty( html5types ) ) { #> -
    - Add alternate sources for maximum HTML5 playback: -
    - <# _.each( html5types, function (mime, type) { #> - - <# } ) #> + + + - - + + + + + + + + + +
    +
    + - - - - - - -
    - Preview as an app icon -
    - + + + +
    + @@ -2262,17 +3499,37 @@

    Preview

    diff --git a/tests/qunit/wp-includes/js/thickbox.js b/tests/qunit/wp-includes/js/thickbox.js new file mode 100644 index 0000000000000..008ffa9b035f2 --- /dev/null +++ b/tests/qunit/wp-includes/js/thickbox.js @@ -0,0 +1,48 @@ +/* jshint evil: true */ + +(function (QUnit) { + QUnit.module('thickbox'); + + QUnit.test( + 'initializes when concatenated after a strict-mode script', + function (assert) { + var done = assert.async(); + + assert.expect(1); + + jQuery + .get('../../src/js/_enqueues/vendor/thickbox/thickbox.js') + .done(function (source) { + var thickboxL10n = { + loadingAnimation: 'loading.gif', + }; + var fakejQuery = function () { + return { + ready: function (callback) { + callback(); + }, + on: function () { + return this; + }, + }; + }; + + assert.doesNotThrow(function () { + Function( + 'jQuery', + 'thickboxL10n', + 'document', + 'Image', + '"use strict";\n' + source + )(fakejQuery, thickboxL10n, {}, window.Image); + }); + + done(); + }) + .fail(function () { + assert.ok(false, 'Could not load thickbox.js source.'); + done(); + }); + } + ); +})(window.QUnit); From 15ffdde1dccbc63d3da0c3689708fdccfa38fbc2 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin <622599+aaronjorbin@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:48:28 -0500 Subject: [PATCH 2/7] Cleanup a bit --- src/js/_enqueues/vendor/thickbox/thickbox.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/js/_enqueues/vendor/thickbox/thickbox.js b/src/js/_enqueues/vendor/thickbox/thickbox.js index 136dbe1668265..fe7d6c8c7faa6 100644 --- a/src/js/_enqueues/vendor/thickbox/thickbox.js +++ b/src/js/_enqueues/vendor/thickbox/thickbox.js @@ -90,6 +90,7 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic urlType == '.webp' || urlType == '.avif' ){//code to show images + var imgPreloader = new Image(); TB_PrevCaption = ""; TB_PrevURL = ""; @@ -120,7 +121,6 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic } } - var imgPreloader = new Image(); imgPreloader.onload = function(){ imgPreloader.onload = null; @@ -204,11 +204,12 @@ function tb_show(caption, url, imageGroup) {//function called when the user clic var queryString = url.replace(/^[^\?]+\??/,''); var params = tb_parseQuery( queryString ); - var ajaxContentW = TB_WIDTH - 30; - var ajaxContentH = TB_HEIGHT - 45; + var ajaxContentW, ajaxContentH; TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no parameters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no parameters were added to URL + ajaxContentW = TB_WIDTH - 30; + ajaxContentH = TB_HEIGHT - 45; if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window var urlNoQuery = url.split('TB_'); @@ -336,8 +337,7 @@ function tb_getPageSize(){ var de = document.documentElement; var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; - var arrayPageSize = [w,h]; - return arrayPageSize; + return [w,h]; } function tb_detectMacXFF() { From 229ed1562f65f168e4a42375220a723d0b04a421 Mon Sep 17 00:00:00 2001 From: Aaron Jorbin <622599+aaronjorbin@users.noreply.github.com> Date: Tue, 30 Jun 2026 16:49:48 -0500 Subject: [PATCH 3/7] don't change the regular qunit tests --- tests/qunit/index.html | 5044 +++++++++++++++------------------------- 1 file changed, 1883 insertions(+), 3161 deletions(-) diff --git a/tests/qunit/index.html b/tests/qunit/index.html index 799e69bee6ebd..9fd35f0c1ffc2 100644 --- a/tests/qunit/index.html +++ b/tests/qunit/index.html @@ -1,4 +1,4 @@ - + WordPress QUnit Test Suite @@ -14,15 +14,15 @@ @@ -32,291 +32,26 @@ @@ -324,23 +59,17 @@ - + @@ -372,26 +101,11 @@ - - - - - + + + + + @@ -404,284 +118,31 @@ - - + @@ -693,7 +154,6 @@ - @@ -709,40 +169,28 @@ + - - - + + - @@ -1221,2277 +443,1818 @@

    -
    - -
    - -
    - - - -

    - - - - -

    -
    +

    -
    +
    +
    - +
    -
    +
    -
      +
        -
        +
        -
          +
            -
            +
            -
              +
                -
                +
                -
                  +
                    -
                    - -
                    - +
                    +