Backed out changeset dd551956b332 (bug 1546296) for bc failures at browser_serviceworkers.js. CLOSED TREE

This commit is contained in:
Brindusan Cristian 2019-05-10 00:38:56 +03:00
Родитель 9ea768b97e
Коммит cab8f31085
6 изменённых файлов: 7 добавлений и 105 удалений

Просмотреть файл

@ -362,10 +362,13 @@ const QuotaCleaner = {
// Clear sessionStorage
Services.obs.notifyObservers(null, "browser:purge-sessionStorage", aHost);
let exceptionThrown = false;
// ServiceWorkers: they must be removed before cleaning QuotaManager.
return ServiceWorkerCleanUp.removeFromHost(aHost)
.then(_ => /* exceptionThrown = */ false, _ => /* exceptionThrown = */ true)
.then(exceptionThrown => {
return Promise.all([
ServiceWorkerCleanUp.removeFromHost("http://" + aHost).catch(_ => { exceptionThrown = true; }),
ServiceWorkerCleanUp.removeFromHost("https://" + aHost).catch(_ => { exceptionThrown = true; }),
]).then(() => {
// QuotaManager: In the event of a failure, we call reject to propagate
// the error upwards.

Просмотреть файл

@ -102,7 +102,7 @@ var SiteDataTestUtils = {
// eslint-disable-next-line no-undef
let r = await content.navigator.serviceWorker.register(p);
return new Promise(resolve => {
let worker = r.installing || r.waiting || r.active;
let worker = r.installing;
worker.addEventListener("statechange", () => {
if (worker.state === "installed") {
resolve();

Просмотреть файл

@ -25,8 +25,6 @@ XPCOM_MANIFESTS += [
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
BROWSER_CHROME_MANIFESTS += ['tests/browser/browser.ini']
include('/ipc/chromium/chromium-config.mozbuild')
with Files('**'):

Просмотреть файл

@ -1,2 +0,0 @@
[browser_serviceworkers.js]
support-files = worker.js

Просмотреть файл

@ -1,96 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const {SiteDataTestUtils} = ChromeUtils.import("resource://testing-common/SiteDataTestUtils.jsm");
function addServiceWorker(origin) {
let swURL = getRootDirectory(gTestPath).replace("chrome://mochitests/content", origin) + "worker.js";
return SiteDataTestUtils.addServiceWorker(swURL);
}
add_task(async function test_deleteFromHost() {
await addServiceWorker("https://example.com");
await addServiceWorker("https://example.org");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has a service worker");
ok(true, "example.com has a service worker");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has a service worker");
ok(true, "example.org has a service worker");
await new Promise(aResolve => {
Services.clearData.deleteDataFromHost("example.com", true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA, value => {
Assert.equal(value, 0);
aResolve();
});
});
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has no service worker");
ok(SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has a service worker");
await new Promise(aResolve => {
Services.clearData.deleteDataFromHost("example.org", true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA, value => {
Assert.equal(value, 0);
aResolve();
});
});
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has no service worker");
});
add_task(async function test_deleteFromPrincipal() {
await addServiceWorker("https://example.com");
await addServiceWorker("https://example.org");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has a service worker");
ok(true, "example.com has a service worker");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has a service worker");
ok(true, "example.org has a service worker");
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("https://example.com/");
await new Promise(aResolve => {
Services.clearData.deleteDataFromPrincipal(principal, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA, value => {
Assert.equal(value, 0);
aResolve();
});
});
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has no service worker");
ok(SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has a service worker");
principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin("https://example.org/");
await new Promise(aResolve => {
Services.clearData.deleteDataFromPrincipal(principal, true, Ci.nsIClearDataService.CLEAR_DOM_QUOTA, value => {
Assert.equal(value, 0);
aResolve();
});
});
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has no service worker");
});
add_task(async function test_deleteAll() {
await addServiceWorker("https://example.com");
await addServiceWorker("https://example.org");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has a service worker");
ok(true, "example.com has a service worker");
await TestUtils.waitForCondition(() => SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has a service worker");
ok(true, "example.org has a service worker");
await new Promise(aResolve => {
Services.clearData.deleteData(Ci.nsIClearDataService.CLEAR_DOM_QUOTA, value => {
Assert.equal(value, 0);
aResolve();
});
});
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.com"), "example.com has no service worker");
ok(!SiteDataTestUtils.hasServiceWorkers("https://example.org"), "example.org has no service worker");
await SiteDataTestUtils.clear();
});

Просмотреть файл

@ -1 +0,0 @@
console.log("hello");