forked from WebKit/WebKit-http
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequestidlecallback-is-called.html
47 lines (38 loc) · 1.17 KB
/
requestidlecallback-is-called.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html><!-- webkit-test-runner [ experimental:RequestIdleCallbackEnabled=true ] -->
<html>
<body>
<script src="../resources/js-test.js"></script>
<script>
description('This tests that when requestIdleCallback is enabled, requestIdleCallback is eventaully called in the order.');
jsTestIsAsync = true;
requestIdleCallbackIsCalled = false;
const iframe = document.createElement('iframe');
const logs = [];
iframe.onload = () => {
requestIdleCallback(() => {
requestIdleCallbackIsCalled = true;
logs.push('1.A1');
});
iframe.contentWindow.requestIdleCallback(() => {
requestIdleCallbackIsCalled = true;
logs.push('2.B1');
});
iframe.contentWindow.requestIdleCallback(() => {
requestIdleCallbackIsCalled = true;
logs.push('3.B2');
});
requestIdleCallback(() => {
requestIdleCallbackIsCalled = true;
logs.push('4.A2');
});
}
document.body.appendChild(iframe);
setTimeout(() => {
shouldBeTrue('requestIdleCallbackIsCalled');
shouldBe('logs.length', '4');
shouldBeEqualToString('logs.join(", ")', '1.A1, 2.B1, 4.A2, 3.B2');
finishJSTest();
}, 200);
</script>
</body>
</html>