diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/xpconnect/tests/chrome/test_secureContexts.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | js/xpconnect/tests/chrome/test_secureContexts.html | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/js/xpconnect/tests/chrome/test_secureContexts.html b/js/xpconnect/tests/chrome/test_secureContexts.html new file mode 100644 index 0000000000..956e609d5f --- /dev/null +++ b/js/xpconnect/tests/chrome/test_secureContexts.html @@ -0,0 +1,58 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1273687 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 1430164</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://global/skin"/> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> + <iframe id="t" src="https://example.com"></iframe> + <iframe id="i" src="http://example.com"></iframe> + <script type="application/javascript"> + /** Test for Bug 1273687 **/ + 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 + let sb = new Cu.Sandbox('https://www.example.com', + { forceSecureContext: false, + wantGlobalProperties: + ["isSecureContext"] + }); + ok(!Cu.evalInSandbox('isSecureContext', sb)); + + // Check options secure works + let sb2 = new Cu.Sandbox('https://www.example.com', + { 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> |