diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/longtask-timing/longtask-promise.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/longtask-timing/longtask-promise.html')
-rw-r--r-- | testing/web-platform/tests/longtask-timing/longtask-promise.html | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/testing/web-platform/tests/longtask-timing/longtask-promise.html b/testing/web-platform/tests/longtask-timing/longtask-promise.html new file mode 100644 index 0000000000..762511524b --- /dev/null +++ b/testing/web-platform/tests/longtask-timing/longtask-promise.html @@ -0,0 +1,36 @@ +<!DOCTYPE HTML> +<meta charset=utf-8> +<title>LongTask Timing: Promise resolvers</title> +<body> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="resources/utils.js"></script> + +<h1>Long Task: promise resolvers</h1> +<script> + function test_promise_long_task(name, promise) { + promise_test(async t => { + assert_implements(window.PerformanceLongTaskTiming, 'Longtasks are not supported.'); + const longTaskPromise = new Promise(resolve => { + const observer = new PerformanceObserver(t.step_func(entryList => { + observer.disconnect(); + resolve(entryList.getEntries()); + })); + observer.observe({entryTypes: ['longtask']}); + }); + + await promise().catch(() => {}); + busyWait(); + const entries = await longTaskPromise; + assert_greater_than_equal(entries.length, 1); + }, `Performance longtask entries after a promise: ${name}`); + } + + test_promise_long_task("successful fetch", () => fetch("/common/dummy.xml")); + test_promise_long_task("Response.text()", () => + fetch("/common/dummy.xml").then(r => r.text())); + test_promise_long_task("rejected fetch", () => fetch("/common/non-existent.xml")); + test_promise_long_task("JSON error", () => fetch("/common/dummy.xml").then(r => r.json())); +</script> +</body> |