browser_compatibility_throbber.js (1818B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test whether the throbber is displayed correctly or not. 7 8 const TEST_URI = ` 9 <style> 10 body { 11 color: blue; 12 border-block-color: lime; 13 user-modify: read-only; 14 } 15 div { 16 font-variant-alternates: historical-forms; 17 } 18 </style> 19 <body> 20 <div>test</div> 21 </body> 22 `; 23 24 const { 25 COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_START, 26 } = require("resource://devtools/client/inspector/compatibility/actions/index.js"); 27 28 add_task(async function () { 29 const tab = await addTab( 30 "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI) 31 ); 32 33 const { allElementsPane, inspector, selectedElementPane } = 34 await openCompatibilityView(); 35 36 info("Check the throbber visibility at the beginning"); 37 assertThrobber(allElementsPane, false); 38 assertThrobber(selectedElementPane, false); 39 40 info("Reload the browsing page"); 41 const onStart = waitForDispatch( 42 inspector.store, 43 COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_START 44 ); 45 const onComplete = waitForDispatch( 46 inspector.store, 47 COMPATIBILITY_UPDATE_TOP_LEVEL_TARGET_COMPLETE 48 ); 49 gBrowser.reloadTab(tab); 50 51 info("Check the throbber visibility of after starting updating action"); 52 await onStart; 53 assertThrobber(allElementsPane, true); 54 assertThrobber(selectedElementPane, false); 55 56 info("Check the throbber visibility of after completing updating action"); 57 await onComplete; 58 assertThrobber(allElementsPane, false); 59 assertThrobber(selectedElementPane, false); 60 }); 61 62 function assertThrobber(panel, expectedVisibility) { 63 const isThrobberVisible = !!panel.querySelector(".devtools-throbber"); 64 is( 65 isThrobberVisible, 66 expectedVisibility, 67 "Visibility of the throbber is correct" 68 ); 69 }