Source code

Revision control

Other Tools

1
<!DOCTYPE HTML>
2
<html>
3
<head>
4
<title>Tabs reload Test</title>
5
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
7
<script type="text/javascript" src="head.js"></script>
8
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
9
</head>
10
<body>
11
12
<script type="text/javascript">
13
"use strict";
14
15
add_task(async function() {
16
let extension = ExtensionTestUtils.loadExtension({
17
manifest: {
18
"permissions": ["tabs"],
19
},
20
21
files: {
22
"tab.js": function() {
23
browser.runtime.sendMessage("tab-loaded");
24
},
25
"tab.html":
26
`<head>
27
<meta charset="utf-8">
28
<script src="tab.js"><\/script>
29
</head>`,
30
},
31
32
async background() {
33
let tabLoadedCount = 0;
34
35
let tab = await browser.tabs.create({url: "tab.html", active: true});
36
37
browser.runtime.onMessage.addListener(msg => {
38
if (msg == "tab-loaded") {
39
tabLoadedCount++;
40
41
if (tabLoadedCount == 1) {
42
// Reload the tab once passing no arguments.
43
return browser.tabs.reload();
44
}
45
46
if (tabLoadedCount == 2) {
47
// Reload the tab again with explicit arguments.
48
return browser.tabs.reload(tab.id, {
49
bypassCache: false,
50
});
51
}
52
53
if (tabLoadedCount == 3) {
54
browser.test.notifyPass("tabs.reload");
55
}
56
}
57
});
58
},
59
});
60
61
await extension.startup();
62
await extension.awaitFinish("tabs.reload");
63
await extension.unload();
64
});
65
</script>
66
67
</body>
68
</html>