Skip to content

Commit

Permalink
Resync requestIdleCallback WPT tests
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259917

Reviewed by Tim Nguyen.

Updated WPT tests for requestIdleCallback as of 0f0227f.

* LayoutTests/TestExpectations: Added flaky failure expectation on the tests that yield different result each time.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/basic.html:
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-idle-periods.html:
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-invoked.html:
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html:
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-after-expired-timer-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-after-expired-timer.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/resources/ric-utils.js: Added.
(getDeadlineForNextIdleCallback):
(getRICRetryCount):
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/resources/w3c-import.log:
* LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/w3c-import.log:
* LayoutTests/tests-options.json:

Canonical link: https://commits.webkit.org/266678@main
  • Loading branch information
rniwa committed Aug 8, 2023
1 parent 0055009 commit d9b63e8
Show file tree
Hide file tree
Showing 18 changed files with 208 additions and 2 deletions.
4 changes: 4 additions & 0 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -6205,6 +6205,10 @@ imported/w3c/web-platform-tests/pointerlock/mouse_buttons_back_forward.html [ Sk
imported/w3c/web-platform-tests/requestidlecallback/callback-idle-periods.html [ Skip ]
imported/w3c/web-platform-tests/requestidlecallback/callback-multiple-calls.html [ Skip ]
imported/w3c/web-platform-tests/requestidlecallback/callback-xhr-sync.html [ Skip ]
imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic.html [ Pass Failure ]
imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF.html [ Pass Failure ]
imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic.html [ Pass Failure ]
imported/w3c/web-platform-tests/requestidlecallback/deadline-max.html [ Pass Failure ]
imported/w3c/web-platform-tests/resize-observer/observe.html [ Skip ]
imported/w3c/web-platform-tests/resize-observer/svg.html [ Skip ]
imported/w3c/web-platform-tests/resource-timing/entry-attributes.html [ Skip ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
assert_equals(typeof window.requestIdleCallback(function() {}), "number");
}, "window.requestIdleCallback() returns a number");

// The cancelIdleCallback method MUST return void
// The cancelIdleCallback method MUST return undefined
test(function() {
assert_equals(typeof window.cancelIdleCallback(1), "undefined");
}, "window.cancelIdleCallback() returns undefined");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<title>window.requestIdleCallback callback behavior during idle periods.</title>
<meta name="timeout" content="long">
<link rel="author" title="Ross McIlroy" href="mailto:rmcilroy@chromium.org" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -15,7 +16,7 @@
var remaining = deadline.timeRemaining();
var new_deadline = now + remaining;
if (previous_deadline != undefined) {
assert_true(new_deadline > previous_deadline, "A requestIdleCallback scheduled during an idle period should be called back with a deadline greater than that in the current idle period.");
assert_true(new_deadline >= previous_deadline, "A requestIdleCallback scheduled during an idle period should be called back with a deadline greater than or equal to that in the current idle period.");
}

// Schedule a new requestIdleCallback.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>requestIdleCallback callback must be called eventually</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

FAIL The deadline after an expired timer must not be negative assert_false: expected false got true

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<meta charset=utf-8>
<title>The deadline after an expired timer must not be negative</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
async_test(function(t) {
setTimeout(() => {

requestIdleCallback(
t.step_func((deadline) => {
assert_false(deadline.didTimeout);
assert_greater_than_equal(deadline.timeRemaining(), 0);
t.done();
}),
{ timeout: 1000 }
);

}, 0);
});
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Test of requestIdleCallback deadline behavior

This test validates that deadlines returned for requestIdleCallback are less than 50ms.

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. It runs multiple times to expose potential failures.


FAIL Check that the deadline is less than 50ms. assert_less_than_equal: expected a number less than or equal to 50 but got 93

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Test of requestIdleCallback deadline behavior

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. It runs multiple times to expose potential failures.


FAIL Check that the deadline is changed if there is a new requestAnimationFrame from within requestIdleCallback. assert_less_than_equal: expected a number less than or equal to 16.666666666666668 but got 101

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<title>window.requestIdleCallback max idle period deadline (requestAnimationFrame).</title>
<meta name="timeout" content="long">
<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/ric-utils.js"></script>
<script>

promise_test(async () => {
for (let i = 0; i < getRICRetryCount(); ++i) {
const {before, after} = await new Promise(resolve => requestIdleCallback(async deadline => {
const before = deadline.timeRemaining();
const animationFramePromise = new Promise(requestAnimationFrame);
const after = deadline.timeRemaining();

// Waiting till rAF is handled before the next iteration, to avoid residual callacks between iterations.
await animationFramePromise;
resolve({before, after})
}))

assert_less_than_equal(after, before)
assert_less_than_equal(after, getPendingRenderDeadlineCap())
}

}, 'Check that the deadline is changed if there is a new requestAnimationFrame from within requestIdleCallback.');
</script>
<h1>Test of requestIdleCallback deadline behavior</h1>
<p>The test can pass accidentally as idle deadlines have a maximum but they can always be shorter.
It runs multiple times to expose potential failures.</p>
<div id="log"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Test of requestIdleCallback deadline behavior

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. It runs multiple times to expose potential failures.


FAIL Check that the deadline is less than 16ms when there is a pending animation frame. assert_less_than_equal: expected a number less than or equal to 16.666666666666668 but got 115

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<title>window.requestIdleCallback max idle period deadline (requestAnimationFrame).</title>
<meta name="timeout" content="long">
<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/ric-utils.js"></script>
<script>

promise_test(async done => {
for (let i = 0; i < getRICRetryCount(); ++i) {
requestAnimationFrame(() => {})
assert_less_than_equal(await getDeadlineForNextIdleCallback(), getPendingRenderDeadlineCap())
}

}, 'Check that the deadline is less than 16ms when there is a pending animation frame.');
</script>
<h1>Test of requestIdleCallback deadline behavior</h1>
<p>The test can pass accidentally as idle deadlines have a maximum but they can always be shorter.
It runs multiple times to expose potential failures.</p>
<div id="log"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Test of requestIdleCallback deadline behavior

The test can pass accidentally as idle deadlines have a maximum but they can always be shorter. It runs multiple times to expose potential failures.


FAIL Check that the deadline is changed if there is a new timeout from within requestIdleCallback. assert_less_than_equal: expected a number less than or equal to 10 but got 95

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<title>window.requestIdleCallback max idle period deadline (dynamic timoeout).</title>
<meta name="timeout" content="long">
<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/ric-utils.js"></script>
<script>

promise_test(async () => {
for (let i = 0; i < getRICRetryCount(); ++i) {
for (const timeout of [10, 20, 30]) {
const {before, after} = await new Promise(resolve => requestIdleCallback(async deadline => {
const before = deadline.timeRemaining();
const timerPromise = new Promise(resolve => step_timeout(resolve, timeout));
const after = deadline.timeRemaining();
await timerPromise;
resolve({before, after})
}))

assert_less_than_equal(after, before)
assert_less_than_equal(after, timeout)
}
}

}, 'Check that the deadline is changed if there is a new timeout from within requestIdleCallback.');
</script>
<h1>Test of requestIdleCallback deadline behavior</h1>
<p>The test can pass accidentally as idle deadlines have a maximum but they can always be shorter.
It runs multiple times to expose potential failures.</p>
<div id="log"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html><!-- webkit-test-runner [ RequestIdleCallbackEnabled=true ] -->
<title>window.requestIdleCallback max idle period deadline.</title>
<meta name="timeout" content="long">
<link rel="author" title="Noam Rosenthal" href="mailto:noam@webkit.org" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/ric-utils.js"></script>
<script>

promise_test(async done => {
for (let i = 0; i < getRICRetryCount(); ++i)
assert_less_than_equal(await getDeadlineForNextIdleCallback(), 50)

}, 'Check that the deadline is less than 50ms.');
</script>
<h1>Test of requestIdleCallback deadline behavior</h1>
<p>This test validates that deadlines returned for requestIdleCallback are less than 50ms.</p>
<p>The test can pass accidentally as idle deadlines have a maximum but they can always be shorter.
It runs multiple times to expose potential failures.</p>
<div id="log"></div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function getDeadlineForNextIdleCallback() {
return new Promise(
resolve =>
requestIdleCallback(deadline => resolve(deadline.timeRemaining()))
);
}

function getPendingRenderDeadlineCap() {
return 1000 / 60;
}

function getRICRetryCount() {
return 10;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ None
------------------------------------------------------------------------
List of files:
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/resources/post_name_on_load.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/resources/ric-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ List of files:
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-multiple-calls.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-removed-frame.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-suspended.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeout-when-busy.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-timeout.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/callback-xhr-sync.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/cancel-invoked.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-after-expired-timer.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/deadline-max.html
/LayoutTests/imported/w3c/web-platform-tests/requestidlecallback/idlharness.window.js
21 changes: 21 additions & 0 deletions LayoutTests/tests-options.json
Original file line number Diff line number Diff line change
Expand Up @@ -5276,12 +5276,21 @@
"imported/w3c/web-platform-tests/quirks/unitless-length/no-quirks.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-idle-periods.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-iframe.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-invoked.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-suspended.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-timeRemaining-cross-realm-method.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/callback-timeout-when-busy.html": [
"slow"
],
Expand All @@ -5291,6 +5300,18 @@
"imported/w3c/web-platform-tests/requestidlecallback/callback-xhr-sync.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF-dynamic.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/deadline-max-rAF.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/deadline-max-timeout-dynamic.html": [
"slow"
],
"imported/w3c/web-platform-tests/requestidlecallback/deadline-max.html": [
"slow"
],
"imported/w3c/web-platform-tests/resource-timing/nested-context-navigations-embed.html": [
"slow"
],
Expand Down

0 comments on commit d9b63e8

Please sign in to comment.