Skip to content

Commit

Permalink
test: cleanup WPT setup files, update WPT fixtures, update expectations
Browse files Browse the repository at this point in the history
  • Loading branch information
panva committed Feb 21, 2023
1 parent c90ea93 commit dca29e1
Show file tree
Hide file tree
Showing 238 changed files with 5,027 additions and 5,159 deletions.
55 changes: 21 additions & 34 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,10 @@ class WPTTestSpec {
}

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

Expand Down Expand Up @@ -374,6 +380,7 @@ class StatusLoader {
result.push(filepath);
}
}
result = result.filter((filepath) => !filepath.endsWith('.helper.js'));
return result;
}

Expand Down Expand Up @@ -484,9 +491,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 +531,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 +890,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

0 comments on commit dca29e1

Please sign in to comment.