browser_toolbox_telemetry_activate_splitconsole.js (3061B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const URL = 7 "data:text/html;charset=utf8,browser_toolbox_telemetry_activate_splitconsole.js"; 8 const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS; 9 const DATA = [ 10 { 11 timestamp: null, 12 category: "devtools.main", 13 method: "activate", 14 object: "split_console", 15 value: null, 16 extra: { 17 host: "bottom", 18 width: "1300", 19 }, 20 }, 21 { 22 timestamp: null, 23 category: "devtools.main", 24 method: "deactivate", 25 object: "split_console", 26 value: null, 27 extra: { 28 host: "bottom", 29 width: "1300", 30 }, 31 }, 32 { 33 timestamp: null, 34 category: "devtools.main", 35 method: "activate", 36 object: "split_console", 37 value: null, 38 extra: { 39 host: "bottom", 40 width: "1300", 41 }, 42 }, 43 { 44 timestamp: null, 45 category: "devtools.main", 46 method: "deactivate", 47 object: "split_console", 48 value: null, 49 extra: { 50 host: "bottom", 51 width: "1300", 52 }, 53 }, 54 ]; 55 56 add_task(async function () { 57 // See Bug 1500141: this test frequently fails on beta because some highlighter 58 // requests made by the BoxModel component in the layout view come back when the 59 // connection between the client and the server has been destroyed. We are forcing 60 // the computed view here to avoid the failures but ideally we should have an event 61 // or a promise on the inspector we can wait for to be sure the initialization is over. 62 // Logged Bug 1500918 to investigate this. 63 await pushPref("devtools.inspector.activeSidebar", "computedview"); 64 65 // Let's reset the counts. 66 Services.telemetry.clearEvents(); 67 68 // Ensure no events have been logged 69 const snapshot = Services.telemetry.snapshotEvents(ALL_CHANNELS, true); 70 ok(!snapshot.parent, "No events have been logged for the main process"); 71 72 const tab = await addTab(URL); 73 const toolbox = await gDevTools.showToolboxForTab(tab, { 74 toolId: "inspector", 75 }); 76 77 await toolbox.openSplitConsole(); 78 await toolbox.closeSplitConsole(); 79 await toolbox.openSplitConsole(); 80 await toolbox.closeSplitConsole(); 81 82 await checkResults(); 83 }); 84 85 async function checkResults() { 86 const snapshot = Services.telemetry.snapshotEvents(ALL_CHANNELS, true); 87 const events = snapshot.parent.filter( 88 event => 89 event[1] === "devtools.main" && 90 (event[2] === "activate" || event[2] === "deactivate") 91 ); 92 93 for (const i in DATA) { 94 const [timestamp, category, method, object, value, extra] = events[i]; 95 const expected = DATA[i]; 96 97 // ignore timestamp 98 Assert.greater(timestamp, 0, "timestamp is greater than 0"); 99 is(category, expected.category, "category is correct"); 100 is(method, expected.method, "method is correct"); 101 is(object, expected.object, "object is correct"); 102 is(value, expected.value, "value is correct"); 103 104 // extras 105 is(extra.host, expected.extra.host, "host is correct"); 106 Assert.greater(Number(extra.width), 0, "width is greater than 0"); 107 } 108 }