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 | 6 |
7 // Test the different ways you can construct a Blob. | 7 // Test the different ways you can construct a Blob. |
8 shouldBeTrue("(new Blob()) instanceof window.Blob"); | 8 shouldBeTrue("(new Blob()) instanceof window.Blob"); |
9 shouldBeTrue("(new Blob([])) instanceof window.Blob"); | 9 shouldBeTrue("(new Blob([])) instanceof window.Blob"); |
10 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); | 10 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 54 shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
55 shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Fai
led to construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 55 shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Fai
led to construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
56 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to
construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 56 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to
construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
57 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 57 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
58 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 58 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t
o construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
59 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': The 2nd argument is not of type Object.'"); | 59 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed
to construct \\'Blob\\': The 2nd argument is not of type Object.'"); |
60 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); | 60 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); |
61 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); | 61 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); |
62 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); | 62 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); |
63 | 63 |
64 // Test that the type/size is correctly added to the Blob | 64 // Test that the type/size is correctly added to the Blob. |
65 shouldBe("(new Blob([], {type:'text/html'})).type", "'text/html'"); | 65 shouldBe("(new Blob([], {type:'text/html'})).type", "'text/html'"); |
66 shouldBe("(new Blob([], {type:'text/html'})).size", "0"); | 66 shouldBe("(new Blob([], {type:'text/html'})).size", "0"); |
67 shouldBe("(new Blob([], {type:'text/plain;charset=UTF-8'})).type", "'text/plain;
charset=utf-8'"); | 67 shouldBe("(new Blob([], {type:'text/plain;charset=UTF-8'})).type", "'text/plain;
charset=utf-8'"); |
68 | 68 |
| 69 // Test that the File-specific lastModificationDate is not set by the Blob const
ructor. |
| 70 shouldBe("(new Blob([])).lastModifiedDate", "undefined"); |
| 71 shouldBe("(new Blob([], {})).lastModifiedDate", "undefined"); |
| 72 shouldBe("(new Blob([], {lastModifiedDate: new Date()})).lastModifiedDate", "und
efined"); |
| 73 shouldBe("(new Blob([], {lastModifiedDate: 'not a valid date'})).lastModifiedDat
e", "undefined"); |
| 74 |
69 // Test the number of expected arguments in the Blob constructor. | 75 // Test the number of expected arguments in the Blob constructor. |
70 shouldBe("window.Blob.length", "0"); | 76 shouldBe("window.Blob.length", "0"); |
71 | 77 |
72 // Test ArrayBufferView parameters. | 78 // Test ArrayBufferView parameters. |
73 shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100"); | 79 shouldBe("new Blob([new DataView(new ArrayBuffer(100))]).size", "100"); |
74 shouldBe("new Blob([new Uint8Array(100)]).size", "100"); | 80 shouldBe("new Blob([new Uint8Array(100)]).size", "100"); |
75 shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100"); | 81 shouldBe("new Blob([new Uint8ClampedArray(100)]).size", "100"); |
76 shouldBe("new Blob([new Uint16Array(100)]).size", "200"); | 82 shouldBe("new Blob([new Uint16Array(100)]).size", "200"); |
77 shouldBe("new Blob([new Uint32Array(100)]).size", "400"); | 83 shouldBe("new Blob([new Uint32Array(100)]).size", "400"); |
78 shouldBe("new Blob([new Int8Array(100)]).size", "100"); | 84 shouldBe("new Blob([new Int8Array(100)]).size", "100"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Object.defineProperty(throwingSequence, "1", { | 116 Object.defineProperty(throwingSequence, "1", { |
111 get: function() { throw new Error("Misbehaving property"); }, | 117 get: function() { throw new Error("Misbehaving property"); }, |
112 enumerable: true, configurable: true | 118 enumerable: true, configurable: true |
113 }); | 119 }); |
114 Object.defineProperty(throwingSequence, "2", { | 120 Object.defineProperty(throwingSequence, "2", { |
115 get: function() { throw new Error("This should not be thrown"); }, | 121 get: function() { throw new Error("This should not be thrown"); }, |
116 enumerable: true, configurable: true | 122 enumerable: true, configurable: true |
117 }); | 123 }); |
118 shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'"); | 124 shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'"); |
119 </script> | 125 </script> |
OLD | NEW |