browser_toolbox_fission_navigation.js (1959B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 const EXAMPLE_COM_URI = 6 "https://example.com/document-builder.sjs?html=<div id=com>com"; 7 const EXAMPLE_ORG_URI = 8 "https://example.org/document-builder.sjs?html=<div id=org>org"; 9 10 add_task(async function () { 11 const tab = await addTab(EXAMPLE_COM_URI); 12 13 const toolbox = await openToolboxForTab(tab, "inspector"); 14 const comNode = await getNodeBySelector(toolbox, "#com"); 15 ok(comNode, "Found node for the COM page"); 16 17 info("Navigate to the ORG page"); 18 await navigateTo(EXAMPLE_ORG_URI); 19 const orgNode = await getNodeBySelector(toolbox, "#org"); 20 ok(orgNode, "Found node for the ORG page"); 21 22 info("Reload the ORG page"); 23 await navigateTo(EXAMPLE_ORG_URI); 24 const orgNodeAfterReload = await getNodeBySelector(toolbox, "#org"); 25 ok(orgNodeAfterReload, "Found node for the ORG page after reload"); 26 isnot(orgNode, orgNodeAfterReload, "The new node is different"); 27 28 info("Navigate back to the COM page"); 29 await navigateTo(EXAMPLE_COM_URI); 30 const comNodeAfterNavigation = await getNodeBySelector(toolbox, "#com"); 31 ok(comNodeAfterNavigation, "Found node for the COM page after navigation"); 32 33 info("Navigate to about:blank"); 34 await navigateTo("about:blank"); 35 const blankBodyAfterNavigation = await getNodeBySelector(toolbox, "body"); 36 ok( 37 blankBodyAfterNavigation, 38 "Found node for the about:blank page after navigation" 39 ); 40 41 info("Navigate to about:robots"); 42 await navigateTo("about:robots"); 43 const aboutRobotsAfterNavigation = await getNodeBySelector( 44 toolbox, 45 "div.container" 46 ); 47 ok( 48 aboutRobotsAfterNavigation, 49 "Found node for the about:robots page after navigation" 50 ); 51 }); 52 53 async function getNodeBySelector(toolbox, selector) { 54 const inspector = await toolbox.selectTool("inspector"); 55 return inspector.walker.querySelector(inspector.walker.rootNode, selector); 56 }