Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions FileAPI/blob/Blob-constructor.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down