fune/devtools/client/aboutdebugging/test/browser_service_workers_status.js
Julian Descottes 829b30f34e Bug 1345932 - show warning info in about:debugging#workers if multi-e10s is on;r=ochameau
If multi e10s is enabled, service worker debugging is unavailable.
We temporarily disabled the start/push/debug buttons in about:debugging
for all service workers if multi-e10s is on.

A warning section is also displayed on top of about:debugging, letting the
user know that they can set dom.ipc.processCount to 1 in order to force
a single content process and restore debugging capabilities.

MozReview-Commit-ID: IPAlbOq2Hij

--HG--
extra : rebase_source : 493253a65392982e7564343da7654a7ba00a3d6c
extra : source : 7fcfc6bf254734d16bff0145257fc256e7395a79
2017-03-16 16:06:05 +01:00

64 lines
2.4 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Service workers can't be loaded from chrome://,
// but http:// is ok with dom.serviceWorkers.testing.enabled turned on.
const SERVICE_WORKER = URL_ROOT + "service-workers/delay-sw.js";
const TAB_URL = URL_ROOT + "service-workers/delay-sw.html";
const SW_TIMEOUT = 2000;
requestLongerTimeout(2);
add_task(function* () {
yield enableServiceWorkerDebugging();
yield pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
yield pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
let { tab, document } = yield openAboutDebugging("workers");
// Listen for mutations in the service-workers list.
let serviceWorkersElement = getServiceWorkerList(document);
let onMutation = waitForMutation(serviceWorkersElement, { childList: true });
let swTab = yield addTab(TAB_URL);
info("Make the test page notify us when the service worker sends a message.");
// Wait for the service-workers list to update.
yield onMutation;
// Check that the service worker appears in the UI
let names = [...document.querySelectorAll("#service-workers .target-name")];
let name = names.filter(element => element.textContent === SERVICE_WORKER)[0];
ok(name, "Found the service worker in the list");
let targetElement = name.parentNode.parentNode;
let status = targetElement.querySelector(".target-status");
// We might miss the registering state in some setup...
if (status.textContent == "Registering") {
yield waitForMutation(serviceWorkersElement, { childList: true, subtree: true });
}
is(status.textContent, "Running", "Service worker is currently running");
yield waitForMutation(serviceWorkersElement, { attributes: true, subtree: true });
is(status.textContent, "Stopped", "Service worker is currently stopped");
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker unregistered");
} catch (e) {
ok(false, "Service worker not unregistered; " + e);
}
// Check that the service worker disappeared from the UI
names = [...document.querySelectorAll("#service-workers .target-name")];
names = names.map(element => element.textContent);
ok(!names.includes(SERVICE_WORKER),
"The service worker url is no longer in the list: " + names);
yield removeTab(swTab);
yield closeAboutDebugging(tab);
});