зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1644188 - [devtools] Unregister service worker in all resourceWatcher/targetList tests. r=jdescottes
Not doing that, makes the browser_resources_sources.js test to fail because of pending SW's target which comes with unexpected sources. Differential Revision: https://phabricator.services.mozilla.com/D98460
This commit is contained in:
Родитель
53d3715f45
Коммит
1a154de122
|
@ -102,6 +102,12 @@ async function testTabConsoleMessagesResources(executeInIframe) {
|
|||
|
||||
targetList.destroy();
|
||||
await client.close();
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
|
||||
async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
||||
|
@ -163,6 +169,12 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources(
|
|||
|
||||
await targetList.destroy();
|
||||
await client.close();
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
|
||||
async function logExistingMessages(browser, executeInIframe) {
|
||||
|
|
|
@ -213,6 +213,12 @@ add_task(async function() {
|
|||
|
||||
targetList.destroy();
|
||||
await client.close();
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
});
|
||||
|
||||
function checkStartWorkerLogMessage(resource, expectedUrl) {
|
||||
|
|
|
@ -130,6 +130,12 @@ add_task(async function() {
|
|||
|
||||
await targetList.stopListening();
|
||||
await client.close();
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
});
|
||||
|
||||
async function assertResources(resources, expected) {
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(async function() {
|
|||
|
||||
const client = await createLocalClient();
|
||||
const mainRoot = client.mainRoot;
|
||||
await addTab(FISSION_TEST_URL);
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
info("Test TargetList against workers via the parent process target");
|
||||
|
||||
|
@ -182,6 +182,12 @@ add_task(async function() {
|
|||
await unregisterAllServiceWorkers(client);
|
||||
|
||||
await client.close();
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
});
|
||||
|
||||
function sortFronts(f1, f2) {
|
||||
|
|
|
@ -159,5 +159,10 @@ async function testTabFrames(mainRoot) {
|
|||
targetList.destroy();
|
||||
await waitForAllTargetsToBeAttached(targetList);
|
||||
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ add_task(async function() {
|
|||
const client = await createLocalClient();
|
||||
const mainRoot = client.mainRoot;
|
||||
|
||||
await addTab(FISSION_TEST_URL);
|
||||
const tab = await addTab(FISSION_TEST_URL);
|
||||
|
||||
// Instantiate a worker in the parent process
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
|
@ -100,4 +100,9 @@ add_task(async function() {
|
|||
await waitForAllTargetsToBeAttached(targetList);
|
||||
|
||||
await client.close();
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -63,10 +63,10 @@ add_task(async function() {
|
|||
);
|
||||
|
||||
info("Unregister the worker and wait until onDestroyed is called.");
|
||||
SpecialPowers.spawn(tab.linkedBrowser, [], function() {
|
||||
const win = content.wrappedJSObject;
|
||||
// win.registration is set by the test page.
|
||||
win.registration.unregister();
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
await waitUntil(() => targets.length === 0);
|
||||
|
||||
|
|
|
@ -348,10 +348,11 @@ async function watchServiceWorkerTargets({
|
|||
|
||||
async function unregisterServiceWorker(tab, expectedPageUrl) {
|
||||
await waitForRegistrationReady(tab, expectedPageUrl);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], () =>
|
||||
// win.registration is set by the test page.
|
||||
content.wrappedJSObject.registration.unregister()
|
||||
);
|
||||
await SpecialPowers.spawn(tab.linkedBrowser, [], async () => {
|
||||
// registrationPromise is set by the test page.
|
||||
const registration = await content.wrappedJSObject.registrationPromise;
|
||||
registration.unregister();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,7 +364,7 @@ async function waitForRegistrationReady(tab, expectedPageUrl) {
|
|||
try {
|
||||
const win = content.wrappedJSObject;
|
||||
const isExpectedUrl = win.location.href === _url;
|
||||
const hasRegistration = !!win.registration;
|
||||
const hasRegistration = !!win.registrationPromise;
|
||||
return isExpectedUrl && hasRegistration;
|
||||
} catch (e) {
|
||||
return false;
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
const sharedWorker = new SharedWorker("https://example.com/browser/devtools/shared/resources/tests/test_worker.js#shared-worker");
|
||||
|
||||
if (!params.has("noServiceWorker")) {
|
||||
(async function () {
|
||||
// Expose a reference to the registration so that tests can unregister it.
|
||||
window.registration = await navigator.serviceWorker.register("https://example.com/browser/devtools/shared/resources/tests/test_service_worker.js#service-worker");
|
||||
})();
|
||||
// Expose a reference to the registration so that tests can unregister it.
|
||||
window.registrationPromise = navigator.serviceWorker.register("https://example.com/browser/devtools/shared/resources/tests/test_service_worker.js#service-worker");
|
||||
}
|
||||
|
||||
/* exported logMessageInWorker */
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
// Assign the worker to a global variable in order to avoid
|
||||
// having it be GCed.
|
||||
this.worker = new Worker("worker-sources.js");
|
||||
navigator.serviceWorker.register("service-worker-sources.js");
|
||||
window.registrationPromise = navigator.serviceWorker.register("service-worker-sources.js");
|
||||
</script>
|
||||
<script src="sources.js"></script>
|
||||
</body>
|
||||
|
|
|
@ -12,10 +12,8 @@
|
|||
<script>
|
||||
"use strict";
|
||||
|
||||
(async function () {
|
||||
// Expose a reference to the registration so that tests can unregister it.
|
||||
window.registration = await navigator.serviceWorker.register("test_sw_page_worker.js");
|
||||
})();
|
||||
// Expose a reference to the registration so that tests can unregister it.
|
||||
window.registrationPromise = navigator.serviceWorker.register("test_sw_page_worker.js");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче