browser_private_ls.js (989B)
1 /** 2 * This test is mainly to verify that datastores are cleared when the last 3 * private browsing context exited. 4 */ 5 6 async function lsCheckFunc() { 7 let storage = content.localStorage; 8 9 if (storage.length) { 10 return false; 11 } 12 13 // Store non-ASCII value to verify bug 1552428. 14 storage.setItem("foo", "úžasné"); 15 16 return true; 17 } 18 19 function checkTabWindowLS(tab) { 20 return SpecialPowers.spawn(tab.linkedBrowser, [], lsCheckFunc); 21 } 22 23 add_task(async function () { 24 const pageUrl = 25 "http://example.com/browser/dom/localstorage/test/page_private_ls.html"; 26 27 for (let i = 0; i < 2; i++) { 28 let privateWin = await BrowserTestUtils.openNewBrowserWindow({ 29 private: true, 30 }); 31 32 let privateTab = await BrowserTestUtils.openNewForegroundTab( 33 privateWin.gBrowser, 34 pageUrl 35 ); 36 37 ok( 38 await checkTabWindowLS(privateTab), 39 "LS works correctly in a private-browsing page." 40 ); 41 42 await BrowserTestUtils.closeWindow(privateWin); 43 } 44 });