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
|
var MAX_TOTAL_VIEWERS = "browser.sessionhistory.max_total_viewers";
var TAB1_URL = EXAMPLE_URL + "doc_WorkerActor.attach-tab1.html";
var TAB2_URL = EXAMPLE_URL + "doc_WorkerActor.attach-tab2.html";
var WORKER1_URL = "code_WorkerActor.attach-worker1.js";
var WORKER2_URL = "code_WorkerActor.attach-worker2.js";
function test() {
Task.spawn(function* () {
let oldMaxTotalViewers = SpecialPowers.getIntPref(MAX_TOTAL_VIEWERS);
SpecialPowers.setIntPref(MAX_TOTAL_VIEWERS, 10);
DebuggerServer.init();
DebuggerServer.addBrowserActors();
let client = new DebuggerClient(DebuggerServer.connectPipe());
yield connect(client);
let tab = yield addTab(TAB1_URL);
let { tabs } = yield listTabs(client);
let [, tabClient] = yield attachTab(client, findTab(tabs, TAB1_URL));
yield listWorkers(tabClient);
// If a page still has pending network requests, it will not be moved into
// the bfcache. Consequently, we cannot use waitForWorkerListChanged here,
// because the worker is not guaranteed to have finished loading when it is
// registered. Instead, we have to wait for the promise returned by
// createWorker in the tab to be resolved.
yield createWorkerInTab(tab, WORKER1_URL);
let { workers } = yield listWorkers(tabClient);
let [, workerClient1] = yield attachWorker(tabClient,
findWorker(workers, WORKER1_URL));
is(workerClient1.isClosed, false, "worker in tab 1 should not be closed");
executeSoon(() => {
tab.linkedBrowser.loadURI(TAB2_URL);
});
yield waitForWorkerClose(workerClient1);
is(workerClient1.isClosed, true, "worker in tab 1 should be closed");
yield createWorkerInTab(tab, WORKER2_URL);
({ workers } = yield listWorkers(tabClient));
let [, workerClient2] = yield attachWorker(tabClient,
findWorker(workers, WORKER2_URL));
is(workerClient2.isClosed, false, "worker in tab 2 should not be closed");
executeSoon(() => {
tab.linkedBrowser.contentWindow.history.back();
});
yield waitForWorkerClose(workerClient2);
is(workerClient2.isClosed, true, "worker in tab 2 should be closed");
({ workers } = yield listWorkers(tabClient));
[, workerClient1] = yield attachWorker(tabClient,
findWorker(workers, WORKER1_URL));
is(workerClient1.isClosed, false, "worker in tab 1 should not be closed");
yield close(client);
SpecialPowers.setIntPref(MAX_TOTAL_VIEWERS, oldMaxTotalViewers);
finish();
});
}
|