-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable WebIDL harness tests for reference implementation #1044
Comments
The good news: I already managed to get the tests to run locally, and I already found some missing things and broken things in the tests:
Now, I'd like to clean up and upstream my local patches. But first, I'd like your input on my suggested approach before I start making more pull requests. 😁 In essence, there are two things missing to get the tests to run:
For (1), wpt-runner would need to either include its own copy of these files, or would need to know where to find them. The first option seems like a bad idea, since we'd have to regular make new releases just to stay up-to-date with WPT. For the second option, we could add an option where the user can define a list of URLs and file paths that the runner needs to serve. Then, the streams spec would pass in the URLs and paths of the WebIDL harness files: const failures = await wptRunner(testsPath, {
rootURL: 'streams/',
server: {
// map of URL to file path
"/resources/idlharness.js": path.resolve(__dirname, "web-platform-tests/resources/idlharness.js"),
"/resources/WebIDLParser.js": path.resolve(__dirname, "web-platform-tests/resources/webidl2/lib/webidl2.js")
},
// ...
}); For (2), unfortunately const readFileAsync = promisify(fs.readFile);
const wptPath = path.resolve(__dirname, 'web-platform-tests');
const failures = await wptRunner(testsPath, {
// ...
setup(window) {
window.queueMicrotask = queueMicrotask;
window.fetch = async function (url) {
const filePath = path.join(wptPath, url);
if (!filePath.startsWith(wptPath)) {
throw new TypeError('Invalid URL');
}
return {
ok: true,
async text() {
return await readFileAsync(filePath, { encoding: 'utf8' });
}
};
};
window.eval(bundledJS);
},
} And that's it: with those things in place, plus the fixes to the web platform tests themselves, all IDL tests run smoothly. So, what do you think? 🙂 |
Ah, this is excellent; thank you so much for working on this! For (1), my concern is that (That also might be a good time to change the path configuration in general; I'm not so happy about the "mount a subpath" behavior.) For (2), I agree a fake fetch is the way to go, in pretty much exactly the way you've outlined. |
Right, I forgot there is a
+1 to both suggestions. But at least for now, I'll just copy the files. 🙂 |
As part of #1035, we added WebIDL harness tests to the web platform tests. However, we currently skip them for the reference implementation because they do not work with
wpt-runner
. This means that bugs in the WebIDL types (or in the WebIDL tests themselves) would only be uncovered when a browser runs the tests against their implementation (which happens much later). And even then, it would not be clear if the browser or the reference implementation got it wrong...I would like to see the reference implementations run (and pass) the IDL tests, so we can catch bugs in the specification or the tests before browsers start implementing.
The text was updated successfully, but these errors were encountered: