| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -453,14 +453,13 @@ class WPTRunner { | |||
| 453 | 453 | this.scriptsModifier = modifier; | |
| 454 | 454 | } | |
| 455 | 455 | ||
| 456 | - fullInitScript(hasSubsetScript, locationSearchString) { | ||
| 456 | + fullInitScript(url, metaTitle) { | ||
| 457 | 457 | let { initScript } = this; | |
| 458 | - if (hasSubsetScript || locationSearchString) { | ||
| 459 | - initScript = `${initScript}\n\n//===\nglobalThis.location ||= {};`; | ||
| 460 | - } | ||
| 461 | 458 | ||
| 462 | - if (locationSearchString) { | ||
| 463 | - initScript = `${initScript}\n\n//===\nglobalThis.location.search = "${locationSearchString}";`; | ||
| 459 | + initScript = `${initScript}\n\n//===\nglobalThis.location = new URL("${url.href}");`; | ||
| 460 | + | ||
| 461 | + if (metaTitle) { | ||
| 462 | + initScript = `${initScript}\n\n//===\nglobalThis.META_TITLE = "${metaTitle}";`; | ||
| 464 | 463 | } | |
| 465 | 464 | ||
| 466 | 465 | if (this.globalThisInitScripts.length === null) { | |
@@ -553,13 +552,13 @@ class WPTRunner { | |||
| 553 | 552 | const relativePath = spec.getRelativePath(); | |
| 554 | 553 | const harnessPath = fixtures.path('wpt', 'resources', 'testharness.js'); | |
| 555 | 554 | const scriptsToRun = []; | |
| 556 | - let hasSubsetScript = false; | ||
| 555 | + let needsGc = false; | ||
| 557 | 556 | ||
| 558 | 557 | // Scripts specified with the `// META: script=` header | |
| 559 | 558 | if (meta.script) { | |
| 560 | 559 | for (const script of meta.script) { | |
| 561 | - if (script === '/common/subset-tests.js' || script === '/common/subset-tests-by-key.js') { | ||
| 562 | - hasSubsetScript = true; | ||
| 560 | + if (script === '/common/gc.js') { | ||
| 561 | + needsGc = true; | ||
| 563 | 562 | } | |
| 564 | 563 | const obj = { | |
| 565 | 564 | filename: this.resource.toRealFilePath(relativePath, script), | |
@@ -592,12 +591,13 @@ class WPTRunner { | |||
| 592 | 591 | testRelativePath: relativePath, | |
| 593 | 592 | wptRunner: __filename, | |
| 594 | 593 | wptPath: this.path, | |
| 595 | - initScript: this.fullInitScript(hasSubsetScript, variant), | ||
| 594 | + initScript: this.fullInitScript(new URL(`/${relativePath.replace(/\.js$/, '.html')}${variant}`, 'http://wpt'), meta.title), | ||
| 596 | 595 | harness: { | |
| 597 | 596 | code: fs.readFileSync(harnessPath, 'utf8'), | |
| 598 | 597 | filename: harnessPath, | |
| 599 | 598 | }, | |
| 600 | 599 | scriptsToRun, | |
| 600 | + needsGc, | ||
| 601 | 601 | }, | |
| 602 | 602 | }); | |
| 603 | 603 | this.workers.set(testFileName, worker); | |
@@ -749,11 +749,7 @@ class WPTRunner { | |||
| 749 | 749 | */ | |
| 750 | 750 | resultCallback(filename, test, reportResult) { | |
| 751 | 751 | const status = this.getTestStatus(test.status); | |
| 752 | - const title = this.getTestTitle(filename); | ||
| 753 | - if (/^Untitled( \d+)?$/.test(test.name)) { | ||
| 754 | - test.name = `${title}${test.name.slice(8)}`; | ||
| 755 | - } | ||
| 756 | - console.log(`---- ${title} ----`); | ||
| 752 | + console.log(`---- ${test.name} ----`); | ||
| 757 | 753 | if (status !== kPass) { | |
| 758 | 754 | this.fail(filename, test, status, reportResult); | |
| 759 | 755 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,29 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | - const { runInThisContext } = require('vm'); | ||
| 3 | + const { runInNewContext, runInThisContext } = require('vm'); | ||
| 4 | + const { setFlagsFromString } = require('v8'); | ||
| 4 | 5 | const { parentPort, workerData } = require('worker_threads'); | |
| 5 | 6 | ||
| 6 | 7 | const { ResourceLoader } = require(workerData.wptRunner); | |
| 7 | 8 | const resource = new ResourceLoader(workerData.wptPath); | |
| 8 | 9 | ||
| 9 | - global.self = global; | ||
| 10 | - global.GLOBAL = { | ||
| 10 | + if (workerData.needsGc) { | ||
| 11 | + // See https://github.com/nodejs/node/issues/16595#issuecomment-340288680 | ||
| 12 | + setFlagsFromString('--expose-gc'); | ||
| 13 | + globalThis.gc = runInNewContext('gc'); | ||
| 14 | + } | ||
| 15 | + | ||
| 16 | + globalThis.self = global; | ||
| 17 | + globalThis.GLOBAL = { | ||
| 11 | 18 | isWindow() { return false; }, | |
| 12 | 19 | isShadowRealm() { return false; }, | |
| 13 | 20 | }; | |
| 14 | - global.require = require; | ||
| 21 | + globalThis.require = require; | ||
| 15 | 22 | ||
| 16 | 23 | // This is a mock, because at the moment fetch is not implemented | |
| 17 | 24 | // in Node.js, but some tests and harness depend on this to pull | |
| 18 | 25 | // resources. | |
| 19 | - global.fetch = function fetch(file) { | ||
| 26 | + globalThis.fetch = function fetch(file) { | ||
| 20 | 27 | return resource.read(workerData.testRelativePath, file, true); | |
| 21 | 28 | }; | |
| 22 | 29 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,59 @@ | |||
| 1 | + <!DOCTYPE html> | ||
| 2 | + <meta charset="utf-8"> | ||
| 3 | + <title>Blob methods from detached frame work as expected</title> | ||
| 4 | + <script src="/resources/testharness.js"></script> | ||
| 5 | + <script src="/resources/testharnessreport.js"></script> | ||
| 6 | + | ||
| 7 | + <iframe id="emptyDocumentIframe" src="../support/empty-document.html"></iframe> | ||
| 8 | + | ||
| 9 | + <script> | ||
| 10 | + const BlobPrototypeFromDetachedFramePromise = new Promise(resolve => { | ||
| 11 | + emptyDocumentIframe.onload = () => { | ||
| 12 | + const BlobPrototype = emptyDocumentIframe.contentWindow.Blob.prototype; | ||
| 13 | + emptyDocumentIframe.remove(); | ||
| 14 | + resolve(BlobPrototype); | ||
| 15 | + }; | ||
| 16 | + }); | ||
| 17 | + | ||
| 18 | + const charCodeArrayToString = charCodeArray => Array.from(charCodeArray, c => String.fromCharCode(c)).join(""); | ||
| 19 | + const charCodeBufferToString = charCodeBuffer => charCodeArrayToString(new Uint8Array(charCodeBuffer)); | ||
| 20 | + | ||
| 21 | + promise_test(async () => { | ||
| 22 | + const { slice } = await BlobPrototypeFromDetachedFramePromise; | ||
| 23 | + const blob = new Blob(["foobar"]); | ||
| 24 | + | ||
| 25 | + const slicedBlob = slice.call(blob, 1, 3); | ||
| 26 | + assert_true(slicedBlob instanceof Blob); | ||
| 27 | + | ||
| 28 | + assert_equals(await slicedBlob.text(), "oo"); | ||
| 29 | + assert_equals(charCodeBufferToString(await slicedBlob.arrayBuffer()), "oo"); | ||
| 30 | + | ||
| 31 | + const reader = slicedBlob.stream().getReader(); | ||
| 32 | + const { value } = await reader.read(); | ||
| 33 | + assert_equals(charCodeArrayToString(value), "oo"); | ||
| 34 | + }, "slice()"); | ||
| 35 | + | ||
| 36 | + promise_test(async () => { | ||
| 37 | + const { text } = await BlobPrototypeFromDetachedFramePromise; | ||
| 38 | + const blob = new Blob(["foo"]); | ||
| 39 | + | ||
| 40 | + assert_equals(await text.call(blob), "foo"); | ||
| 41 | + }, "text()"); | ||
| 42 | + | ||
| 43 | + promise_test(async () => { | ||
| 44 | + const { arrayBuffer } = await BlobPrototypeFromDetachedFramePromise; | ||
| 45 | + const blob = new Blob(["bar"]); | ||
| 46 | + | ||
| 47 | + const charCodeBuffer = await arrayBuffer.call(blob); | ||
| 48 | + assert_equals(charCodeBufferToString(charCodeBuffer), "bar"); | ||
| 49 | + }, "arrayBuffer()"); | ||
| 50 | + | ||
| 51 | + promise_test(async () => { | ||
| 52 | + const { stream } = await BlobPrototypeFromDetachedFramePromise; | ||
| 53 | + const blob = new Blob(["baz"]); | ||
| 54 | + | ||
| 55 | + const reader = stream.call(blob).getReader(); | ||
| 56 | + const { value } = await reader.read(); | ||
| 57 | + assert_equals(charCodeArrayToString(value), "baz"); | ||
| 58 | + }, "stream()"); | ||
| 59 | + </script> | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments