diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /js/xpconnect/tests/browser | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/xpconnect/tests/browser')
-rw-r--r-- | js/xpconnect/tests/browser/browser.toml | 3 | ||||
-rw-r--r-- | js/xpconnect/tests/browser/browser_date_telemetry.js | 70 | ||||
-rw-r--r-- | js/xpconnect/tests/browser/browser_dead_object.js | 11 | ||||
-rw-r--r-- | js/xpconnect/tests/browser/browser_exception_leak.js | 11 |
4 files changed, 8 insertions, 87 deletions
diff --git a/js/xpconnect/tests/browser/browser.toml b/js/xpconnect/tests/browser/browser.toml index c7c72c71e7..59b8e08657 100644 --- a/js/xpconnect/tests/browser/browser.toml +++ b/js/xpconnect/tests/browser/browser.toml @@ -9,8 +9,6 @@ support-files = [ "browser_promise_userInteractionHandling.html" ] -["browser_date_telemetry.js"] - ["browser_dead_object.js"] ["browser_exception_leak.js"] @@ -28,4 +26,3 @@ support-files = [ ["browser_weak_xpcwjs.js"] ["browser_weak_xpcwn.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,<script>${call}("${format}")</script>` - ); - 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; - } -}); diff --git a/js/xpconnect/tests/browser/browser_dead_object.js b/js/xpconnect/tests/browser/browser_dead_object.js index b8b2dd0688..a79b46bc36 100644 --- a/js/xpconnect/tests/browser/browser_dead_object.js +++ b/js/xpconnect/tests/browser/browser_dead_object.js @@ -19,13 +19,10 @@ add_task(async function test() { let { TestUtils } = ChromeUtils.importESModule( "resource://testing-common/TestUtils.sys.mjs" ); - let promise = TestUtils.topicObserved( - "inner-window-nuked", - (subject, data) => { - let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; - return id == args.innerWindowId; - } - ); + let promise = TestUtils.topicObserved("inner-window-nuked", subject => { + let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; + return id == args.innerWindowId; + }); content.location = "http://mochi.test:8888/"; await promise; return Cu.isDeadWrapper(doc); diff --git a/js/xpconnect/tests/browser/browser_exception_leak.js b/js/xpconnect/tests/browser/browser_exception_leak.js index be860355bc..80358758ec 100644 --- a/js/xpconnect/tests/browser/browser_exception_leak.js +++ b/js/xpconnect/tests/browser/browser_exception_leak.js @@ -40,13 +40,10 @@ add_task(async function test() { // eslint-disable-next-line no-unused-vars let doc = content.document; - let promise = TestUtils.topicObserved( - "inner-window-nuked", - (subject, data) => { - let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; - return id == args.innerWindowId; - } - ); + let promise = TestUtils.topicObserved("inner-window-nuked", subject => { + let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; + return id == args.innerWindowId; + }); content.location = "http://mochi.test:8888/"; await promise; |