Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit af4e682

Browse filesBrowse files
XadillaXtargos
authored andcommitted
test: pass URL's toascii.window.js WPT
PR-URL: #39910 Backport-PR-URL: #40383 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Nitzan Uziely <linkgoron@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent 0a8c331 commit af4e682
Copy full SHA for af4e682

File tree

Expand file treeCollapse file tree

3 files changed

+28
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+28
-7
lines changed
Open diff view settings
Collapse file

‎test/common/wpt.js‎

Copy file name to clipboardExpand all lines: test/common/wpt.js
+19-5Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ class WPTRunner {
301301
this.inProgress = new Set();
302302
this.workers = new Map();
303303
this.unexpectedFailures = [];
304+
305+
this.scriptsModifier = null;
304306
}
305307

306308
/**
@@ -319,6 +321,14 @@ class WPTRunner {
319321
this.initScript = script;
320322
}
321323

324+
/**
325+
* Set the scripts modifier for each script.
326+
* @param {(meta: { code: string, filename: string }) => void}
327+
*/
328+
setScriptModifier(modifier) {
329+
this.scriptsModifier = modifier;
330+
}
331+
322332
get fullInitScript() {
323333
if (this.initScript === null && this.dummyGlobalThisScript === null) {
324334
return null;
@@ -330,7 +340,7 @@ class WPTRunner {
330340
return this.initScript;
331341
}
332342

333-
return `${this.fullInitScript}\n\n//===\n${this.initScript}`;
343+
return `${this.dummyGlobalThisScript}\n\n//===\n${this.initScript}`;
334344
}
335345

336346
/**
@@ -387,17 +397,21 @@ class WPTRunner {
387397
// Scripts specified with the `// META: script=` header
388398
if (meta.script) {
389399
for (const script of meta.script) {
390-
scriptsToRun.push({
400+
const obj = {
391401
filename: this.resource.toRealFilePath(relativePath, script),
392402
code: this.resource.read(relativePath, script, false)
393-
});
403+
};
404+
this.scriptsModifier?.(obj);
405+
scriptsToRun.push(obj);
394406
}
395407
}
396408
// The actual test
397-
scriptsToRun.push({
409+
const obj = {
398410
code: content,
399411
filename: absolutePath
400-
});
412+
};
413+
this.scriptsModifier?.(obj);
414+
scriptsToRun.push(obj);
401415

402416
const workerPath = path.join(__dirname, 'wpt/worker.js');
403417
const worker = new Worker(workerPath, {
Collapse file

‎test/wpt/status/url.json‎

Copy file name to clipboardExpand all lines: test/wpt/status/url.json
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"toascii.window.js": {
3-
"requires": ["small-icu"],
4-
"skip": "TODO: port from .window.js"
3+
"requires": ["small-icu"]
54
},
65
"percent-encoding.window.js": {
76
"requires": ["small-icu"],
Collapse file

‎test/wpt/test-url.js‎

Copy file name to clipboardExpand all lines: test/wpt/test-url.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,13 @@ runner.setInitScript(`
1515
global.DOMException = DOMException;
1616
`);
1717

18+
runner.setScriptModifier((obj) => {
19+
if (obj.filename.includes('toascii.window.js')) {
20+
// `a` and `area` in `toascii.window.js` is for testing `Element` that
21+
// created via `document.createElement`. So we need to ignore them and just
22+
// test `URL`.
23+
obj.code = obj.code.replace(/\["url", "a", "area"\]/, '[ "url" ]');
24+
}
25+
});
1826
runner.pretendGlobalThisAs('Window');
1927
runner.runJsTests();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.