}, "Passing non-objects, Dates and RegExps for blobParts should throw a TypeError.");
test_blob(function() {
- return new Blob({ 0: "PASS", length: 1 });
+ return new Blob({
+ [Symbol.iterator]: Array.prototype[Symbol.iterator],
+ 0: "PASS",
+ length: 1
+ });
}, {
expected: "PASS",
type: "",
- desc: "A plain object with a length property should be treated as a sequence for the blobParts argument."
+ desc: "A plain object with @@iterator and a length property should be treated as a sequence for the blobParts argument."
});
test_blob(function() {
return new Blob(new String("xyz"));
test(function() {
var obj = {
+ [Symbol.iterator]: Array.prototype[Symbol.iterator],
get length() { throw test_error; }
};
assert_throws(test_error, function() {
test(function() {
assert_throws(test_error, function() {
var obj = {
+ [Symbol.iterator]: Array.prototype[Symbol.iterator],
length: {
valueOf: null,
toString: function() { throw test_error; }
});
assert_throws(test_error, function() {
var obj = {
+ [Symbol.iterator]: Array.prototype[Symbol.iterator],
length: { valueOf: function() { throw test_error; } }
};
new Blob(obj);
test(function() {
var received = [];
var obj = {
+ get [Symbol.iterator]() {
+ received.push("Symbol.iterator");
+ return Array.prototype[Symbol.iterator];
+ },
get length() {
received.push("length getter");
return {
new Blob(obj);
});
assert_array_equals(received, [
+ "Symbol.iterator",
"length getter",
"length valueOf",
"0 getter",
"0 toString",
+ "length getter",
+ "length valueOf",
"1 getter"
]);
}, "Getters and value conversions should happen in order until an exception is thrown.");