Skip to content

Commit

Permalink
test: port flaky wpt/html/webappapis/timers tests to test/sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Apr 21, 2023
1 parent 6675505 commit ac59ddc
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 129 deletions.
1 change: 0 additions & 1 deletion test/fixtures/wpt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Last update:
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
- interfaces: https://github.com/web-platform-tests/wpt/tree/df731dab88/interfaces
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/17ebc3aea0/performance-timeline
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
Expand Down

This file was deleted.

23 changes: 0 additions & 23 deletions test/fixtures/wpt/html/webappapis/timers/evil-spec-example.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

4 changes: 0 additions & 4 deletions test/fixtures/wpt/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@
"commit": "47d3fb280c9c632e684dee3b78ae1f4c5d5ba640",
"path": "html/webappapis/structured-clone"
},
"html/webappapis/timers": {
"commit": "5873f2d8f1f7bbb9c64689e52d04498614632906",
"path": "html/webappapis/timers"
},
"interfaces": {
"commit": "df731dab88a1a25c04eb7e6238c11dc28fda0801",
"path": "interfaces"
Expand Down
19 changes: 19 additions & 0 deletions test/sequential/test-timers-clearinterval-from-callback.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/clearinterval-from-callback.any.js

let wasPreviouslyCalled = false;

const handle = setInterval(() => {
if (!wasPreviouslyCalled) {
wasPreviouslyCalled = true;

clearInterval(handle);

setInterval(process.exit, 750);
} else {
common.mustNotCall()();
}
}, 500);
17 changes: 17 additions & 0 deletions test/sequential/test-timers-cleartimeout-clearinterval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/cleartimeout-cleartinterval.any.js

{
const handle = setTimeout(common.mustNotCall(), 0);
clearInterval(handle);
}

{
const handle = setInterval(common.mustNotCall(), 0);
clearTimeout(handle);
}

setTimeout(process.exit, 100);
34 changes: 34 additions & 0 deletions test/sequential/test-timers-missing-timeout-setinterval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/missing-timeout-setinterval.any.js

// Calling setInterval with no interval should be the same as if called with 0 interval
{
let ctr = 0;
let doneHandle;
// eslint-disable-next-line no-restricted-syntax
const handle = setInterval(() => {
if (++ctr === 2) {
clearInterval(handle);
clearTimeout(doneHandle);
}
}/* no interval */);

doneHandle = setTimeout(common.mustNotCall(), 100);
}

// Calling setInterval with undefined interval should be the same as if called with 0 interval
{
let ctr = 0;
let doneHandle;
const handle = setInterval(() => {
if (++ctr === 2) {
clearInterval(handle);
clearTimeout(doneHandle);
}
}, undefined);

doneHandle = setTimeout(common.mustNotCall(), 100);
}
17 changes: 17 additions & 0 deletions test/sequential/test-timers-negative-setinterval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/negative-setinterval.any.js

let i = 0;
let interval;
function next() {
i++;
if (i === 20) {
clearInterval(interval);
process.exit();
}
}
setTimeout(common.mustNotCall(), 1000);
interval = setInterval(next, -100);
8 changes: 8 additions & 0 deletions test/sequential/test-timers-negative-settimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/negative-settimeout.any.js

setTimeout(process.exit, -100);
setTimeout(common.mustNotCall(), 10);
8 changes: 8 additions & 0 deletions test/sequential/test-timers-type-long-setinterval.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/type-long-setinterval.any.js

setInterval(process.exit, Math.pow(2, 32));
setTimeout(common.mustNotCall(), 100);
8 changes: 8 additions & 0 deletions test/sequential/test-timers-type-long-settimeout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const common = require('../common');

// This is a port of https://github.com/web-platform-tests/wpt/blob/22ecfc9/html/webappapis/timers/type-long-settimeout.any.js

setTimeout(process.exit, Math.pow(2, 32));
setTimeout(common.mustNotCall(), 100);
5 changes: 0 additions & 5 deletions test/wpt/status/html/webappapis/timers.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/wpt/test-timers.js

This file was deleted.

0 comments on commit ac59ddc

Please sign in to comment.