Followup r87986: qunit test case for bug 30825
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 9 Sep 2011 18:43:37 +0000 (18:43 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 9 Sep 2011 18:43:37 +0000 (18:43 +0000)
jQuery's $.append() and friends go through some funky code paths which sometimes manually load <script> node contents via AJAX and eval them. That failed entirely in IE 7 if given a protocol-relative link ($wgServer = '//commons.wikimedia.org').
The fix in r87986 bypasses that by using DOM append directly on a script node, and thus fixes bug 30825 without even knowing it. :)

This test serves as a regression test.

tests/qunit/suites/resources/mediawiki/mediawiki.test.bug30825.js [new file with mode: 0644]
tests/qunit/suites/resources/mediawiki/mediawiki.test.js

diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.bug30825.js b/tests/qunit/suites/resources/mediawiki/mediawiki.test.bug30825.js
new file mode 100644 (file)
index 0000000..bdf2334
--- /dev/null
@@ -0,0 +1,2 @@
+start();
+ok( true, "Bug 30825 -- protocol-relative URL script load via mw.loader.load");
index bae323f..588b3d3 100644 (file)
@@ -169,6 +169,23 @@ test( 'mw.loader.bug29107' , function() {
        });
 });
 
+test( 'mw.loader.bug30825', function() {
+       // This bug was actually already fixed in 1.18 and later when discovered in 1.17.
+       // Test is for regressions!
+
+       expect(1);
+
+       // Confirm that mw.loader.load() works with protocol-relative URLs
+       var loc = window.location,
+               base = ('//' + loc.hostname + loc.pathname).replace(/\/[^\/]*$/, ''),
+               target = base + '/suites/resources/mediawiki/mediawiki.test.bug30825.js';
+
+       // Async! Include a timeout, as failure in this test leads to neither the
+       // success nor failure callbacks getting called.
+       stop(5000);
+       mw.loader.load( target );
+});
+
 test( 'mw.html', function() {
        expect(11);