blob: 05489d753de850df757e1c0d2840a01829af295a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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();
});
|