Skip to content
This repository was archived by the owner on Jul 28, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Set up tests
  • Loading branch information
MattiasBuelens committed Mar 12, 2021
commit 35cb5db1de17bbfb59b6beb66539c5a132214488
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "WIP support for WHATWG Stream in Node",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "node --expose-internals --expose_gc test/wpt/test.js"
},
"repository": {
"type": "git",
Expand All @@ -16,6 +16,9 @@
"url": "https://github.com/nodejs/whatwg-stream/issues"
},
"homepage": "https://github.com/nodejs/whatwg-stream#readme",
"engines": {
"node": ">= 15"
},
"dependencies": {
"web-streams-polyfill": "^3.0.2"
}
Expand Down
14 changes: 14 additions & 0 deletions test/wpt/status/streams.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"piping/pipe-through.any.js": {
"fail": "Node does not perform a brand check for AbortSignal.prototype.aborted"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test checks whether passing a "bad" AbortSignal (in particular ) causes pipeThrough() to throw. The polyfill implements this by trying to retrieve AbortSignal.prototype.aborted and checking that it does not throw. WebIDL requires this attribute to perform a brand check, so a compliant implementation should throw a TypeError when this getter is run on such a "bad" AbortSignal.

Unfortunately, Node's AbortSignal implementation does not throw an error when AbortSignal.prototype.aborted is run such a signal. Instead, it will return false and the polyfill will consider this to be a valid AbortSignal.

I'm not sure what we want to do here. Should we fix Node to perform a brand check in get aborted (i.e. throw an error if this[kAborted] does not exist)? Or should we change how the polyfill does this check (although I'm not sure how)?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand you correctly, I think the best course of action is to make an upstream change to Node.js core AbortSignal so that it aligns more with the spec.

Copy link
Author

@MattiasBuelens MattiasBuelens Mar 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On it! πŸ™‚

EDIT: Opened nodejs/node#37720.

},
"queuing-strategies-size-function-per-global.window.js": {
"skip": "test requires an <iframe>"
},
"readable-byte-streams/bad-buffers-and-views.any.js": {
"skip": "Node does not have detached ArrayBuffers"
},
"transferable/deserialize-error.window.js": {
"skip": "test requires an <iframe>"
}
}
30 changes: 30 additions & 0 deletions test/wpt/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

// Flags: --expose-internals --expose_gc
// Note:
// - The --expose-internals flag is specific to Node.js core's
// internal error system and is unnecessary for external users.
// - The --expose_gc flag is specific to the WPT stream tests

const { WPTRunner } = require('../common/wpt');
const runner = new WPTRunner('streams');
const whatwgStreamPath = require.resolve('../../');

runner.setFlags(['--expose-internals']);

runner.setInitScript(`
const { internalBinding } = require('internal/test/binding');
const { DOMException } = internalBinding('messaging');
global.DOMException = DOMException;

const whatwgStream = require(${JSON.stringify(whatwgStreamPath)});
for (const [name, value] of Object.entries(whatwgStream)) {
Object.defineProperty(global, name, {
value,
writable: true,
configurable: true
});
}
`);

runner.runJsTests();