From c0a06440834ba11d63667eaad32b78452ae3034f Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sat, 18 Sep 2021 00:55:34 +0200 Subject: [PATCH 01/29] Move WPT script to test/wpt-node --- package.json | 2 +- test/{run-web-platform-tests.js => wpt/node/run.js} | 6 +++--- test/{wpt-util => wpt/shared}/filtering-reporter.js | 0 3 files changed, 4 insertions(+), 4 deletions(-) rename test/{run-web-platform-tests.js => wpt/node/run.js} (97%) rename test/{wpt-util => wpt/shared}/filtering-reporter.js (100%) diff --git a/package.json b/package.json index 8b962d0..edf2bb0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ }, "scripts": { "test": "npm run test:types && npm run test:unit && npm run test:wpt && npm run test:bundlers", - "test:wpt": "node --expose_gc ./test/run-web-platform-tests.js", + "test:wpt": "node --expose_gc ./test/wpt/node/run.js", "test:bundlers": "npm run test:rollup && npm run test:webpack", "test:rollup": "cd test/rollup && npm ci && npm test", "test:webpack": "cd test/webpack && npm ci && npm test", diff --git a/test/run-web-platform-tests.js b/test/wpt/node/run.js similarity index 97% rename from test/run-web-platform-tests.js rename to test/wpt/node/run.js index c7a4362..b162810 100644 --- a/test/run-web-platform-tests.js +++ b/test/wpt/node/run.js @@ -8,7 +8,7 @@ const { promisify } = require('util'); const micromatch = require('micromatch'); const wptRunner = require('wpt-runner'); const consoleReporter = require('wpt-runner/lib/console-reporter.js'); -const { FilteringReporter } = require('./wpt-util/filtering-reporter.js'); +const { FilteringReporter } = require('../shared/filtering-reporter.js'); const allSettled = require('@ungap/promise-all-settled'); const readFileAsync = promisify(fs.readFile); @@ -128,8 +128,8 @@ async function main() { } async function runTests(entryFile, { excludedTests = [], ignoredFailures = {} } = {}) { - const entryPath = path.resolve(__dirname, `../dist/${entryFile}`); - const wptPath = path.resolve(__dirname, 'web-platform-tests'); + const entryPath = path.resolve(__dirname, `../../../dist/${entryFile}`); + const wptPath = path.resolve(__dirname, '../../web-platform-tests'); const testsPath = path.resolve(wptPath, 'streams'); const includedTests = process.argv.length >= 3 ? process.argv.slice(2) : ['**/*.html']; diff --git a/test/wpt-util/filtering-reporter.js b/test/wpt/shared/filtering-reporter.js similarity index 100% rename from test/wpt-util/filtering-reporter.js rename to test/wpt/shared/filtering-reporter.js From 30aebdaf796521712dd26c995d8b09ec8861944e Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sat, 18 Sep 2021 00:58:05 +0200 Subject: [PATCH 02/29] Copy server setup from wpt-runner --- test/wpt/browser/server.js | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 test/wpt/browser/server.js diff --git a/test/wpt/browser/server.js b/test/wpt/browser/server.js new file mode 100644 index 0000000..3a5d319 --- /dev/null +++ b/test/wpt/browser/server.js @@ -0,0 +1,95 @@ +const http = require('http'); +const path = require('path'); +const fs = require('fs'); +const { URL } = require('url'); +const st = require('st'); +const { AnyHtmlHandler, WindowHandler } = require('wpt-runner/lib/internal/serve.js'); + +const testharnessPath = path.resolve(__dirname, '../testharness/testharness.js'); +const idlharnessPath = path.resolve(__dirname, '../testharness/idlharness.js'); +const webidl2jsPath = path.resolve(__dirname, '../testharness/webidl2/lib/webidl2.js'); +const testdriverDummyPath = path.resolve(__dirname, './testdriver-dummy.js'); + +function setupServer(testsPath, { + rootURL = '/' +}) { + if (!rootURL.startsWith('/')) { + rootURL = '/' + rootURL; + } + if (!rootURL.endsWith('/')) { + rootURL += '/'; + } + + const staticFileServer = st({ path: testsPath, url: rootURL, passthrough: true }); + + const routes = [ + ['.window.html', new WindowHandler(testsPath, rootURL)], + ['.any.html', new AnyHtmlHandler(testsPath, rootURL)] + ]; + + return http.createServer((req, res) => { + staticFileServer(req, res, () => { + const { pathname } = new URL(req.url, `http://${req.headers.host}`); + + for (const [pathNameSuffix, handler] of routes) { + if (pathname.endsWith(pathNameSuffix)) { + handler.handleRequest(req, res); + return; + } + } + + switch (pathname) { + case '/resources/testharness.js': { + fs.createReadStream(testharnessPath).pipe(res); + break; + } + + case '/resources/idlharness.js': { + fs.createReadStream(idlharnessPath).pipe(res); + break; + } + + case '/resources/WebIDLParser.js': { + fs.createReadStream(webidl2jsPath).pipe(res); + break; + } + + case '/service-workers/service-worker/resources/test-helpers.sub.js': { + res.end('window.service_worker_test = () => {};'); + break; + } + + case '/resources/testharnessreport.js': { + res.end('window.__setupJSDOMReporter();'); + break; + } + + case '/streams/resources/test-initializer.js': { + res.end('window.worker_test = () => {};'); + break; + } + + case '/resources/testharness.css': { + res.end(''); + break; + } + + case '/resources/testdriver.js': { + fs.createReadStream(testdriverDummyPath).pipe(res); + break; + } + + case '/resources/testdriver-vendor.js': { + res.end(''); + break; + } + + default: { + throw new Error(`Unexpected URL: ${req.url}`); + } + } + }); + }).listen(); +} + +exports.setupServer = setupServer; From 8f80fd01e2966fd25ce4d918324f570ff42f11ea Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Sat, 18 Sep 2021 01:04:27 +0200 Subject: [PATCH 03/29] Fix paths --- test/wpt/browser/server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/wpt/browser/server.js b/test/wpt/browser/server.js index 3a5d319..b0d6482 100644 --- a/test/wpt/browser/server.js +++ b/test/wpt/browser/server.js @@ -5,10 +5,10 @@ const { URL } = require('url'); const st = require('st'); const { AnyHtmlHandler, WindowHandler } = require('wpt-runner/lib/internal/serve.js'); -const testharnessPath = path.resolve(__dirname, '../testharness/testharness.js'); -const idlharnessPath = path.resolve(__dirname, '../testharness/idlharness.js'); -const webidl2jsPath = path.resolve(__dirname, '../testharness/webidl2/lib/webidl2.js'); -const testdriverDummyPath = path.resolve(__dirname, './testdriver-dummy.js'); +const testharnessPath = path.resolve(__dirname, '../../web-platform-tests/resources/testharness.js'); +const idlharnessPath = path.resolve(__dirname, '../../web-platform-tests/resources/idlharness.js'); +const webidl2jsPath = path.resolve(__dirname, '../../web-platform-tests/resources/webidl2/lib/webidl2.js'); +const testdriverDummyPath = require.resolve('wpt-runner/lib/testdriver-dummy.js'); function setupServer(testsPath, { rootURL = '/' From 9e04927f512f8f040adc5c1a274ad001778a189b Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Mon, 27 Sep 2021 22:49:07 +0200 Subject: [PATCH 04/29] Move exclusions to separate file --- test/wpt/node/run.js | 90 +++++------------------------------ test/wpt/shared/exclusions.js | 83 ++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 78 deletions(-) create mode 100644 test/wpt/shared/exclusions.js diff --git a/test/wpt/node/run.js b/test/wpt/node/run.js index b162810..e38fe06 100644 --- a/test/wpt/node/run.js +++ b/test/wpt/node/run.js @@ -10,6 +10,14 @@ const wptRunner = require('wpt-runner'); const consoleReporter = require('wpt-runner/lib/console-reporter.js'); const { FilteringReporter } = require('../shared/filtering-reporter.js'); const allSettled = require('@ungap/promise-all-settled'); +const { + excludedTestsNonES2018, + excludedTestsBase, + ignoredFailuresBase, + ignoredFailuresMinified, + ignoredFailuresES5, + mergeIgnoredFailures +} = require('../shared/exclusions'); const readFileAsync = promisify(fs.readFile); const queueMicrotask = global.queueMicrotask || (fn => Promise.resolve().then(fn)); @@ -32,85 +40,19 @@ main().catch(e => { }); async function main() { - const supportsES2018 = runtimeSupportsAsyncGenerators(); - const excludedTests = [ - // We cannot polyfill TransferArrayBuffer yet, so disable tests for detached array buffers - // See https://github.com/MattiasBuelens/web-streams-polyfill/issues/3 - 'readable-byte-streams/bad-buffers-and-views.any.html', - 'readable-byte-streams/enqueue-with-detached-buffer.window.html', - 'readable-byte-streams/non-transferable-buffers.any.html', - // Disable tests for different size functions per realm, since they need a working