blob: 5bb44ab6450b6bbafce570e9f15af099bd793207 (
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
56
57
58
59
60
61
62
63
64
|
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Tabs lastAccessed Test</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
<script type="text/javascript" src="head.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="text/javascript">
"use strict";
add_task(async function testLastAccessed() {
const past = Date.now();
window.open("https://example.com/?1");
window.open("https://example.com/?2");
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
},
async background() {
browser.test.onMessage.addListener(async function(msg, past) {
if (msg !== "past") {
return;
}
const [tab1] = await browser.tabs.query({url: "https://example.com/?1"});
const [tab2] = await browser.tabs.query({url: "https://example.com/?2"});
browser.test.assertTrue(tab1 && tab2, "Expected tabs were found");
const now = Date.now();
browser.test.assertTrue(typeof tab1.lastAccessed == "number",
"tab1 lastAccessed should be a number");
browser.test.assertTrue(typeof tab2.lastAccessed == "number",
"tab2 lastAccessed should be a number");
browser.test.assertTrue(past <= tab1.lastAccessed &&
tab1.lastAccessed <= tab2.lastAccessed &&
tab2.lastAccessed <= now,
"lastAccessed timestamps are recent and in the right order");
await browser.tabs.remove([tab1.id, tab2.id]);
browser.test.notifyPass("tabs.lastAccessed");
});
},
});
await extension.startup();
await extension.sendMessage("past", past);
await extension.awaitFinish("tabs.lastAccessed");
await extension.unload();
});
</script>
</body>
|