browser_page_load_event_telemetry.js (1602B)
1 "use strict"; 2 3 const { TelemetryTestUtils } = ChromeUtils.importESModule( 4 "resource://testing-common/TelemetryTestUtils.sys.mjs" 5 ); 6 7 const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS; 8 9 add_task(async function () { 10 if (Services.prefs.getBoolPref("telemetry.fog.artifact_build", false)) { 11 Assert.ok(true, "Test skipped in artifact builds. See bug 1836686."); 12 return; 13 } 14 15 let tab = await BrowserTestUtils.openNewForegroundTab({ 16 gBrowser, 17 waitForLoad: true, 18 }); 19 20 let browser = tab.linkedBrowser; 21 22 // Reset event counts. 23 Services.telemetry.clearEvents(); 24 TelemetryTestUtils.assertNumberOfEvents(0); 25 26 // Check for pageload ping and pageload event 27 await GleanPings.pageload.testSubmission( 28 reason => { 29 Assert.equal(reason, "threshold"); 30 let record = Glean.perf.pageLoad.testGetValue(); 31 32 // Ensure the events in the pageload ping are reasonable. 33 record.forEach(entry => { 34 Assert.equal(entry.name, "page_load"); 35 Assert.greater(parseInt(entry.extra.load_time), 0); 36 Assert.ok( 37 entry.extra.using_webdriver, 38 "Webdriver field should be set to true." 39 ); 40 }); 41 }, 42 async () => { 43 // Perform page load 30 times to trigger the ping being sent 44 for (let i = 0; i < 30; i++) { 45 BrowserTestUtils.startLoadingURIString(browser, "https://example.com"); 46 await BrowserTestUtils.browserLoaded(browser); 47 } 48 }, 49 // The ping itself is submitted via idle dispatch, so we need to specify a 50 // timeout. 51 1000 52 ); 53 54 BrowserTestUtils.removeTab(tab); 55 });