summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/longtask-timing/longtask-promise.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/longtask-timing/longtask-promise.html')
-rw-r--r--testing/web-platform/tests/longtask-timing/longtask-promise.html36
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>