OLD | NEW |
1 description("Test the Blob constructor."); | 1 description("Test the Blob constructor."); |
2 | 2 |
3 // Test the diffrent ways you can construct a Blob. | 3 // Test the diffrent ways you can construct a Blob. |
4 shouldBeTrue("(new Blob()) instanceof window.Blob"); | 4 shouldBeTrue("(new Blob()) instanceof window.Blob"); |
5 shouldBeTrue("(new Blob([])) instanceof window.Blob"); | 5 shouldBeTrue("(new Blob([])) instanceof window.Blob"); |
6 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); | 6 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); |
7 shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); | 7 shouldBeTrue("(new Blob(['hello'], {})) instanceof window.Blob"); |
8 shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob")
; | 8 shouldBeTrue("(new Blob(['hello'], {type:'text/html'})) instanceof window.Blob")
; |
9 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'native'})) instan
ceof window.Blob"); | 9 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'native'})) instan
ceof window.Blob"); |
10 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'transparent'})) i
nstanceof window.Blob"); | 10 shouldBeTrue("(new Blob(['hello'], {type:'text/html', endings:'transparent'})) i
nstanceof window.Blob"); |
11 | 11 |
12 // Test invalid blob parts | 12 // Test invalid blob parts |
13 shouldThrow("new Blob('hello')", "'TypeError: First argument of the constructor
is not of type Array'"); | 13 shouldThrow("new Blob('hello')", "'TypeError: First argument of the constructor
is not of type Array'"); |
14 shouldThrow("new Blob(0)", "'TypeError: First argument of the constructor is not
of type Array'"); | 14 shouldThrow("new Blob(0)", "'TypeError: First argument of the constructor is not
of type Array'"); |
15 | 15 |
16 // Test valid blob parts. | 16 // Test valid blob parts. |
17 shouldBeTrue("(new Blob([])) instanceof window.Blob"); | 17 shouldBeTrue("(new Blob([])) instanceof window.Blob"); |
18 shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob"); | 18 shouldBeTrue("(new Blob(['stringPrimitive'])) instanceof window.Blob"); |
19 shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob"); | 19 shouldBeTrue("(new Blob([String('stringObject')])) instanceof window.Blob"); |
20 shouldBeTrue("(new Blob([new Blob])) instanceof window.Blob"); | 20 shouldBeTrue("(new Blob([new Blob])) instanceof window.Blob"); |
21 shouldBeTrue("(new Blob([new Blob([new Blob])])) instanceof window.Blob"); | 21 shouldBeTrue("(new Blob([new Blob([new Blob])])) instanceof window.Blob"); |
22 | 22 |
23 // Test some conversions to string in the parts array. | 23 // Test some conversions to string in the parts array. |
24 shouldBe("(new Blob([12])).size", "2"); | 24 shouldBe("(new Blob([12])).size", "2"); |
25 shouldBe("(new Blob([[]])).size", "0"); // [].toString() is the empty st
ring | 25 shouldBe("(new Blob([[]])).size", "0"); // [].toString() is the empty st
ring |
26 shouldBe("(new Blob([{}])).size", "15");; // {}.toString() is the string "
[object Object]" | 26 shouldBe("(new Blob([{}])).size", "15");; // {}.toString() is the string "
[object Object]" |
27 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st
ring "[object HTMLDocument]" | 27 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st
ring "[object HTMLDocument]" |
28 | 28 |
29 var toStringingObj = { toString: function() { return "A string"; } }; | 29 var toStringingObj = { toString: function() { return "A string"; } }; |
30 shouldBe("(new Blob([toStringingObj])).size", "8"); | 30 shouldBe("(new Blob([toStringingObj])).size", "8"); |
31 | 31 |
32 var throwingObj = { toString: function() { throw "Error"; } }; | 32 var throwingObj = { toString: function() { throw "Error"; } }; |
33 shouldThrow("new Blob([throwingObj])", "'Error'"); | 33 shouldThrow("new Blob([throwingObj])", "'Error'"); |
34 | 34 |
35 // Test some invalid property bags | 35 // Test some invalid property bags |
36 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob");
// Ignore invalid keys | 36 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob");
// Ignore invalid keys |
37 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: The endings p
roperty must be either \"transparent\" or \"native\"'"); | 37 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: The endings p
roperty must be either \"transparent\" or \"native\"'"); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 shouldBe("new Blob([(new Uint8ClampedArray(100)).buffer]).size", "100"); | 85 shouldBe("new Blob([(new Uint8ClampedArray(100)).buffer]).size", "100"); |
86 shouldBe("new Blob([(new Uint16Array(100)).buffer]).size", "200"); | 86 shouldBe("new Blob([(new Uint16Array(100)).buffer]).size", "200"); |
87 shouldBe("new Blob([(new Uint32Array(100)).buffer]).size", "400"); | 87 shouldBe("new Blob([(new Uint32Array(100)).buffer]).size", "400"); |
88 shouldBe("new Blob([(new Int8Array(100)).buffer]).size", "100"); | 88 shouldBe("new Blob([(new Int8Array(100)).buffer]).size", "100"); |
89 shouldBe("new Blob([(new Int16Array(100)).buffer]).size", "200"); | 89 shouldBe("new Blob([(new Int16Array(100)).buffer]).size", "200"); |
90 shouldBe("new Blob([(new Int32Array(100)).buffer]).size", "400"); | 90 shouldBe("new Blob([(new Int32Array(100)).buffer]).size", "400"); |
91 shouldBe("new Blob([(new Float32Array(100)).buffer]).size", "400"); | 91 shouldBe("new Blob([(new Float32Array(100)).buffer]).size", "400"); |
92 shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800"); | 92 shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800"); |
93 shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer
, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).si
ze", "1400"); | 93 shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer
, (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).si
ze", "1400"); |
94 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10
0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100)))
.buffer]).size", "1000"); | 94 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10
0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100)))
.buffer]).size", "1000"); |
OLD | NEW |