| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 | 2 |
| 3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
| 4 <script> | 4 <script> |
| 5 description("Test the Blob constructor."); | 5 description("Test the Blob constructor."); |
| 6 var jsTestIsAsync = true; | 6 var jsTestIsAsync = true; |
| 7 | 7 |
| 8 // Test the different ways you can construct a Blob. | 8 // Test the different ways you can construct a Blob. |
| 9 shouldBeTrue("(new Blob()) instanceof window.Blob"); | 9 shouldBeTrue("(new Blob()) instanceof window.Blob"); |
| 10 shouldBeTrue("(new Blob(undefined)) instanceof window.Blob"); | 10 shouldBeTrue("(new Blob(undefined)) instanceof window.Blob"); |
| 11 shouldBeTrue("(new Blob([])) instanceof window.Blob"); | 11 shouldBeTrue("(new Blob([])) instanceof window.Blob"); |
| 12 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); | 12 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); |
| 13 shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); | 13 shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); |
| 14 shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob")
; | 14 shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob")
; |
| 15 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'native'})) instan
ceof window.Blob"); | |
| 16 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'transparent'})) i
nstanceof window.Blob"); | |
| 17 | 15 |
| 18 // Test default sizes/types. | 16 // Test default sizes/types. |
| 19 shouldBe("(new Blob()).size", "0"); | 17 shouldBe("(new Blob()).size", "0"); |
| 20 shouldBe("(new Blob(undefined)).size", "0"); | 18 shouldBe("(new Blob(undefined)).size", "0"); |
| 21 shouldBeEqualToString("(new Blob()).type", ""); | 19 shouldBeEqualToString("(new Blob()).type", ""); |
| 22 shouldBeEqualToString("(new Blob(undefined)).type", ""); | 20 shouldBeEqualToString("(new Blob(undefined)).type", ""); |
| 23 | 21 |
| 24 // Test invalid blob parts. | 22 // Test invalid blob parts. |
| 25 shouldThrow("new Blob('hello')", '"TypeError: Failed to construct \'Blob\': The
1st argument is neither an array, nor does it have indexed properties."'); | 23 shouldThrow("new Blob('hello')", '"TypeError: Failed to construct \'Blob\': The
1st argument is neither an array, nor does it have indexed properties."'); |
| 26 shouldThrow("new Blob(0)", '"TypeError: Failed to construct \'Blob\': The 1st ar
gument is neither an array, nor does it have indexed properties."'); | 24 shouldThrow("new Blob(0)", '"TypeError: Failed to construct \'Blob\': The 1st ar
gument is neither an array, nor does it have indexed properties."'); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st
ring "[object HTMLDocument]" | 38 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st
ring "[object HTMLDocument]" |
| 41 | 39 |
| 42 var toStringingObj = { toString: function() { return "A string"; } }; | 40 var toStringingObj = { toString: function() { return "A string"; } }; |
| 43 shouldBe("(new Blob([toStringingObj])).size", "8"); | 41 shouldBe("(new Blob([toStringingObj])).size", "8"); |
| 44 | 42 |
| 45 var throwingObj = { toString: function() { throw "Error"; } }; | 43 var throwingObj = { toString: function() { throw "Error"; } }; |
| 46 shouldThrow("new Blob([throwingObj])", "'Error'"); | 44 shouldThrow("new Blob([throwingObj])", "'Error'"); |
| 47 | 45 |
| 48 // Test some invalid property bags. | 46 // Test some invalid property bags. |
| 49 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob");
// Ignore invalid keys | 47 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob");
// Ignore invalid keys |
| 50 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to con
struct \\'Blob\\': The provided value \\'illegalValue\\' is not a valid enum val
ue of type NormalizeLineEndings.'"); | |
| 51 shouldThrow("new Blob([], {endings:throwingObj})", "'Error'"); | |
| 52 shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); | 48 shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); |
| 53 shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to const
ruct \\'Blob\\': The \\'type\\' property must consist of ASCII characters.'"); | 49 shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to const
ruct \\'Blob\\': The \\'type\\' property must consist of ASCII characters.'"); |
| 54 | 50 |
| 55 // Test that order of property bag evaluation is lexigraphical | |
| 56 var throwingObj1 = { toString: function() { throw "Error 1"; } }; | |
| 57 var throwingObj2 = { toString: function() { throw "Error 2"; } }; | |
| 58 shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1
'"); | |
| 59 shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1
'"); | |
| 60 shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError:
Failed to construct \\'Blob\\': The provided value \\'illegal\\' is not a valid
enum value of type NormalizeLineEndings.'"); | |
| 61 | |
| 62 // Test various non-object literals being used as property bags. | 51 // Test various non-object literals being used as property bags. |
| 63 shouldBeTrue("(new Blob([], null)) instanceof window.Blob"); | 52 shouldBeTrue("(new Blob([], null)) instanceof window.Blob"); |
| 64 shouldBeTrue("(new Blob([], undefined)) instanceof window.Blob"); | 53 shouldBeTrue("(new Blob([], undefined)) instanceof window.Blob"); |
| 65 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to
construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); | 54 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to
construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); |
| 66 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); | 55 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); |
| 67 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); | 56 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); |
| 68 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); | 57 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); |
| 69 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); | 58 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); |
| 70 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); | 59 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); |
| 71 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); | 60 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 reader = new FileReader(); | 127 reader = new FileReader(); |
| 139 reader.readAsText(new Blob([CONTAINS_UNPAIRED_SURROGATES])); | 128 reader.readAsText(new Blob([CONTAINS_UNPAIRED_SURROGATES])); |
| 140 reader.onload = function() { | 129 reader.onload = function() { |
| 141 shouldBe("reader.result.charCodeAt(3)", "0xFFFD"); | 130 shouldBe("reader.result.charCodeAt(3)", "0xFFFD"); |
| 142 shouldBe("reader.result.charCodeAt(7)", "0xFFFD"); | 131 shouldBe("reader.result.charCodeAt(7)", "0xFFFD"); |
| 143 finishJSTest(); | 132 finishJSTest(); |
| 144 }; | 133 }; |
| 145 } | 134 } |
| 146 | 135 |
| 147 </script> | 136 </script> |
| OLD | NEW |