test_databaseWorkStarted.js (1265B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 // This test doesn't use the shared module system (running the same test in 7 // multiple test suites) on purpose because it needs to create an unprivileged 8 // sandbox which is not possible if the test is already running in a sandbox. 9 10 const { PrincipalUtils } = ChromeUtils.importESModule( 11 "resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs" 12 ); 13 const { TestUtils } = ChromeUtils.importESModule( 14 "resource://testing-common/TestUtils.sys.mjs" 15 ); 16 17 add_task(async function testSteps() { 18 const principal = PrincipalUtils.createPrincipal("https://example.com"); 19 20 info("Starting database opening"); 21 22 const openPromise = new Promise(function (resolve, reject) { 23 const sandbox = new Cu.Sandbox(principal, { 24 wantGlobalProperties: ["storage"], 25 forceSecureContext: true, 26 }); 27 sandbox.resolve = resolve; 28 sandbox.reject = reject; 29 Cu.evalInSandbox(`storage.getDirectory().then(resolve, reject);`, sandbox); 30 }); 31 32 info("Waiting for database work to start"); 33 34 await TestUtils.topicObserved("BucketFS::DatabaseWorkStarted"); 35 36 info("Waiting for database to finish opening"); 37 38 await openPromise; 39 });