From b578ccf77b12ccdc435be07c36c74f3083cc2bc5 Mon Sep 17 00:00:00 2001 From: Tom Tung Date: Thu, 27 Feb 2020 12:28:13 +0000 Subject: [PATCH] Bug 1618483 - Have a test to ensure the behavior between QMS::ClearClient and localStorage; r=dom-workers-and-storage-reviewers,janv Differential Revision: https://phabricator.services.mozilla.com/D64550 --HG-- extra : moz-landing-system : lando --- dom/quota/test/unit/head-shared.js | 10 +++++ .../test/unit/test_orpahnedQuotaObject.js | 45 +++++++++++++++++++ dom/quota/test/unit/xpcshell.ini | 1 + 3 files changed, 56 insertions(+) create mode 100644 dom/quota/test/unit/test_orpahnedQuotaObject.js diff --git a/dom/quota/test/unit/head-shared.js b/dom/quota/test/unit/head-shared.js index db7f8a76b3d9..dfb4ac2a895d 100644 --- a/dom/quota/test/unit/head-shared.js +++ b/dom/quota/test/unit/head-shared.js @@ -215,6 +215,16 @@ function reset(callback) { return request; } +function resetClient(principal, client) { + let request = Services.qms.resetStoragesForPrincipal( + principal, + "default", + client + ); + + return request; +} + function persist(principal, callback) { let request = SpecialPowers._getQuotaManager().persist(principal); request.callback = callback; diff --git a/dom/quota/test/unit/test_orpahnedQuotaObject.js b/dom/quota/test/unit/test_orpahnedQuotaObject.js new file mode 100644 index 000000000000..9f337df1b436 --- /dev/null +++ b/dom/quota/test/unit/test_orpahnedQuotaObject.js @@ -0,0 +1,45 @@ +/** + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +async function testSteps() { + const principal = getPrincipal("https://example.com"); + + info("Setting prefs"); + + SpecialPowers.setBoolPref("dom.storage.next_gen", true); + Services.prefs.setBoolPref("dom.storage.client_validation", false); + + info("Clearing"); + + let request = clear(); + await requestFinished(request); + + info("Creating simpledb"); + + let database = getSimpleDatabase(principal); + + request = database.open("data"); + await requestFinished(request); + + info("Creating localStorage"); + + let storage = Services.domStorageManager.createStorage( + null, + principal, + principal, + "" + ); + storage.setItem("key", "value"); + + info("Clearing simpledb"); + + request = clearClient(principal, "default", "sdb"); + await requestFinished(request); + + info("Resetting localStorage"); + + request = resetClient(principal, "ls"); + await requestFinished(request); +} diff --git a/dom/quota/test/unit/xpcshell.ini b/dom/quota/test/unit/xpcshell.ini index 86fa656585d0..44571d26fd4a 100644 --- a/dom/quota/test/unit/xpcshell.ini +++ b/dom/quota/test/unit/xpcshell.ini @@ -33,6 +33,7 @@ support-files = [test_initTemporaryStorage.js] [test_listOrigins.js] [test_originWithCaret.js] +[test_orpahnedQuotaObject.js] [test_persist.js] [test_persist_eviction.js] [test_persist_globalLimit.js]