diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-15 03:35:49 +0000 |
commit | d8bbc7858622b6d9c278469aab701ca0b609cddf (patch) | |
tree | eff41dc61d9f714852212739e6b3738b82a2af87 /dom/power/tests | |
parent | Releasing progress-linux version 125.0.3-1~progress7.99u1. (diff) | |
download | firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip |
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/power/tests')
-rw-r--r-- | dom/power/tests/file_empty.html | 1 | ||||
-rw-r--r-- | dom/power/tests/mochitest.toml | 5 | ||||
-rw-r--r-- | dom/power/tests/test_wakelock_on_initial_about_blank.html | 49 |
3 files changed, 55 insertions, 0 deletions
diff --git a/dom/power/tests/file_empty.html b/dom/power/tests/file_empty.html new file mode 100644 index 0000000000..4f54ef40a6 --- /dev/null +++ b/dom/power/tests/file_empty.html @@ -0,0 +1 @@ +<h1>Example page</h1> diff --git a/dom/power/tests/mochitest.toml b/dom/power/tests/mochitest.toml index 0b57119a8a..47e10ee3cd 100644 --- a/dom/power/tests/mochitest.toml +++ b/dom/power/tests/mochitest.toml @@ -1,9 +1,14 @@ [DEFAULT] prefs = ["dom.screenwakelock.enabled=true"] scheme = "https" +support-files = [ + "file_empty.html", +] ["test_dynamic_pref_change.html"] fail-if = ["xorigin"] # cross-origin use requires permissions policy ["test_wakelock_default_permission.html"] fail-if = ["xorigin"] # cross-origin use requires permissions policy + +["test_wakelock_on_initial_about_blank.html"] diff --git a/dom/power/tests/test_wakelock_on_initial_about_blank.html b/dom/power/tests/test_wakelock_on_initial_about_blank.html new file mode 100644 index 0000000000..eefa6c6fb7 --- /dev/null +++ b/dom/power/tests/test_wakelock_on_initial_about_blank.html @@ -0,0 +1,49 @@ +<!DOCTYPE HTML> +<html> +<head> + <meta charset="utf-8"> + <title>Test requesting lock on the initial about:blank</title> + <link rel="help" href="https://bugzilla.mozilla.org/1882344"/> + <script src="/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> + <script> + + add_task(async function test() { + const iframe = document.createElement('iframe'); + iframe.src = "file_empty.html"; + document.documentElement.appendChild(iframe); + + // https://html.spec.whatwg.org/multipage/nav-history-apis.html#the-window-object:initialise-the-document-object + is(iframe.contentWindow.location.href, "about:blank", "Initial about:blank is loaded"); + + let lock; + try { + // request lock on initial about:blank + lock = await iframe.contentWindow.navigator.wakeLock.request(); + } catch (err) { + // This could happen if the initial about:blank document is inactive + // once the async code in .request runs. + ok(true, "request was rejected"); + return; + } + + if (iframe.contentWindow.location.href == "about:blank") { + await new Promise((res, _rej) => { iframe.onload = res; }); + } + isnot(iframe.contentWindow.location.href, "about:blank", "Target document is loaded"); + + is(lock.released, true, "lock was released by load of target doc"); + + // window and wakeLock object stayed the same, but document changed + await iframe.contentWindow.navigator.wakeLock.request(); + ok(true, "Was able to request lock on target document"); + }); + + </script> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"></div> +<pre id="test"></pre> +</body> +</html> |