forked from WebKit/WebKit-http
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequestidlecallback-in-page-cache.html
54 lines (45 loc) · 1.58 KB
/
requestidlecallback-in-page-cache.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
48
49
50
51
52
53
54
<!DOCTYPE html><!-- webkit-test-runner [ experimental:RequestIdleCallbackEnabled=true UsesBackForwardCache=true ] -->
<html>
<body>
<script src="../resources/js-test.js"></script>
<script>
description('This tests that when requestIdleCallback is not enabled, requestIdleCallback and IdleDeadline are not defined.');
jsTestIsAsync = true;
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
let isInitialLoad = true;
const logs = [];
if (window.testRunner)
setTimeout(() => testRunner.notifyDone(), 3000);
window.addEventListener("pageshow", function(event) {
if (isInitialLoad) {
isInitialLoad = false;
return;
}
if (window.testRunner)
setTimeout(() => testRunner.notifyDone(), 3000);
shouldBeTrue('event.persisted');
shouldBe('logs.length', '0');
iframe.contentWindow.requestIdleCallback(() => logs.push('B3'));
requestIdleCallback(() => logs.push('A4'));
requestIdleCallback(() => {
shouldBe('logs.length', '7');
shouldBeEqualToString('logs.join(", ")', 'A1, B1, A2, B2, A3, B3, A4');
finishJSTest();
});
});
window.addEventListener("pagehide", function(event) {
requestIdleCallback(() => logs.push('A1'));
iframe.contentWindow.requestIdleCallback(() => logs.push('B1'));
requestIdleCallback(() => logs.push('A2'));
iframe.contentWindow.requestIdleCallback(() => logs.push('B2'));
requestIdleCallback(() => logs.push('A3'));
});
onload = () => {
setTimeout(() => {
window.location = 'resources/page-cache-helper.html';
}, 0);
}
</script>
</body>
</html>