test_clearStoragesForPrincipal.js (1613B)
1 /** 2 * Any copyright is dedicated to the Public Domain. 3 * http://creativecommons.org/publicdomain/zero/1.0/ 4 */ 5 6 /** 7 * This test is an xpcshell test for clearStoragesForPrincipal. It verifies that 8 * if the removing client is the last client in the targeting origin, then it 9 * is expected to remove the origin directory as well. 10 */ 11 12 async function testSteps() { 13 const testingOrigins = [ 14 { 15 origin: "http://example.com", 16 path: "storage/default/http+++example.com/", 17 only_idb: false, 18 }, 19 { 20 origin: "http://www.mozilla.org", 21 path: "storage/default/http+++www.mozilla.org/", 22 only_idb: true, 23 }, 24 ]; 25 const removingClient = "idb"; 26 27 info("Installing package to create the environment"); 28 // The package is manually created and it contains: 29 // - storage/default/http+++www.mozilla.org/idb/ 30 // - storage/default/http+++www.example.com/idb/ 31 // - storage/default/http+++www.example.com/cache/ 32 installPackage("clearStoragesForPrincipal_profile"); 33 34 let request; 35 let file; 36 for (let i = 0; i < testingOrigins.length; ++i) { 37 info("Clearing"); 38 request = clearClient( 39 getPrincipal(testingOrigins[i].origin), 40 removingClient 41 ); 42 await requestFinished(request); 43 44 info("Verifying"); 45 file = getRelativeFile(testingOrigins[i].path + removingClient); 46 ok(!file.exists(), "Client file doesn't exist"); 47 48 file = getRelativeFile(testingOrigins[i].path); 49 if (testingOrigins[i].only_idb) { 50 todo(!file.exists(), "Origin file doesn't exist"); 51 } else { 52 ok(file.exists(), "Origin file does exist"); 53 } 54 } 55 }