diff --git a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-navigation.https.html b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-navigation.https.html new file mode 100644 index 00000000000000..a92e0f7a8a9b20 --- /dev/null +++ b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-navigation.https.html @@ -0,0 +1,251 @@ + + + + + + + + + + + + + + + + diff --git a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-self-fetch.https.html b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-self-fetch.https.html new file mode 100644 index 00000000000000..cbff2fa18fa15d --- /dev/null +++ b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-self-fetch.https.html @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-worker-creation.https.html b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-worker-creation.https.html new file mode 100644 index 00000000000000..e8d0bad4c97580 --- /dev/null +++ b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition-worker-creation.https.html @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.https.html b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.https.html new file mode 100644 index 00000000000000..cb66ebe77093bc --- /dev/null +++ b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.https.html @@ -0,0 +1,482 @@ + + + + + + + + + + + + + + + + diff --git a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.tentative.https.html b/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.tentative.https.html deleted file mode 100644 index c75ce07d054eb7..00000000000000 --- a/test/fixtures/wpt/FileAPI/BlobURL/cross-partition.tentative.https.html +++ /dev/null @@ -1,276 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/test/fixtures/wpt/FileAPI/BlobURL/resources/common.js b/test/fixtures/wpt/FileAPI/BlobURL/resources/common.js new file mode 100644 index 00000000000000..60a97d6a5ea5fe --- /dev/null +++ b/test/fixtures/wpt/FileAPI/BlobURL/resources/common.js @@ -0,0 +1,33 @@ +const add_iframe_js = (iframe_origin, response_queue_uuid) => ` + const importScript = ${importScript}; + await importScript("/html/cross-origin-embedder-policy/credentialless" + + "/resources/common.js"); + await importScript("/html/anonymous-iframe/resources/common.js"); + await importScript("/common/utils.js"); + + // dispatcher.js has already been loaded by the popup this is running in. + await send("${response_queue_uuid}", newIframe("${iframe_origin}")); +`; + +async function create_test_iframes(t, response_queue_uuid) { + const same_site_origin = get_host_info().HTTPS_ORIGIN; + const cross_site_origin = get_host_info().HTTPS_NOTSAMESITE_ORIGIN; + + assert_equals("https://" + window.location.host, same_site_origin, + "this test assumes that the page's window.location.host corresponds to " + + "get_host_info().HTTPS_ORIGIN"); + + // Create a same-origin iframe in a cross-site popup. + const not_same_site_popup_uuid = newPopup(t, cross_site_origin); + await send(not_same_site_popup_uuid, + add_iframe_js(same_site_origin, response_queue_uuid)); + const cross_site_iframe_uuid = await receive(response_queue_uuid); + + // Create a same-origin iframe in a same-site popup. + const same_origin_popup_uuid = newPopup(t, same_site_origin); + await send(same_origin_popup_uuid, + add_iframe_js(same_site_origin, response_queue_uuid)); + const same_site_iframe_uuid = await receive(response_queue_uuid); + + return [cross_site_iframe_uuid, same_site_iframe_uuid]; +} \ No newline at end of file diff --git a/test/fixtures/wpt/FileAPI/BlobURL/support/file_test2.txt b/test/fixtures/wpt/FileAPI/BlobURL/support/file_test2.txt deleted file mode 100644 index e69de29bb2d1d6..00000000000000 diff --git a/test/fixtures/wpt/FileAPI/WEB_FEATURES.yml b/test/fixtures/wpt/FileAPI/WEB_FEATURES.yml new file mode 100644 index 00000000000000..8d279ceaaeab21 --- /dev/null +++ b/test/fixtures/wpt/FileAPI/WEB_FEATURES.yml @@ -0,0 +1,3 @@ +features: +- name: file + files: "**" diff --git a/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js b/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js index 6dc44e8e156cce..03155b99cb20ea 100644 --- a/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js +++ b/test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js @@ -104,6 +104,59 @@ test_blob(function() { desc: "A Uint8Array object should be treated as a sequence for the blobParts argument." }); +test(function() { + assert_throws_js(TypeError, function() { new Blob(true) }); +}, "blobParts not an object: boolean"); + +test(function() { + Boolean.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]() + this.add_cleanup(function() { delete Boolean.prototype[Symbol.iterator] }); + assert_throws_js(TypeError, function() { new Blob(true) }); +}, "blobParts not an object: boolean with Boolean.prototype[Symbol.iterator]"); + +test(function() { + assert_throws_js(TypeError, function() { new Blob("fail") }); +}, "blobParts not an object: string"); + +test(function() { + const original = String.prototype[Symbol.iterator]; + String.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]() + this.add_cleanup(function() { String.prototype[Symbol.iterator] = original }); + assert_throws_js(TypeError, function() { new Blob("fail") }); +}, "blobParts not an object: string with String.prototype[Symbol.iterator]"); + +test(function() { + assert_throws_js(TypeError, function() { new Blob(7) }); +}, "blobParts not an object: number"); + +test(function() { + Number.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]() + this.add_cleanup(function() { delete Number.prototype[Symbol.iterator] }); + assert_throws_js(TypeError, function() { new Blob(7) }); +}, "blobParts not an object: number with Number.prototype[Symbol.iterator]"); + +test(function() { + assert_throws_js(TypeError, function() { new Blob(7n) }); +}, "blobParts not an object: BigInt"); + +test(function() { + BigInt.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]() + this.add_cleanup(function() { delete BigInt.prototype[Symbol.iterator] }); + assert_throws_js(TypeError, function() { new Blob(7n) }); +}, "blobParts not an object: BigInt with BigInt.prototype[Symbol.iterator]"); + +test(function() { + const symbol = Symbol(); + assert_throws_js(TypeError, function() { new Blob(symbol) }); +}, "blobParts not an object: Symbol"); + +test(function() { + const symbol = Symbol(); + Symbol.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]() + this.add_cleanup(function() { delete Symbol.prototype[Symbol.iterator] }); + assert_throws_js(TypeError, function() { new Blob(symbol) }); +}, "blobParts not an object: Symbol with Symbol.prototype[Symbol.iterator]"); + var test_error = { name: "test", message: "test error", @@ -290,14 +343,22 @@ test_blob(function() { new Int16Array([0x4150, 0x5353]), new Uint32Array([0x53534150]), new Int32Array([0x53534150]), - new Float16Array([2.65625, 58.59375]), new Float32Array([0xD341500000]) ]); }, { - expected: "PASSPASSPASSPASSPASSPASSPASSPASS", + expected: "PASSPASSPASSPASSPASSPASSPASS", type: "", desc: "Passing typed arrays as elements of the blobParts array should work." }); +test_blob(function() { + return new Blob([ + new Float16Array([2.65625, 58.59375]) + ]); +}, { + expected: "PASS", + type: "", + desc: "Passing a Float16Array as element of the blobParts array should work." +}); test_blob(function() { return new Blob([ // 0x535 3415053534150 diff --git a/test/fixtures/wpt/FileAPI/blob/Blob-newobject.any.js b/test/fixtures/wpt/FileAPI/blob/Blob-newobject.any.js new file mode 100644 index 00000000000000..e036c3a9a743e6 --- /dev/null +++ b/test/fixtures/wpt/FileAPI/blob/Blob-newobject.any.js @@ -0,0 +1,12 @@ +// META: title=Blob methods return new objects ([NewObject]) +// META: global=window,worker +'use strict'; + +['stream', 'text', 'arrayBuffer', 'bytes'].forEach(method => { + test(() => { + const blob = new Blob(['PASS']); + const a = blob[method](); + const b = blob[method](); + assert_not_equals(a, b, `Blob.${method}() must return a new object`); + }, `Blob.${method}() returns [NewObject]`); +}); diff --git a/test/fixtures/wpt/FileAPI/blob/Blob-slice.any.js b/test/fixtures/wpt/FileAPI/blob/Blob-slice.any.js index 1f85d44d269191..bedc8d737302a0 100644 --- a/test/fixtures/wpt/FileAPI/blob/Blob-slice.any.js +++ b/test/fixtures/wpt/FileAPI/blob/Blob-slice.any.js @@ -12,24 +12,50 @@ test_blob(function() { }); test(function() { - var blob1, blob2; + var blob1 = new Blob(["squiggle"]); + var blob2 = new Blob(["steak"], {type: "content/type"}); - test_blob(function() { - return blob1 = new Blob(["squiggle"]); - }, { + test_blob(() => blob1, + { expected: "squiggle", type: "", desc: "blob1." }); - test_blob(function() { - return blob2 = new Blob(["steak"], {type: "content/type"}); - }, { + test_blob(() => blob2, + { expected: "steak", type: "content/type", desc: "blob2." }); + test_blob(function() { + var blob = new Blob(["abcd"]); + return blob.slice(undefined, undefined, "content/type"); + }, { + expected: "abcd", + type: "content/type", + desc: "undefined start/end Blob slice" + }); + + test_blob(function() { + var blob = new Blob(["abcd"]); + return blob.slice(undefined, 2, "content/type"); + }, { + expected: "ab", + type: "content/type", + desc: "undefined start Blob slice" + }); + + test_blob(function() { + var blob = new Blob(["abcd"]); + return blob.slice(2, undefined, "content/type"); + }, { + expected: "cd", + type: "content/type", + desc: "undefined end Blob slice" + }); + test_blob(function() { return new Blob().slice(0,0,null); }, { @@ -74,6 +100,21 @@ test(function() { {start: 7, end: 4, contents: ""}] ], + // Test double start/end values + [ + ["abcd"], + [{start: 0.5, contents: "abcd"}, + {start: 1.5, contents: "cd"}, + {start: 2.5, contents: "cd"}, + {start: 3.5, contents: ""}, + {start: 0, end: 0.5, contents: ""}, + {start: 0, end: 1.5, contents: "ab"}, + {start: 0, end: 2.5, contents: "ab"}, + {start: 0, end: 3.5, contents: "abcd"}, + {start: 1.5, end: 2.5, contents: ""}, + {start: 1.5, end: 3.5, contents: "cd"}] + ], + // Test 3 strings [ ["foo", "bar", "baz"], diff --git a/test/fixtures/wpt/FileAPI/reading-data-section/filereader_readAsArrayBuffer.any.js b/test/fixtures/wpt/FileAPI/reading-data-section/filereader_readAsArrayBuffer.any.js index d06e3170782b7c..88c4f4d26cc0b2 100644 --- a/test/fixtures/wpt/FileAPI/reading-data-section/filereader_readAsArrayBuffer.any.js +++ b/test/fixtures/wpt/FileAPI/reading-data-section/filereader_readAsArrayBuffer.any.js @@ -7,6 +7,7 @@ reader.onload = this.step_func(function(evt) { assert_equals(reader.result.byteLength, 4, "The byteLength is 4"); assert_true(reader.result instanceof ArrayBuffer, "The result is instanceof ArrayBuffer"); + assert_array_equals(new Uint8Array(reader.result), [84, 69, 83, 84]); assert_equals(reader.readyState, reader.DONE); this.done(); }); diff --git a/test/fixtures/wpt/FileAPI/support/Blob.js b/test/fixtures/wpt/FileAPI/support/Blob.js index 2c249746858918..e8a52425a17085 100644 --- a/test/fixtures/wpt/FileAPI/support/Blob.js +++ b/test/fixtures/wpt/FileAPI/support/Blob.js @@ -5,23 +5,16 @@ self.test_blob = (fn, expectations) => { type = expectations.type, desc = expectations.desc; - var t = async_test(desc); - t.step(function() { + promise_test(async (t) => { var blob = fn(); assert_true(blob instanceof Blob); assert_false(blob instanceof File); assert_equals(blob.type, type); assert_equals(blob.size, expected.length); - var fr = new FileReader(); - fr.onload = t.step_func_done(function(event) { - assert_equals(this.result, expected); - }, fr); - fr.onerror = t.step_func(function(e) { - assert_unreached("got error event on FileReader"); - }); - fr.readAsText(blob, "UTF-8"); - }); + const text = await blob.text(); + assert_equals(text, expected); + }, desc); } self.test_blob_binary = (fn, expectations) => { @@ -29,25 +22,18 @@ self.test_blob_binary = (fn, expectations) => { type = expectations.type, desc = expectations.desc; - var t = async_test(desc); - t.step(function() { + promise_test(async (t) => { var blob = fn(); assert_true(blob instanceof Blob); assert_false(blob instanceof File); assert_equals(blob.type, type); assert_equals(blob.size, expected.length); - var fr = new FileReader(); - fr.onload = t.step_func_done(function(event) { - assert_true(this.result instanceof ArrayBuffer, - "Result should be an ArrayBuffer"); - assert_array_equals(new Uint8Array(this.result), expected); - }, fr); - fr.onerror = t.step_func(function(e) { - assert_unreached("got error event on FileReader"); - }); - fr.readAsArrayBuffer(blob); - }); + const ab = await blob.arrayBuffer(); + assert_true(ab instanceof ArrayBuffer, + "Result should be an ArrayBuffer"); + assert_array_equals(new Uint8Array(ab), expected); + }, desc); } // Assert that two TypedArray objects have the same byte values diff --git a/test/fixtures/wpt/FileAPI/support/send-file-form-helper.js b/test/fixtures/wpt/FileAPI/support/send-file-form-helper.js index 39c73c41b42207..d6adf21ec33795 100644 --- a/test/fixtures/wpt/FileAPI/support/send-file-form-helper.js +++ b/test/fixtures/wpt/FileAPI/support/send-file-form-helper.js @@ -180,7 +180,7 @@ const formPostFileUploadTest = ({ // Used to verify that the browser agrees with the test about // field value replacement and encoding independently of file system - // idiosyncrasies. + // idiosyncracies. form.append(Object.assign(document.createElement('input'), { type: 'hidden', name: 'filename', diff --git a/test/fixtures/wpt/FileAPI/support/send-file-formdata-helper.js b/test/fixtures/wpt/FileAPI/support/send-file-formdata-helper.js index dd62a0e98e92c8..53c8cca7e09b8e 100644 --- a/test/fixtures/wpt/FileAPI/support/send-file-formdata-helper.js +++ b/test/fixtures/wpt/FileAPI/support/send-file-formdata-helper.js @@ -34,7 +34,7 @@ const formDataPostFileUploadTest = ({ // Used to verify that the browser agrees with the test about // field value replacement and encoding independently of file system - // idiosyncrasies. + // idiosyncracies. formData.append("filename", fileBaseName); // Same, but with name and value reversed to ensure field names diff --git a/test/fixtures/wpt/FileAPI/url/url-in-tags.window.js b/test/fixtures/wpt/FileAPI/url/url-in-tags.window.js index f20b3599013bf5..8a722dcac82b66 100644 --- a/test/fixtures/wpt/FileAPI/url/url-in-tags.window.js +++ b/test/fixtures/wpt/FileAPI/url/url-in-tags.window.js @@ -1,3 +1,10 @@ +setup(() => { + const viewport_meta = document.createElement('meta'); + viewport_meta.name = "viewport"; + viewport_meta.content = "width=device-width,initial-scale=1"; + document.head.appendChild(viewport_meta); +}); + async_test(t => { const run_result = 'test_script_OK'; const blob_contents = 'window.test_result = "' + run_result + '";'; diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 22e6bc3e3b480e..7a22722fb32b6d 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -17,7 +17,7 @@ Last update: - dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events - encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding - fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources -- FileAPI: https://github.com/web-platform-tests/wpt/tree/cceaf3628d/FileAPI +- FileAPI: https://github.com/web-platform-tests/wpt/tree/7f51301888/FileAPI - hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time - html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob - html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 382038acf9f05b..b191ab695d7575 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -28,7 +28,7 @@ "path": "fetch/data-urls/resources" }, "FileAPI": { - "commit": "cceaf3628da950621004d9b5d8c1d1f367073347", + "commit": "7f5130188818b6c12c636491186b459ec2bf131f", "path": "FileAPI" }, "hr-time": { diff --git a/test/wpt/status/FileAPI/blob.json b/test/wpt/status/FileAPI/blob.json index 8ea03bbc019992..e92f6b8de84468 100644 --- a/test/wpt/status/FileAPI/blob.json +++ b/test/wpt/status/FileAPI/blob.json @@ -4,38 +4,14 @@ }, "Blob-constructor.any.js": { "fail": { - "note": "Depends on File API", "expected": [ - "A plain object with @@iterator should be treated as a sequence for the blobParts argument.", - "A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument.", - "A String object should be treated as a sequence for the blobParts argument.", - "A Uint8Array object should be treated as a sequence for the blobParts argument.", + "blobParts not an object: boolean with Boolean.prototype[Symbol.iterator]", + "blobParts not an object: number with Number.prototype[Symbol.iterator]", + "blobParts not an object: BigInt with BigInt.prototype[Symbol.iterator]", + "blobParts not an object: Symbol with Symbol.prototype[Symbol.iterator]", "Getters and value conversions should happen in order until an exception is thrown.", - "Changes to the blobParts array should be reflected in the returned Blob (pop).", - "Changes to the blobParts array should be reflected in the returned Blob (unshift).", - "ToString should be called on elements of the blobParts array.", - "ArrayBuffer elements of the blobParts array should be supported.", - "Passing typed arrays as elements of the blobParts array should work.", - "Passing a Float64Array as element of the blobParts array should work.", - "Passing BigInt typed arrays as elements of the blobParts array should work.", - "Array with two blobs", - "Array with two buffers", - "Array with two bufferviews", - "Array with mixed types", "options properties should be accessed in lexicographic order.", - "Arguments should be evaluated from left to right.", - "Passing null (index 0) for options should use the defaults.", - "Passing null (index 0) for options should use the defaults (with newlines).", - "Passing undefined (index 1) for options should use the defaults.", - "Passing undefined (index 1) for options should use the defaults (with newlines).", - "Passing object \"[object Object]\" (index 2) for options should use the defaults.", - "Passing object \"[object Object]\" (index 2) for options should use the defaults (with newlines).", - "Passing object \"[object Object]\" (index 3) for options should use the defaults.", - "Passing object \"[object Object]\" (index 3) for options should use the defaults (with newlines).", - "Passing object \"/regex/\" (index 4) for options should use the defaults.", - "Passing object \"/regex/\" (index 4) for options should use the defaults (with newlines).", - "Passing function \"function() {}\" (index 5) for options should use the defaults.", - "Passing function \"function() {}\" (index 5) for options should use the defaults (with newlines)." + "Arguments should be evaluated from left to right." ] } }, @@ -43,6 +19,15 @@ "skip": "Depends on Web Workers API" }, "Blob-slice.any.js": { - "skip": "Depends on File API" + "fail": { + "expected": [ + "Slicing test: slice (1,1).", + "Slicing test: slice (1,3).", + "Slicing test: slice (1,5).", + "Slicing test: slice (1,7).", + "Slicing test: slice (1,8).", + "Slicing test: slice (1,9)." + ] + } } }