Bug 1793227, part 2 - Manually convert some http:// URLs to https:// in chrome XPConnect tests. r=kmag

The eslint autofixer makes URLs that appear in strings in JS into https://
URLs. However, it does not change any URLs in the HTML part of the tests, which
caused some tests to fail. To try to ensure that the autofixer didn't break
tests in any way that doesn't show up as a failure, I did a light audit of the
tests. Specifically, I looked at files in js/xpconnect/tests/chrome/ containing
the string "example." in a URL string in more than one place. I switched these
URLs over to https://, both in JS and HTML.

I left alone test_secureContexts.html, which uses an http:// URL in HTML, but
is clearly trying to test http://.

I did a similar check for mochi.test but there weren't any tests that used it
more than once.

The tests that originally were broken by the autofix were:
  * test_evalInWindow.xhtml
  * test_expandosharing.xhtml
  * test_wrappers.xhtml
  * test_xrayic.xhtml

My audit didn't find any other instances that looked like they might fail. I
did fix a few other places, but I think in those cases the HTML and JS URLs were
cross origin anyways so it shouldn't really matter if one is https:// and the
other is http://.

I also changed single quotes to double quotes for the URLs I changed, because
the autofix is going to do that anyways.

Differential Revision: https://phabricator.services.mozilla.com/D158502
This commit is contained in:
Andrew McCreight 2022-10-10 22:21:59 +00:00
parent b9091631a4
commit a2486eeeb0
11 changed files with 33 additions and 33 deletions

View file

@ -20,7 +20,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1042436
/** Test for Bug 1042436 **/
SimpleTest.waitForExplicitFinish();
var contentSb = Cu.Sandbox('http://www.example.com');
var contentSb = Cu.Sandbox("https://www.example.com");
var nonXrayableObj = contentSb.eval("new Map()[Symbol.iterator]()");
nonXrayableObj.wrappedJSObject.someExpandoProperty = 42;
nonXrayableObj.wrappedJSObject.someOtherExpandoProperty = 52;
@ -43,7 +43,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1042436
is(contentObjWithGetter.valueProp, 42, "Getter prop set up correctly");
chromeSb2.contentObjWithGetter = contentObjWithGetter;
Cu.evalInSandbox('contentObjWithGetter.getterProp; contentObjWithGetter.valueProp; contentObjWithGetter.getterProp;',
chromeSb2, "1.7", "http://phony.example.com/file.js", 99);
chromeSb2, "1.7", "https://phony.example.com/file.js", 99);
},
[{ errorMessage: /property "someExpandoProperty" \(reason: object is not safely Xrayable/, sourceName: /test_bug1042436/, isWarning: true },
{ errorMessage: /property "getterProp" \(reason: property has accessor/, sourceName: /phony/, lineNumber: 99, isWarning: true } ],

View file

@ -46,7 +46,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=773962
win2.document.adoptNode(node1);
// Navigate win1. This causes win1 to be transplanted.
win1.location = 'http://test2.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html';
win1.location = "https://test2.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
// The above happens async. Our onload handler will call finishTest() when we're ready.
}
@ -75,6 +75,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=773962
]]>
</script>
<iframe id="frame1" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
<iframe id="frame2" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
<iframe id="frame1" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
<iframe id="frame2" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
</window>

View file

@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=792280
<![CDATA[
/** Test for Bug 792280 **/
function checkSb(sb, expect) {
var target = new Cu.Sandbox('http://www.example.com');
var target = new Cu.Sandbox("https://www.example.com");
Cu.evalInSandbox('function fun() { return arguments.callee.caller; };', target);
sb.fun = target.fun;
let allowed = false;
@ -34,8 +34,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=792280
}
// Note that COWs are callable, but XOWs are not.
checkSb(new Cu.Sandbox('http://www.example.com'), "allow");
checkSb(new Cu.Sandbox('http://www.example.org'), "throw");
checkSb(new Cu.Sandbox("https://www.example.com"), "allow");
checkSb(new Cu.Sandbox("https://www.example.org"), "throw");
checkSb(new Cu.Sandbox(window), "censor");
]]>

View file

@ -34,7 +34,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=860494
"iframe names shouldn't shadow |alert| via Xray");
// Now test XOWs.
var sb = new Cu.Sandbox('http://www.example.com');
var sb = new Cu.Sandbox("https://www.example.com");
sb.win = iwin;
sb.topWin = top;
sb.parentWin = window;
@ -52,5 +52,5 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=860494
]]>
</script>
<iframe id="ifr" type="content" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_bug860494.html" />
<iframe id="ifr" type="content" onload="go();" src="https://example.org/tests/js/xpconnect/tests/mochitest/file_bug860494.html" />
</window>

View file

@ -22,7 +22,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=865948
SimpleTest.waitForExplicitFinish();
function go() {
$('ifr').onload = null;
var sb = Cu.Sandbox(['http://example.com', 'http://example.org']);
var sb = Cu.Sandbox(["https://example.com", "https://example.org"]);
sb.iwin = $('ifr').contentWindow;
sb.ok = ok;
Cu.evalInSandbox('try { iwin.location = "about:mozilla"; ok(false, "didnt throw"); } catch (e) { ok(!!/denied/.exec(e), "threw: " + e); }', sb);
@ -31,5 +31,5 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=865948
]]>
</script>
<iframe id="ifr" type="content" onload="go();" src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
<iframe id="ifr" type="content" onload="go();" src="https://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html" />
</window>

View file

@ -116,7 +116,7 @@
};
var sandbox = new Cu.Sandbox(window, sandboxOptions);
// The second sandbox is for testing the exportHelper version of the cloneInto
var sandbox2 = new Cu.Sandbox("http://example.com", sandboxOptions);
var sandbox2 = new Cu.Sandbox("https://example.com", sandboxOptions);
sandbox.sandbox2 = sandbox2;
sandbox2.sandbox = sandbox;
@ -168,9 +168,9 @@
'CloneInto should only work on less privileged target scopes.',
/denied|insecure/);
var cloneTarget = new Cu.Sandbox('http://example.com');
var sameOriginSB = new Cu.Sandbox('http://example.com', { wantGlobalProperties: ['XMLHttpRequest'] });
var crossOriginSB = new Cu.Sandbox('http://example.net', { wantGlobalProperties: ['XMLHttpRequest'] });
var cloneTarget = new Cu.Sandbox("https://example.com");
var sameOriginSB = new Cu.Sandbox("https://example.com", { wantGlobalProperties: ['XMLHttpRequest'] });
var crossOriginSB = new Cu.Sandbox("https://example.net", { wantGlobalProperties: ['XMLHttpRequest'] });
sandbox2.cloneTarget = cloneTarget;
sandbox2.soXHR = Cu.evalInSandbox('new XMLHttpRequest()', sameOriginSB);
sandbox2.xoXHR = Cu.evalInSandbox('new XMLHttpRequest()', crossOriginSB);

View file

@ -30,7 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
case 1:
ok(/native code/.test(window[0].canary.toString()), "System function should be sourceless: " + window[0].canary.toString());
ok(/native code/.test(window[0].onload.toString()), "System event handler should be sourceless: " + window[0].onload.toString());
var sb = new Cu.Sandbox('http://www.example.com', { discardSource: true });
var sb = new Cu.Sandbox("https://www.example.com", { discardSource: true });
Cu.evalInSandbox('function canary() { var someBitOfSource = 42; }', sb);
ok(/native code/.test(sb.canary.toString()), "Function from sandbox with explicit discarding should be sourceless");
try {
@ -40,7 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=990353
ok(/some error/.test(e), "Threw exception as expected: " + e);
ok(/throwSomething/.test(e.stack), "Exception stack trace works: " + e.stack);
}
window[0].location = "http://example.org/tests/js/xpconnect/tests/chrome/file_discardSystemSource.html";
window[0].location = "https://example.org/tests/js/xpconnect/tests/chrome/file_discardSystemSource.html";
break;
case 2:
ok(/someBitOfSource/.test(Cu.waiveXrays(window[0]).canary.toString()), "Content function should have source");

View file

@ -16,7 +16,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=877673
<!-- test code goes here -->
<script type="application/javascript"><![CDATA[
SimpleTest.waitForExplicitFinish();
var sb = new Cu.Sandbox("http://example.org", {wantExportHelpers: true});
var sb = new Cu.Sandbox("https://example.org", {wantExportHelpers: true});
sb.ok = ok;
function executeIn(frame, script, exceptionCb) {
@ -62,7 +62,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=877673
SimpleTest.finish();
}
]]></script>
<iframe src="http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"
<iframe src="https://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html"
onload="testSameOrigin(this)">
</iframe>
<iframe src="http://mochi.test:8888/tests/js/xpconnect/tests/mochitest/file_empty.html"

View file

@ -87,8 +87,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=758415
// Set up the sandboxes. Use an expanded principal to get xrays with
// exclusive expandos.
sb1 = Cu.Sandbox(["http://test1.example.org", "http://test2.example.org"]);
sb2 = Cu.Sandbox(["http://test1.example.org", "http://test2.example.org"]);
sb1 = Cu.Sandbox(["https://test1.example.org", "https://test2.example.org"]);
sb2 = Cu.Sandbox(["https://test1.example.org", "https://test2.example.org"]);
sb1.target = target;
sb2.target = target;
sb1.name = "sandbox1";
@ -137,9 +137,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=758415
]]>
</script>
<iframe id="frameA1" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameA2" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameA3" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameB" onload="frameLoaded();" type="content" src="http://test2.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameC" onload="frameLoaded();" type="content" src="http://sub1.test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameA1" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameA2" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameA3" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameB" onload="frameLoaded();" type="content" src="https://test2.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
<iframe id="frameC" onload="frameLoaded();" type="content" src="https://sub1.test1.example.org/tests/js/xpconnect/tests/mochitest/file_expandosharing.html" />
</window>

View file

@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931
is(utils.getClassName(location), "Location", "chrome doesn't have location wrappers")
is(utils.getClassName(win), "Proxy", "win is an Proxy");
is(utils.getClassName(win.location), "Proxy", "deep wrapping works");
is(win.location.href, "http://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html",
is(win.location.href, "https://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html",
"can still get strings out");
var unsafeWin = win.wrappedJSObject;
@ -78,7 +78,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500931
]]></script>
<iframe type="content"
src="http://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html"
src="https://example.org/tests/js/xpconnect/tests/mochitest/chrome_wrappers_helper.html"
onload="go()"
id="ifr">
</iframe>

View file

@ -42,8 +42,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1355109
function testSandbox(iterations) {
// Create an expanded principal sandbox to get xrays with exclusive
// expandos.
var sandbox = new Cu.Sandbox(["http://test1.example.org",
"http://test2.example.org"]);
var sandbox = new Cu.Sandbox(["https://test1.example.org",
"https://test2.example.org"]);
sandbox.iframeWindows = new sandbox.Array();
for (let iframe of document.getElementsByTagName('iframe')) {
sandbox.iframeWindows.push(iframe.contentWindow);
@ -76,6 +76,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1355109
}
]]>
</script>
<iframe id="inlineFrame1" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" />
<iframe id="inlineFrame2" onload="frameLoaded();" type="content" src="http://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" />
<iframe id="inlineFrame1" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" />
<iframe id="inlineFrame2" onload="frameLoaded();" type="content" src="https://test1.example.org/tests/js/xpconnect/tests/mochitest/file_xrayic.html" />
</window>