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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<!DOCTYPE HTML>
<html>
<head>
<title>Test for simple WebExtension</title>
<meta charset="utf-8">
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SpawnTask.js"></script>
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="chrome_head.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
add_task(function* test_versioned_js() {
// We need to deal with escaping the close script tags.
// May as well consolidate it into one place.
let script = attrs => `<script ${attrs}><\/script>`;
let extension = ExtensionTestUtils.loadExtension({
manifest: {
"background": {"page": "background.html"},
},
files: {
"background.html": `
<meta charset="utf-8">
${script('src="background.js" type="application/javascript"')}
${script('src="background-1.js" type="application/javascript;version=1.8"')}
${script('src="background-2.js" type="application/javascript;version=latest"')}
${script('src="background-3.js" type="application/javascript"')}
`,
"background.js": function() {
window.reportResult = msg => {
browser.test.assertEq(
msg, "background-script-3",
"Expected a message only from the unversioned background script.");
browser.test.sendMessage("finished");
};
},
"background-1.js": function() {
window.reportResult("background-script-1");
},
"background-2.js": function() {
window.reportResult("background-script-2");
},
"background-3.js": function() {
window.reportResult("background-script-3");
},
},
});
let messages = [/Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/,
/Versioned JavaScript.*not supported in WebExtension.*developer\.mozilla\.org/];
let waitForConsole = new Promise(resolve => {
SimpleTest.monitorConsole(resolve, messages);
});
info("loading extension");
yield Promise.all([extension.startup(),
extension.awaitMessage("finished")]);
info("waiting for console");
SimpleTest.endMonitorConsole();
yield waitForConsole;
info("unloading extension");
yield extension.unload();
info("test complete");
});
</script>
</body>
</html>
|