blob: aed4a3822c8f2f366946bbbcfa4312b96cf0d02d (
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
|
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(async function () {
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
},
files: {
"tab.js": function () {
browser.runtime.sendMessage("tab-loaded");
},
"tab.html": `<head>
<meta charset="utf-8">
<script src="tab.js"></script>
</head>`,
},
async background() {
let tabLoadedCount = 0;
let tab = await browser.tabs.create({ url: "tab.html", active: true });
browser.runtime.onMessage.addListener(msg => {
if (msg == "tab-loaded") {
tabLoadedCount++;
if (tabLoadedCount == 1) {
// Reload the tab once passing no arguments.
return browser.tabs.reload();
}
if (tabLoadedCount == 2) {
// Reload the tab again with explicit arguments.
return browser.tabs.reload(tab.id, {
bypassCache: false,
});
}
if (tabLoadedCount == 3) {
browser.test.notifyPass("tabs.reload");
}
}
});
},
});
await extension.startup();
await extension.awaitFinish("tabs.reload");
await extension.unload();
});
|