From e253472b32e2e0219379bc71e9f5b2c88e7f56f6 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 23 Jun 2020 23:42:19 +0200 Subject: [PATCH 1/2] Update WPT --- reference-implementation/web-platform-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference-implementation/web-platform-tests b/reference-implementation/web-platform-tests index 887350c2f..c5f9e7017 160000 --- a/reference-implementation/web-platform-tests +++ b/reference-implementation/web-platform-tests @@ -1 +1 @@ -Subproject commit 887350c2f46def5b01c4dd1f8d2eee35dfb9c5bb +Subproject commit c5f9e701753a034f99dda16d4716c465bed73e18 From 60bf8a0fef0ab91faa3b4592b4e1a74e636131bc Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 23 Jun 2020 23:45:59 +0200 Subject: [PATCH 2/2] Run idlharness tests on reference implementation * Update wpt-runner to version 3.1.0, which adds support for serving idlharness resources * Add a fetch() stub, so idlharness can load the WebIDL files --- reference-implementation/package.json | 2 +- .../run-web-platform-tests.js | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/reference-implementation/package.json b/reference-implementation/package.json index 563971428..12e516b4f 100644 --- a/reference-implementation/package.json +++ b/reference-implementation/package.json @@ -19,7 +19,7 @@ "nyc": "^15.0.1", "opener": "^1.5.1", "webidl2js": "^16.2.0", - "wpt-runner": "^3.0.1" + "wpt-runner": "^3.1.0" }, "nyc": { "include": [ diff --git a/reference-implementation/run-web-platform-tests.js b/reference-implementation/run-web-platform-tests.js index c8520118e..db71f40e2 100644 --- a/reference-implementation/run-web-platform-tests.js +++ b/reference-implementation/run-web-platform-tests.js @@ -3,10 +3,12 @@ /* eslint-disable no-console */ 'use strict'; const path = require('path'); +const fs = require('fs'); const { promisify } = require('util'); const browserify = require('browserify'); const wptRunner = require('wpt-runner'); const minimatch = require('minimatch'); +const readFileAsync = promisify(fs.readFile); // wpt-runner does not yet support unhandled rejection tracking a la // https://github.com/w3c/testharness.js/commit/7716e2581a86dfd9405a9c00547a7504f0c7fe94 @@ -27,7 +29,8 @@ main().catch(e => { async function main() { const entryPath = path.resolve(__dirname, 'lib/index.js'); - const testsPath = path.resolve(__dirname, 'web-platform-tests/streams'); + const wptPath = path.resolve(__dirname, 'web-platform-tests'); + const testsPath = path.resolve(wptPath, 'streams'); const filterGlobs = process.argv.length >= 3 ? process.argv.slice(2) : ['**/*.html']; const workerTestPattern = /\.(?:dedicated|shared|service)worker(?:\.https)?\.html$/; @@ -38,6 +41,18 @@ async function main() { rootURL: 'streams/', 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); }, filter(testPath) { @@ -46,11 +61,6 @@ async function main() { return false; } - // Ignore for now: wpt-runner doesn't handle the cross-folder dependencies well. - if (testPath === 'idlharness.any.html') { - return false; - } - return filterGlobs.some(glob => minimatch(testPath, glob)); } });