| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0a8c331 commit af4e682
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -301,6 +301,8 @@ class WPTRunner { | |||
| 301 | 301 | this.inProgress = new Set(); | |
| 302 | 302 | this.workers = new Map(); | |
| 303 | 303 | this.unexpectedFailures = []; | |
| 304 | + | ||
| 305 | + this.scriptsModifier = null; | ||
| 304 | 306 | } | |
| 305 | 307 | ||
| 306 | 308 | /** | |
@@ -319,6 +321,14 @@ class WPTRunner { | |||
| 319 | 321 | this.initScript = script; | |
| 320 | 322 | } | |
| 321 | 323 | ||
| 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 | + | ||
| 322 | 332 | get fullInitScript() { | |
| 323 | 333 | if (this.initScript === null && this.dummyGlobalThisScript === null) { | |
| 324 | 334 | return null; | |
@@ -330,7 +340,7 @@ class WPTRunner { | |||
| 330 | 340 | return this.initScript; | |
| 331 | 341 | } | |
| 332 | 342 | ||
| 333 | - return `${this.fullInitScript}\n\n//===\n${this.initScript}`; | ||
| 343 | + return `${this.dummyGlobalThisScript}\n\n//===\n${this.initScript}`; | ||
| 334 | 344 | } | |
| 335 | 345 | ||
| 336 | 346 | /** | |
@@ -387,17 +397,21 @@ class WPTRunner { | |||
| 387 | 397 | // Scripts specified with the `// META: script=` header | |
| 388 | 398 | if (meta.script) { | |
| 389 | 399 | for (const script of meta.script) { | |
| 390 | - scriptsToRun.push({ | ||
| 400 | + const obj = { | ||
| 391 | 401 | filename: this.resource.toRealFilePath(relativePath, script), | |
| 392 | 402 | code: this.resource.read(relativePath, script, false) | |
| 393 | - }); | ||
| 403 | + }; | ||
| 404 | + this.scriptsModifier?.(obj); | ||
| 405 | + scriptsToRun.push(obj); | ||
| 394 | 406 | } | |
| 395 | 407 | } | |
| 396 | 408 | // The actual test | |
| 397 | - scriptsToRun.push({ | ||
| 409 | + const obj = { | ||
| 398 | 410 | code: content, | |
| 399 | 411 | filename: absolutePath | |
| 400 | - }); | ||
| 412 | + }; | ||
| 413 | + this.scriptsModifier?.(obj); | ||
| 414 | + scriptsToRun.push(obj); | ||
| 401 | 415 | ||
| 402 | 416 | const workerPath = path.join(__dirname, 'wpt/worker.js'); | |
| 403 | 417 | const worker = new Worker(workerPath, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | { | |
| 2 | 2 | "toascii.window.js": { | |
| 3 | - "requires": ["small-icu"], | ||
| 4 | - "skip": "TODO: port from .window.js" | ||
| 3 | + "requires": ["small-icu"] | ||
| 5 | 4 | }, | |
| 6 | 5 | "percent-encoding.window.js": { | |
| 7 | 6 | "requires": ["small-icu"], | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,5 +15,13 @@ runner.setInitScript(` | |||
| 15 | 15 | global.DOMException = DOMException; | |
| 16 | 16 | `); | |
| 17 | 17 | ||
| 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 | + }); | ||
| 18 | 26 | runner.pretendGlobalThisAs('Window'); | |
| 19 | 27 | runner.runJsTests(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments