diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js')
-rw-r--r-- | toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js b/toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js new file mode 100644 index 0000000000..05489d753d --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/test_ext_sandboxed_resource.js @@ -0,0 +1,55 @@ +"use strict"; + +// Test that an extension page which is sandboxed may load resources +// from itself without relying on web acessible resources. +add_task(async function test_webext_background_sandbox_privileges() { + function backgroundSubframeScript() { + window.parent.postMessage(typeof browser, "*"); + } + + function backgroundScript() { + /* eslint-disable-next-line mozilla/balanced-listeners */ + window.addEventListener("message", event => { + if (event.data == "undefined") { + browser.test.notifyPass("webext-background-sandbox-privileges"); + } else { + browser.test.notifyFail("webext-background-sandbox-privileges"); + } + }); + } + + let extensionData = { + manifest: { + background: { + page: "background.html", + }, + }, + files: { + "background.html": `<!DOCTYPE> + <html> + <head> + <meta charset="utf-8"> + </head> + <body> + <script src="background.js"><\/script> + <iframe src="background-subframe.html" sandbox="allow-scripts"></iframe> + </body> + </html>`, + "background-subframe.html": `<!DOCTYPE> + <html> + <head> + <meta charset="utf-8"> + <script src="background-subframe.js"><\/script> + </head> + </html>`, + "background-subframe.js": backgroundSubframeScript, + "background.js": backgroundScript, + }, + }; + let extension = ExtensionTestUtils.loadExtension(extensionData); + + await extension.startup(); + + await extension.awaitFinish("webext-background-sandbox-privileges"); + await extension.unload(); +}); |