Skip to content
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

test: cleanup WPT setup files, update WPT fixtures, update expectations #46753

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
55 changes: 20 additions & 35 deletions test/common/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ class StatusRuleSet {

// A specification of WPT test
class WPTTestSpec {

#content;

/**
* @param {string} mod name of the WPT module, e.g.
* 'html/webappapis/microtask-queuing'
Expand Down Expand Up @@ -298,7 +301,8 @@ class WPTTestSpec {
}

getContent() {
return fs.readFileSync(this.getAbsolutePath(), 'utf8');
this.#content ??= fs.readFileSync(this.getAbsolutePath(), 'utf8');
return this.#content;
}
}

Expand Down Expand Up @@ -355,7 +359,7 @@ class StatusLoader {
}

/**
* Grep for all .*.js file recursively in a directory.
* Grep for all .*.js file recursively in a directory, omitting helpers.
* @param {string} dir
*/
grep(dir) {
Expand All @@ -374,6 +378,7 @@ class StatusLoader {
result.push(filepath);
}
}
result = result.filter((filepath) => !filepath.endsWith('.helper.js'));
panva marked this conversation as resolved.
Show resolved Hide resolved
return result;
}

Expand Down Expand Up @@ -484,9 +489,7 @@ class WPTRunner {
pretendGlobalThisAs(name) {
switch (name) {
case 'Window': {
this.globalThisInitScripts.push(
`global.Window = Object.getPrototypeOf(globalThis).constructor;
self.GLOBAL.isWorker = () => false;`);
this.globalThisInitScripts.push('globalThis.Window = Object.getPrototypeOf(globalThis).constructor;');
this.loadLazyGlobals();
break;
}
Expand Down Expand Up @@ -526,39 +529,10 @@ class WPTRunner {
this.globalThisInitScripts.push(script);
}

brandCheckGlobalScopeAttribute(name) {
// TODO(legendecas): idlharness GlobalScope attribute receiver validation.
const script = `
const desc = Object.getOwnPropertyDescriptor(globalThis, '${name}');
function getter() {
// Mimic GlobalScope instance brand check.
if (this !== globalThis) {
throw new TypeError('Illegal invocation');
}
return desc.get();
}
Object.defineProperty(getter, 'name', { value: 'get ${name}' });

function setter(value) {
// Mimic GlobalScope instance brand check.
if (this !== globalThis) {
throw new TypeError('Illegal invocation');
}
desc.set(value);
}
Object.defineProperty(setter, 'name', { value: 'set ${name}' });

Object.defineProperty(globalThis, '${name}', {
get: getter,
set: setter,
});
`;
this.globalThisInitScripts.push(script);
}

// TODO(joyeecheung): work with the upstream to port more tests in .html
// to .js.
async runJsTests() {
this.pretendGlobalThisAs('Window');
let queue = [];

// If the tests are run as `node test/wpt/test-something.js subset.any.js`,
Expand Down Expand Up @@ -914,6 +888,17 @@ class WPTRunner {
continue;
}

if (filename.includes('tentative')) {
this.skip(filename, [ 'test makes assertions not yet required by any specification' ]);
continue;
}

const isServiceWorker = spec.getContent().includes('importScripts(');
if (isServiceWorker) {
this.skip(filename, [ 'importScripts is not defined' ]);
continue;
}

queue.push(spec);
}
return queue;
Expand Down
62 changes: 0 additions & 62 deletions test/fixtures/wpt/FileAPI/BlobURL/test2-manual.html

This file was deleted.

This file was deleted.

Empty file.
72 changes: 0 additions & 72 deletions test/fixtures/wpt/FileAPI/FileReader/test_errors-manual.html

This file was deleted.

This file was deleted.

This file was deleted.

27 changes: 0 additions & 27 deletions test/fixtures/wpt/FileAPI/FileReader/workers.html

This file was deleted.

Loading