browser_inspector_select-last-selected.js (1966B)
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 requestLongerTimeout(2); 7 8 // Checks that the expected default node is selected after a page navigation or 9 // a reload. 10 var PAGE_1 = URL_ROOT_SSL + "doc_inspector_select-last-selected-01.html"; 11 var PAGE_2 = URL_ROOT_SSL + "doc_inspector_select-last-selected-02.html"; 12 13 // An array of test cases with following properties: 14 // - url: URL to navigate to. If URL == content.location, reload instead. 15 // - nodeToSelect: a selector for a node to select before navigation. If null, 16 // whatever is selected stays selected. 17 // - selectedNode: a selector for a node that is selected after navigation. 18 var TEST_DATA = [ 19 { 20 url: PAGE_1, 21 nodeToSelect: "#id1", 22 selectedNode: "#id1", 23 }, 24 { 25 url: PAGE_1, 26 nodeToSelect: "#id2", 27 selectedNode: "#id2", 28 }, 29 { 30 url: PAGE_1, 31 nodeToSelect: "#id3", 32 selectedNode: "#id3", 33 }, 34 { 35 url: PAGE_1, 36 nodeToSelect: "#id4", 37 selectedNode: "#id4", 38 }, 39 { 40 url: PAGE_2, 41 nodeToSelect: null, 42 selectedNode: "body", 43 }, 44 { 45 url: PAGE_1, 46 nodeToSelect: "#id5", 47 selectedNode: "body", 48 }, 49 { 50 url: PAGE_2, 51 nodeToSelect: null, 52 selectedNode: "body", 53 }, 54 ]; 55 56 add_task(async function () { 57 const { inspector } = await openInspectorForURL(PAGE_1); 58 59 for (const { url, nodeToSelect, selectedNode } of TEST_DATA) { 60 if (nodeToSelect) { 61 info("Selecting node " + nodeToSelect + " before navigation."); 62 await selectNode(nodeToSelect, inspector); 63 } 64 65 await navigateTo(url); 66 67 const nodeFront = await getNodeFront(selectedNode, inspector); 68 ok(nodeFront, "Got expected node front"); 69 is( 70 inspector.selection.nodeFront, 71 nodeFront, 72 selectedNode + " is selected after navigation." 73 ); 74 } 75 });