-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
buffer: make Blob's slice method more spec-compliant
PR-URL: #37361 Backport-PR-URL: #39704 Fixes: #37335 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
Showing
14 changed files
with
1,355 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
test/fixtures/wpt/FileAPI/blob/Blob-constructor-dom.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// META: title=Blob constructor | ||
// META: script=../support/Blob.js | ||
'use strict'; | ||
|
||
var test_error = { | ||
name: "test", | ||
message: "test error", | ||
}; | ||
|
||
test(function() { | ||
var args = [ | ||
document.createElement("div"), | ||
window, | ||
]; | ||
args.forEach(function(arg) { | ||
assert_throws_js(TypeError, function() { | ||
new Blob(arg); | ||
}, "Should throw for argument " + format_value(arg) + "."); | ||
}); | ||
}, "Passing platform objects for blobParts should throw a TypeError."); | ||
|
||
test(function() { | ||
var element = document.createElement("div"); | ||
element.appendChild(document.createElement("div")); | ||
element.appendChild(document.createElement("p")); | ||
var list = element.children; | ||
Object.defineProperty(list, "length", { | ||
get: function() { throw test_error; } | ||
}); | ||
assert_throws_exactly(test_error, function() { | ||
new Blob(list); | ||
}); | ||
}, "A platform object that supports indexed properties should be treated as a sequence for the blobParts argument (overwritten 'length'.)"); | ||
|
||
test_blob(function() { | ||
var select = document.createElement("select"); | ||
select.appendChild(document.createElement("option")); | ||
return new Blob(select); | ||
}, { | ||
expected: "[object HTMLOptionElement]", | ||
type: "", | ||
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (select)." | ||
}); | ||
|
||
test_blob(function() { | ||
var elm = document.createElement("div"); | ||
elm.setAttribute("foo", "bar"); | ||
return new Blob(elm.attributes); | ||
}, { | ||
expected: "[object Attr]", | ||
type: "", | ||
desc: "Passing an platform object that supports indexed properties as the blobParts array should work (attributes)." | ||
}); |
Oops, something went wrong.