Skip to content

Commit

Permalink
test: use Worker scope in WPT
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
joyeecheung authored and targos committed Nov 21, 2018
1 parent 5c450cd commit 9b34457
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ class WPTRunner {
sandbox.self = sandbox;
// TODO(joyeecheung): we are not a window - work with the upstream to
// add a new scope for us.
sandbox.document = {}; // Pretend we are Window

const { Worker } = require('worker_threads');
sandbox.DedicatedWorker = Worker; // Pretend we are a Worker
return context;
}

Expand Down
2 changes: 1 addition & 1 deletion test/wpt/test-whatwg-console.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Flags: --expose-internals
// Flags: --expose-internals --experimental-worker

require('../common');
const { WPTRunner } = require('../common/wpt');
Expand Down
2 changes: 1 addition & 1 deletion test/wpt/test-whatwg-url.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

// Flags: --expose-internals
// Flags: --expose-internals --experimental-worker

require('../common');
const { WPTRunner } = require('../common/wpt');
Expand Down

0 comments on commit 9b34457

Please sign in to comment.