browser_toolbox_rule_view_reload.js (1736B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Check that the ruleview is still correctly displayed after reloading the page. 8 * See Bug 1487284. 9 */ 10 11 // To trigger the initial issue, the stylesheet needs to be fetched from the network 12 // monitor, so we can not use a data:uri with inline styles here. 13 const TEST_URI = `${URL_ROOT}doc_toolbox_rule_view.html`; 14 15 addRDMTaskWithPreAndPost( 16 TEST_URI, 17 async function pre_task() { 18 info("Open the rule-view and select the test node before opening RDM"); 19 const ruleViewValues = await openRuleView(); 20 const { inspector, view } = ruleViewValues; 21 await selectNode("div", inspector); 22 23 is(numberOfRules(view), 2, "Rule view has two rules."); 24 25 return ruleViewValues; 26 }, 27 async function task({ preTaskValue }) { 28 const { inspector, view } = preTaskValue; 29 30 info("Reload the current page"); 31 const onNewRoot = inspector.once("new-root"); 32 const onRuleViewRefreshed = inspector.once("rule-view-refreshed"); 33 await reloadBrowser(); 34 await onNewRoot; 35 await inspector.markup._waitForChildren(); 36 await onRuleViewRefreshed; 37 38 // Await two reflows of the Rule View window. 39 await new Promise(resolve => { 40 view.styleWindow.requestAnimationFrame(() => { 41 view.styleWindow.requestAnimationFrame(resolve); 42 }); 43 }); 44 45 info("Wait until rule view shows 2 rules"); 46 await waitFor(() => numberOfRules(view) == 2); 47 is( 48 numberOfRules(view), 49 2, 50 "Rule view still has two rules and is not empty." 51 ); 52 }, 53 null 54 ); 55 56 function numberOfRules(ruleView) { 57 return ruleView.element.querySelectorAll(".ruleview-code").length; 58 }