browser_webconsole_telemetry_js_errors.js (1773B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Tests the DEVTOOLS_JAVASCRIPT_ERROR_DISPLAYED telemetry event. 5 6 "use strict"; 7 8 const TEST_URI = `data:text/html,<!DOCTYPE html><meta charset=utf8><script>document()</script>`; 9 10 add_task(async function () { 11 Services.fog.testResetFOG(); 12 startTelemetry(); 13 14 const hud = await openNewTabAndConsole(TEST_URI); 15 16 info( 17 "Check that the error message is logged in telemetry with the expected key" 18 ); 19 await waitFor(() => findErrorMessage(hud, "is not a function")); 20 checkErrorDisplayedTelemetry("JSMSG_NOT_FUNCTION", 1); 21 22 await reloadBrowser(); 23 24 info("Reloading the page (and having the same error) increments the sum"); 25 await waitFor(() => findErrorMessage(hud, "is not a function")); 26 checkErrorDisplayedTelemetry("JSMSG_NOT_FUNCTION", 2); 27 28 info( 29 "Evaluating an expression resulting in the same error increments the sum" 30 ); 31 await executeAndWaitForErrorMessage( 32 hud, 33 "window()", 34 "window is not a function" 35 ); 36 checkErrorDisplayedTelemetry("JSMSG_NOT_FUNCTION", 3); 37 38 info( 39 "Evaluating an expression resulting in another error is logged in telemetry" 40 ); 41 await executeAndWaitForErrorMessage( 42 hud, 43 `"a".repeat(-1)`, 44 "repeat count must be non-negative" 45 ); 46 checkErrorDisplayedTelemetry("JSMSG_NEGATIVE_REPETITION_COUNT", 1); 47 48 await executeAndWaitForErrorMessage( 49 hud, 50 `"b".repeat(-1)`, 51 "repeat count must be non-negative" 52 ); 53 checkErrorDisplayedTelemetry("JSMSG_NEGATIVE_REPETITION_COUNT", 2); 54 }); 55 56 function checkErrorDisplayedTelemetry(key, count) { 57 is( 58 Glean.devtoolsConsole.javascriptErrorDisplayed[key].testGetValue(), 59 count, 60 `recorded ${key} ${count} times` 61 ); 62 }