summaryrefslogtreecommitdiff
path: root/test/common/wpt.js
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-11-17 05:30:06 +0800
committerRich Trott <rtrott@gmail.com>2018-11-20 15:27:38 -0800
commit2742f3869a540b01ed51ca91075af9215c13bd54 (patch)
tree684cb8f6c37eb168f77ab0a8f0bc0f9b9ec965a5 /test/common/wpt.js
parent566a694bbc67219d8765921c9b7d494b8a18a50c (diff)
downloadandroid-node-v8-2742f3869a540b01ed51ca91075af9215c13bd54.tar.gz
android-node-v8-2742f3869a540b01ed51ca91075af9215c13bd54.tar.bz2
android-node-v8-2742f3869a540b01ed51ca91075af9215c13bd54.zip
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: https://github.com/nodejs/node/pull/24410 Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'test/common/wpt.js')
-rw-r--r--test/common/wpt.js4
1 files changed, 3 insertions, 1 deletions
diff --git a/test/common/wpt.js b/test/common/wpt.js
index 59dbe26d2a..4f2f39c8e5 100644
--- a/test/common/wpt.js
+++ b/test/common/wpt.js
@@ -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;
}