Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: js/xpconnect/tests/chrome/chrome.toml
<!DOCTYPE HTML>
<html>
<!--
-->
<head>
<meta charset="utf-8">
<script type="application/javascript">
SimpleTest.waitForExplicitFinish();
window.onload = () => {
/* globals t, i */
runTest(t, true);
runTest(i, false);
// Check we can inherit the system principal
var s = new Cu.Sandbox(window, { wantGlobalProperties: ["isSecureContext"] } );
s.ok = ok;
Cu.evalInSandbox('ok(isSecureContext)', s);
// Check options insecure works
{ forceSecureContext: false,
wantGlobalProperties:
["isSecureContext"]
});
ok(!Cu.evalInSandbox('isSecureContext', sb));
// Check options secure works
{ forceSecureContext: true,
wantGlobalProperties:
["isSecureContext"]
});
ok(Cu.evalInSandbox('isSecureContext', sb2));
SimpleTest.finish();
};
// Check dom window inheritance works
function runTest(ifr, expectIsSecureContext) {
let frameWin = ifr.contentWindow;
let s = new Cu.Sandbox(frameWin, { wantGlobalProperties: ["isSecureContext"] });
is(expectIsSecureContext, Cu.evalInSandbox('isSecureContext', s));
// Ensure the implementation of 'wantGlobalProperties' matches the DOM window prototype
let s2 = new Cu.Sandbox(frameWin, { sandboxPrototype: frameWin });
is(expectIsSecureContext, Cu.evalInSandbox('isSecureContext', s2));
}
</script>
</head>
</html>