browser_grids_number-of-css-grids-telemetry.js (1157B)
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 telemetry count for the number of CSS Grid Elements on a page navigation 7 // is correct when the toolbox is opened. 8 9 const TEST_URI1 = ` 10 <div></div> 11 `; 12 13 const TEST_URI2 = ` 14 <style type='text/css'> 15 #grid { 16 display: grid; 17 } 18 </style> 19 <div id="grid"> 20 <div id="cell1">cell1</div> 21 <div id="cell2">cell2</div> 22 </div> 23 `; 24 25 add_task(async function () { 26 await addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI1)); 27 28 startTelemetry(); 29 30 const { inspector } = await openLayoutView(); 31 const { store } = inspector; 32 33 info("Navigate to TEST_URI2"); 34 35 const onGridListUpdate = waitUntilState( 36 store, 37 state => state.grids.length == 1 38 ); 39 await navigateTo( 40 "data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI2) 41 ); 42 await onGridListUpdate; 43 44 checkResults(); 45 }); 46 47 function checkResults() { 48 // Check for: 49 // - 1 CSS Grid Element 50 checkTelemetry( 51 "DEVTOOLS_NUMBER_OF_CSS_GRIDS_IN_A_PAGE", 52 "", 53 { 0: 0, 1: 1, 2: 0 }, 54 "array" 55 ); 56 }