Skip to content

Commit

Permalink
test: pull html/webappapis/timers WPT
Browse files Browse the repository at this point in the history
Using

```
git node wpt html/webappapis/timers
```

PR-URL: #25618
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and addaleax committed Feb 1, 2019
1 parent 25c19eb commit 5792208
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Last update:
- resources: https://github.com/web-platform-tests/wpt/tree/679a364421/resources
- interfaces: https://github.com/web-platform-tests/wpt/tree/712c9f275e/interfaces
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/0c3bed38df/html/webappapis/microtask-queuing
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/ddfe9c089b/html/webappapis/timers

[Web Platform Tests]: https://github.com/web-platform-tests/wpt
[`git node wpt`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt
23 changes: 23 additions & 0 deletions test/fixtures/wpt/html/webappapis/timers/evil-spec-example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!doctype html>
<title>Interaction of setTimeout and WebIDL</title>
<link rel="author" title="Ian Hickson" href="mailto:[email protected]">
<link rel="author" title="Ms2ger" href="mailto:[email protected]">
<link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-windowtimers-settimeout">
<link rel="help" href="https://heycam.github.io/webidl/#es-operations">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
var t = async_test()
function finishTest() {
assert_equals(log, "ONE TWO ")
t.done()
}
var log = '';
function logger(s) { log += s + ' '; }

setTimeout({ toString: function () {
setTimeout("logger('ONE')", 100);
return "logger('TWO'); t.step(finishTest)";
} }, 100);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function timeout_trampoline(t, timeout, message) {
t.step_timeout(function() {
// Yield in case we managed to be called before the second interval callback.
t.step_timeout(function() {
assert_unreached(message);
}, timeout);
}, timeout);
}

async_test(function(t) {
let ctr = 0;
let h = setInterval(t.step_func(function() {
if (++ctr == 2) {
clearInterval(h);
t.done();
return;
}
}) /* no interval */);

timeout_trampoline(t, 100, "Expected setInterval callback to be called two times");
}, "Calling setInterval with no interval should be the same as if called with 0 interval");

async_test(function(t) {
let ctr = 0;
let h = setInterval(t.step_func(function() {
if (++ctr == 2) {
clearInterval(h);
t.done();
return;
}
}), undefined);

timeout_trampoline(t, 100, "Expected setInterval callback to be called two times");
}, "Calling setInterval with undefined interval should be the same as if called with 0 interval");
17 changes: 17 additions & 0 deletions test/fixtures/wpt/html/webappapis/timers/negative-setinterval.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<title>Negative timeout in setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var i = 0;
var interval;
function next() {
i++;
if (i === 20) {
clearInterval(interval);
done();
}
}
setTimeout(assert_unreached, 1000);
interval = setInterval(next, -100);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<title>Negative timeout in setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setTimeout(done, -100);
setTimeout(assert_unreached, 10);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<title>Type long timeout for setInterval</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var interval;
function next() {
clearInterval(interval);
done();
}
interval = setInterval(next, Math.pow(2, 32));
setTimeout(assert_unreached, 100);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!doctype html>
<title>Type long timeout for setTimeout</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setTimeout(done, Math.pow(2, 32));
setTimeout(assert_unreached, 100);
</script>
4 changes: 4 additions & 0 deletions test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,9 @@
"html/webappapis/microtask-queuing": {
"commit": "0c3bed38df6d9dcd1441873728fb5c1bb59c92df",
"path": "html/webappapis/microtask-queuing"
},
"html/webappapis/timers": {
"commit": "ddfe9c089bab565a9d3aa37bdef63d8012c1a94c",
"path": "html/webappapis/timers"
}
}

0 comments on commit 5792208

Please sign in to comment.