blob: 0a8a5acdef003f4d8d75ec853ddab24c301a37e1 (
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
|
"use strict";
const server = createHttpServer();
server.registerDirectory("/data/", do_get_file("data"));
const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;
function contentScript() {
window.x = 12;
browser.test.assertEq(window.x, 12, "x is 12");
browser.test.notifyPass("background test passed");
}
let extensionData = {
manifest: {
content_scripts: [
{
matches: ["http://localhost/*/file_sample.html"],
js: ["content_script.js"],
run_at: "document_idle",
},
],
},
files: {
"content_script.js": contentScript,
},
};
add_task(async function test_contentscript() {
let extension = ExtensionTestUtils.loadExtension(extensionData);
await extension.startup();
let contentPage = await ExtensionTestUtils.loadContentPage(
`${BASE_URL}/file_sample.html`
);
await extension.awaitFinish();
await contentPage.close();
await extension.unload();
});
|