From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../tests/browser/browser_date_telemetry.js | 70 ---------------------- 1 file changed, 70 deletions(-) delete mode 100644 js/xpconnect/tests/browser/browser_date_telemetry.js (limited to 'js/xpconnect/tests/browser/browser_date_telemetry.js') diff --git a/js/xpconnect/tests/browser/browser_date_telemetry.js b/js/xpconnect/tests/browser/browser_date_telemetry.js deleted file mode 100644 index b9c653db53..0000000000 --- a/js/xpconnect/tests/browser/browser_date_telemetry.js +++ /dev/null @@ -1,70 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - */ - -const triggers = [ - "Sep 26 Tues 1995", - "Sep 26 1995 Tues", - "Sep 26 1995 Tues 09:30", - "Sep 26 1995 09:Tues:30", - "Sep 26 1995 09:30 Tues GMT", - "Sep 26 1995 09:30 GMT Tues", - - "26 Tues Sep 1995", - "26 Sep Tues 1995", - "26 Sep 1995 Tues", - - "1995-09-26 Tues", - - // Multiple occurences should only trigger 1 counter - "Sep 26 Tues 1995 Tues", -]; -const nonTriggers = [ - "Sep 26 1995", - "Tues Sep 26 1995", - "Sep Tues 26 1995", - - // Invalid format shouldn't trigger the counter - "Sep 26 Tues 1995 foo", -]; - -function getCount() { - return Glean.useCounterPage.jsLateWeekday.testGetValue() ?? 0; -} - -/** - * Opens and closes a browser tab with minimal JS code which parses - * the given Date format. - */ -async function parseFormat(format, call = "new Date") { - let newTab = await BrowserTestUtils.openNewForegroundTab( - gBrowser, - `data:text/html;charset=utf-8,` - ); - BrowserTestUtils.removeTab(newTab); -} - -add_task(async function test_date_telemetry() { - let sum = getCount(); - - // waitForCondition cannot be used to test if nothing has changed, - // so these tests aren't as reliable as the ones in the next loop. - // If you encounter an inexplicable failure in any of these tests, - // debug by adding a delay to the end of the parseFormat function. - for (const format of nonTriggers) { - await parseFormat(format); - const count = getCount(); - is(count, sum, `${format} should not trigger telemetry`); - sum = count; - } - - for (const [i, format] of triggers.entries()) { - // Alternate between Date constructor and Date.parse - await parseFormat(format, ["new Date", "Date.parse"][i % 2]); - await BrowserTestUtils.waitForCondition(() => getCount() > sum); - const count = getCount(); - is(count, sum + 1, `${format} should trigger telemetry`); - sum = count; - } -}); -- cgit v1.2.3