Skip to content

Commit 4714dbc

Browse files
committed
fixup! test: update FileAPI tests from WPT
1 parent cbaae6b commit 4714dbc

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

test/fixtures/wpt/FileAPI/blob/Blob-constructor.any.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,59 @@ test_blob(function() {
104104
desc: "A Uint8Array object should be treated as a sequence for the blobParts argument."
105105
});
106106

107+
test(function() {
108+
assert_throws_js(TypeError, function() { new Blob(true) });
109+
}, "blobParts not an object: boolean");
110+
111+
test(function() {
112+
Boolean.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]()
113+
this.add_cleanup(function() { delete Boolean.prototype[Symbol.iterator] });
114+
assert_throws_js(TypeError, function() { new Blob(true) });
115+
}, "blobParts not an object: boolean with Boolean.prototype[Symbol.iterator]");
116+
117+
test(function() {
118+
assert_throws_js(TypeError, function() { new Blob("fail") });
119+
}, "blobParts not an object: string");
120+
121+
test(function() {
122+
const original = String.prototype[Symbol.iterator];
123+
String.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]()
124+
this.add_cleanup(function() { String.prototype[Symbol.iterator] = original });
125+
assert_throws_js(TypeError, function() { new Blob("fail") });
126+
}, "blobParts not an object: string with String.prototype[Symbol.iterator]");
127+
128+
test(function() {
129+
assert_throws_js(TypeError, function() { new Blob(7) });
130+
}, "blobParts not an object: number");
131+
132+
test(function() {
133+
Number.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]()
134+
this.add_cleanup(function() { delete Number.prototype[Symbol.iterator] });
135+
assert_throws_js(TypeError, function() { new Blob(7) });
136+
}, "blobParts not an object: number with Number.prototype[Symbol.iterator]");
137+
138+
test(function() {
139+
assert_throws_js(TypeError, function() { new Blob(7n) });
140+
}, "blobParts not an object: BigInt");
141+
142+
test(function() {
143+
BigInt.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]()
144+
this.add_cleanup(function() { delete BigInt.prototype[Symbol.iterator] });
145+
assert_throws_js(TypeError, function() { new Blob(7n) });
146+
}, "blobParts not an object: BigInt with BigInt.prototype[Symbol.iterator]");
147+
148+
test(function() {
149+
const symbol = Symbol();
150+
assert_throws_js(TypeError, function() { new Blob(symbol) });
151+
}, "blobParts not an object: Symbol");
152+
153+
test(function() {
154+
const symbol = Symbol();
155+
Symbol.prototype[Symbol.iterator] = () => ["FAIL"][Symbol.iterator]()
156+
this.add_cleanup(function() { delete Symbol.prototype[Symbol.iterator] });
157+
assert_throws_js(TypeError, function() { new Blob(symbol) });
158+
}, "blobParts not an object: Symbol with Symbol.prototype[Symbol.iterator]");
159+
107160
var test_error = {
108161
name: "test",
109162
message: "test error",

test/fixtures/wpt/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Last update:
1717
- dom/events: https://github.com/web-platform-tests/wpt/tree/0a811c5161/dom/events
1818
- encoding: https://github.com/web-platform-tests/wpt/tree/1ac8deee08/encoding
1919
- fetch/data-urls/resources: https://github.com/web-platform-tests/wpt/tree/7c79d998ff/fetch/data-urls/resources
20-
- FileAPI: https://github.com/web-platform-tests/wpt/tree/dbacfb223b/FileAPI
20+
- FileAPI: https://github.com/web-platform-tests/wpt/tree/7f51301888/FileAPI
2121
- hr-time: https://github.com/web-platform-tests/wpt/tree/34cafd797e/hr-time
2222
- html/webappapis/atob: https://github.com/web-platform-tests/wpt/tree/f267e1dca6/html/webappapis/atob
2323
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing

test/fixtures/wpt/versions.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"path": "fetch/data-urls/resources"
2929
},
3030
"FileAPI": {
31-
"commit": "dbacfb223ba49aae8619158ab929ff9ecc6e0d2b",
31+
"commit": "7f5130188818b6c12c636491186b459ec2bf131f",
3232
"path": "FileAPI"
3333
},
3434
"hr-time": {

test/wpt/status/FileAPI/blob.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
"Blob-constructor.any.js": {
66
"fail": {
77
"expected": [
8+
"blobParts not an object: boolean with Boolean.prototype[Symbol.iterator]",
9+
"blobParts not an object: number with Number.prototype[Symbol.iterator]",
10+
"blobParts not an object: BigInt with BigInt.prototype[Symbol.iterator]",
11+
"blobParts not an object: Symbol with Symbol.prototype[Symbol.iterator]",
812
"Getters and value conversions should happen in order until an exception is thrown.",
913
"options properties should be accessed in lexicographic order.",
1014
"Arguments should be evaluated from left to right."

0 commit comments

Comments
 (0)