diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js b/devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js new file mode 100644 index 000000000..68d7f1b26 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg_WorkerActor.attach.js @@ -0,0 +1,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(); + }); +} |