Skip to content

Commit 33b5242

Browse files
joyeecheungrvagg
authored andcommitted
test: use Worker scope in WPT
Previously, we use the Window scope by default in our WPT test runner. When one of the test fails, the WPT harness would try to use document.getElementsByTagName() etc. to display the failure, which is not going to work for us. This patch switches the scope to DedicatedWorker and use our Worker implementation as a global - this does not test the Worker implementation per se, just tells the WPT harness to pass the results back to us via the callbacks we installed and not try to access a document. We may still need to use a Window scope when we try to run .window.js tests in the future, but for now we only run .any.js tests so it's fine to use a worker scope by default. PR-URL: #24410 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent f5e9bb1 commit 33b5242

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

test/common/wpt.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ class WPTRunner {
280280
sandbox.self = sandbox;
281281
// TODO(joyeecheung): we are not a window - work with the upstream to
282282
// add a new scope for us.
283-
sandbox.document = {}; // Pretend we are Window
283+
284+
const { Worker } = require('worker_threads');
285+
sandbox.DedicatedWorker = Worker; // Pretend we are a Worker
284286
return context;
285287
}
286288

test/wpt/test-whatwg-console.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
// Flags: --expose-internals
3+
// Flags: --expose-internals --experimental-worker
44

55
require('../common');
66
const { WPTRunner } = require('../common/wpt');

test/wpt/test-whatwg-url.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
// Flags: --expose-internals
3+
// Flags: --expose-internals --experimental-worker
44

55
require('../common');
66
const { WPTRunner } = require('../common/wpt');

0 commit comments

Comments
 (0)