browser_storage_sessionstorage_navigation.js (1915B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 add_task(async function () { 8 const URL1 = buildURLWithContent( 9 "example.com", 10 `<h1>example.com</h1>` + 11 `<script>sessionStorage.setItem("lorem", "ipsum");</script>` 12 ); 13 const URL2 = buildURLWithContent( 14 "example.net", 15 `<h1>example.net</h1>` + 16 `<script>sessionStorage.setItem("foo", "bar");</script>` 17 ); 18 19 // open tab 20 await openTabAndSetupStorage(URL1); 21 const doc = gPanelWindow.document; 22 23 // Check first domain 24 // check that both host appear in the storage tree 25 checkTree(doc, ["sessionStorage", "https://example.com"]); 26 // check the table for values 27 await selectTreeItem(["sessionStorage", "https://example.com"]); 28 checkStorageData("lorem", "ipsum"); 29 30 // clear up session storage data before navigating 31 info("Cleaning up sessionStorage…"); 32 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 33 const win = content.wrappedJSObject; 34 await win.sessionStorage.clear(); 35 }); 36 37 // Check second domain 38 await navigateTo(URL2); 39 // wait for storage tree refresh, and check host 40 info("Waiting for storage tree to refresh and show correct host…"); 41 await waitUntil(() => 42 isInTree(doc, ["sessionStorage", "https://example.net"]) 43 ); 44 45 ok( 46 !isInTree(doc, ["sessionStorage", "https://example.com"]), 47 "example.com item is not in the tree anymore" 48 ); 49 50 // check the table for values 51 await selectTreeItem(["sessionStorage", "https://example.net"]); 52 checkStorageData("foo", "bar"); 53 54 info("Check that the sessionStorage node still has the expected label"); 55 is( 56 getTreeNodeLabel(doc, ["sessionStorage"]), 57 "Session Storage", 58 "sessionStorage item is properly displayed" 59 ); 60 });