browser_rules_flexbox-highlighter-restored-after-reload.js (2295B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Tests that the flexbox highlighter is re-displayed after reloading a page. 7 8 const TEST_URI = ` 9 <style type='text/css'> 10 #flex { 11 display: flex; 12 } 13 </style> 14 <div id="flex"></div> 15 `; 16 17 const OTHER_URI = ` 18 <style type='text/css'> 19 #grid { 20 display: grid; 21 } 22 </style> 23 <div id="grid"></div> 24 `; 25 26 add_task(async function () { 27 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); 28 29 info("Check that the flexbox highlighter can be displayed."); 30 const { inspector, view } = await openRuleView(); 31 const HIGHLIGHTER_TYPE = inspector.highlighters.TYPES.FLEXBOX; 32 const { 33 getActiveHighlighter, 34 waitForHighlighterTypeShown, 35 waitForHighlighterTypeRestored, 36 waitForHighlighterTypeDiscarded, 37 } = getHighlighterTestHelpers(inspector); 38 39 await selectNode("#flex", inspector); 40 const container = getRuleViewProperty(view, "#flex", "display").valueSpan; 41 const flexboxToggle = container.querySelector( 42 ".js-toggle-flexbox-highlighter" 43 ); 44 45 info("Toggling ON the flexbox highlighter from the rule-view."); 46 const onHighlighterShown = waitForHighlighterTypeShown(HIGHLIGHTER_TYPE); 47 flexboxToggle.click(); 48 await onHighlighterShown; 49 ok(getActiveHighlighter(HIGHLIGHTER_TYPE), "Flexbox highlighter is shown."); 50 51 info("Reload the page, expect the highlighter to be displayed once again"); 52 const onRestored = waitForHighlighterTypeRestored(HIGHLIGHTER_TYPE); 53 const onReloaded = inspector.once("reloaded"); 54 await reloadBrowser(); 55 info("Wait for inspector to be reloaded after page reload"); 56 await onReloaded; 57 info("Wait for the highlighter to be restored"); 58 await onRestored; 59 ok(getActiveHighlighter(HIGHLIGHTER_TYPE), "Flexbox highlighter restored."); 60 61 info("Navigate to another URL, and check that the highlighter is hidden"); 62 const otherUri = 63 "data:text/html;charset=utf-8," + encodeURIComponent(OTHER_URI); 64 const onDiscarded = waitForHighlighterTypeDiscarded(HIGHLIGHTER_TYPE); 65 await navigateTo(otherUri); 66 info("Expect the highlighter not to be restored"); 67 await onDiscarded; 68 ok(!getActiveHighlighter(HIGHLIGHTER_TYPE), "Flexbox highlighter not shown."); 69 });