browser_inspector_navigation.js (2507B)
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 "use strict"; 5 6 // Test that inspector updates when page is navigated. 7 8 const TEST_URL_FILE = 9 "browser/devtools/client/inspector/test/doc_inspector_breadcrumbs.html"; 10 11 const TEST_URL_1 = "https://test1.example.org/" + TEST_URL_FILE; 12 const TEST_URL_2 = "https://test2.example.org/" + TEST_URL_FILE; 13 14 // Bug 1340592: "srcset" attribute causes bfcache events (pageshow/pagehide) 15 // with buggy "persisted" values. 16 const TEST_URL_3 = 17 "data:text/html;charset=utf-8," + 18 encodeURIComponent('<img src="foo.png" srcset="foo.png 1.5x" />'); 19 const TEST_URL_4 = 20 "data:text/html;charset=utf-8," + encodeURIComponent("<h1>bar</h1>"); 21 22 add_task(async function () { 23 const { inspector } = await openInspectorForURL(TEST_URL_1); 24 25 await selectNode("#i1", inspector); 26 27 info("Navigating to a different page."); 28 await navigateTo(TEST_URL_2); 29 30 ok(true, "New page loaded"); 31 await selectNode("#i1", inspector); 32 33 const markuploaded = inspector.once("markuploaded"); 34 const onUpdated = inspector.once("inspector-updated"); 35 36 info("Going back in history"); 37 gBrowser.goBack(); 38 39 info("Waiting for markup view to load after going back in history."); 40 await markuploaded; 41 42 info("Check that the inspector updates"); 43 await onUpdated; 44 45 ok(true, "Old page loaded"); 46 const url = await SpecialPowers.spawn( 47 gBrowser.selectedBrowser, 48 [], 49 () => content.location.href 50 ); 51 is(url, TEST_URL_1, "URL is correct."); 52 53 await selectNode("#i1", inspector); 54 }); 55 56 add_task(async function () { 57 const { inspector } = await openInspectorForURL(TEST_URL_3); 58 59 await selectNode("img", inspector); 60 61 info("Navigating to a different page."); 62 await navigateTo(TEST_URL_4); 63 64 ok(true, "New page loaded"); 65 await selectNode("#h1", inspector); 66 67 const markuploaded = inspector.once("markuploaded"); 68 const onUpdated = inspector.once("inspector-updated"); 69 70 info("Going back in history"); 71 gBrowser.goBack(); 72 73 info("Waiting for markup view to load after going back in history."); 74 await markuploaded; 75 76 info("Check that the inspector updates"); 77 await onUpdated; 78 79 ok(true, "Old page loaded"); 80 const url = await SpecialPowers.spawn( 81 gBrowser.selectedBrowser, 82 [], 83 () => content.location.href 84 ); 85 is(url, TEST_URL_3, "URL is correct."); 86 87 await selectNode("img", inspector); 88 });