2016-03-17 13:03:05 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const TAB_URL = EXAMPLE_URL + "bug1047663_tab.html";
|
|
|
|
const WORKER_URL = EXAMPLE_URL + "bug1047663_worker.sjs";
|
|
|
|
|
|
|
|
function test() {
|
|
|
|
waitForExplicitFinish();
|
|
|
|
|
2017-07-11 03:04:00 +03:00
|
|
|
// Disable rcwn to make cache behavior deterministic.
|
|
|
|
let rcwnEnabled = Preferences.get("network.http.rcwn.enabled");
|
|
|
|
Preferences.set("network.http.rcwn.enabled", false);
|
|
|
|
registerCleanupFunction(()=>{
|
|
|
|
Preferences.set("network.http.rcwn.enabled", rcwnEnabled);
|
|
|
|
});
|
|
|
|
|
2017-06-22 13:51:42 +03:00
|
|
|
(async function() {
|
|
|
|
let tab = await addTab(TAB_URL);
|
2016-03-17 13:03:05 +03:00
|
|
|
|
|
|
|
// Create a worker. Post a message to it, and check the reply. Since the
|
|
|
|
// server side JavaScript file returns the first source for the first
|
|
|
|
// request, the reply should be "one". If the reply is correct, terminate
|
|
|
|
// the worker.
|
2017-06-22 13:51:42 +03:00
|
|
|
await createWorkerInTab(tab, WORKER_URL);
|
|
|
|
let message = await postMessageToWorkerInTab(tab, WORKER_URL, "ping");
|
2016-03-17 13:03:05 +03:00
|
|
|
is(message, "one");
|
2017-06-22 13:51:42 +03:00
|
|
|
await terminateWorkerInTab(tab, WORKER_URL);
|
2016-03-17 13:03:05 +03:00
|
|
|
|
|
|
|
// Create a second worker with the same URL. Post a message to it, and check
|
|
|
|
// the reply. The server side JavaScript file returns the second source for
|
|
|
|
// all subsequent requests, but since the cache is still enabled, the reply
|
|
|
|
// should still be "one". If the reply is correct, terminate the worker.
|
2017-06-22 13:51:42 +03:00
|
|
|
await createWorkerInTab(tab, WORKER_URL);
|
|
|
|
message = await postMessageToWorkerInTab(tab, WORKER_URL, "ping");
|
2016-03-17 13:03:05 +03:00
|
|
|
is(message, "one");
|
2017-06-22 13:51:42 +03:00
|
|
|
await terminateWorkerInTab(tab, WORKER_URL);
|
2016-03-17 13:03:05 +03:00
|
|
|
|
|
|
|
// Disable the cache in this tab. This should also disable the cache for all
|
|
|
|
// workers in this tab.
|
2017-06-22 13:51:42 +03:00
|
|
|
await disableCacheInTab(tab);
|
2016-03-17 13:03:05 +03:00
|
|
|
|
|
|
|
// Create a third worker with the same URL. Post a message to it, and check
|
|
|
|
// the reply. Since the server side JavaScript file returns the second
|
|
|
|
// source for all subsequent requests, and the cache is now disabled, the
|
|
|
|
// reply should now be "two". If the reply is correct, terminate the worker.
|
2017-06-22 13:51:42 +03:00
|
|
|
await createWorkerInTab(tab, WORKER_URL);
|
|
|
|
message = await postMessageToWorkerInTab(tab, WORKER_URL, "ping");
|
2016-03-17 13:03:05 +03:00
|
|
|
is(message, "two");
|
2017-06-22 13:51:42 +03:00
|
|
|
await terminateWorkerInTab(tab, WORKER_URL);
|
2016-03-17 13:03:05 +03:00
|
|
|
|
|
|
|
removeTab(tab);
|
|
|
|
|
|
|
|
finish();
|
2017-06-22 13:51:42 +03:00
|
|
|
})();
|
2016-03-17 13:03:05 +03:00
|
|
|
}
|