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 File constructor."); | 5 description("Test the File constructor."); |
6 | 6 |
7 // Test the different ways you can construct a File. | 7 // Test the different ways you can construct a File. |
8 shouldBeTrue("(new File([], 'world.html')) instanceof window.File"); | 8 shouldBeTrue("(new File([], 'world.html')) instanceof window.File"); |
9 shouldBeTrue("(new File(['hello'], 'world.html')) instanceof window.File"); | 9 shouldBeTrue("(new File(['hello'], 'world.html')) instanceof window.File"); |
10 shouldBeTrue("(new File(['hello'], 'world.html', {})) instanceof window.File"); | 10 shouldBeTrue("(new File(['hello'], 'world.html', {})) instanceof window.File"); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 shouldBe("(new File([], {})).name", "'[object Object]'"); | 62 shouldBe("(new File([], {})).name", "'[object Object]'"); |
63 shouldBe("(new File([], document)).name", "'[object HTMLDocument]'"); | 63 shouldBe("(new File([], document)).name", "'[object HTMLDocument]'"); |
64 shouldBe("(new File([], toStringingObj)).name", "'A string'"); | 64 shouldBe("(new File([], toStringingObj)).name", "'A string'"); |
65 shouldThrow("(new File([], throwingObj)).name", "'Error'"); | 65 shouldThrow("(new File([], throwingObj)).name", "'Error'"); |
66 | 66 |
67 // Test some invalid property bags. | 67 // Test some invalid property bags. |
68 shouldBeTrue("(new File([], 'world.html', {unknownKey:'value'})) instanceof wind
ow.File"); // Ignore invalid keys | 68 shouldBeTrue("(new File([], 'world.html', {unknownKey:'value'})) instanceof wind
ow.File"); // Ignore invalid keys |
69 shouldThrow("new File([], 'world.html', {endings:'illegalValue'})", "'TypeError:
Failed to construct \\'File\\': The provided value \\'illegalValue\\' is not a
valid enum value of type NormalizeLineEndings.'"); | 69 shouldThrow("new File([], 'world.html', {endings:'illegalValue'})", "'TypeError:
Failed to construct \\'File\\': The provided value \\'illegalValue\\' is not a
valid enum value of type NormalizeLineEndings.'"); |
70 shouldThrow("new File([], 'world.html', {endings:throwingObj})", "'Error'"); | 70 shouldThrow("new File([], 'world.html', {endings:throwingObj})", "'Error'"); |
71 shouldThrow("new File([], 'world.html', {type:throwingObj})", "'Error'"); | 71 shouldThrow("new File([], 'world.html', {type:throwingObj})", "'Error'"); |
72 shouldThrow("new File([], 'world.html', {type:'hello\u00EE'})", "'SyntaxError: F
ailed to construct \\'File\\': The \\'type\\' property must consist of ASCII cha
racters.'"); | 72 |
| 73 // Test non-ASCII type handling |
| 74 shouldBeEqualToString("new File([], 'world.html', {type:'hello\\u00EE'}).type",
""); |
| 75 |
| 76 // Test non-printable-ASCII type handling |
| 77 shouldBeEqualToString("new File([], 'world.html', {type:'hello\\u001F'}).type",
""); |
| 78 shouldBeEqualToString("new File([], 'world.html', {type:'hello\\u007F'}).type",
""); |
| 79 |
| 80 // Test lowercasing of type |
| 81 shouldBeEqualToString("new File([], 'world.html', {type:'ABC/abc'}).type", "abc/
abc"); |
| 82 |
| 83 // Test non-parsable type |
| 84 shouldBeEqualToString("new File([], 'world.html', {type:'123ABCabc'}).type", "12
3abcabc"); |
73 | 85 |
74 // Test various non-object literals being used as property bags. | 86 // Test various non-object literals being used as property bags. |
75 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File"); | 87 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File"); |
76 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File"); | 88 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File"); |
77 shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeEr
ror: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an objec
t.'"); | 89 shouldThrow("(new File([], 'world.html', 123)) instanceof window.File", "'TypeEr
ror: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an objec
t.'"); |
78 shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'Type
Error: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obj
ect.'"); | 90 shouldThrow("(new File([], 'world.html', 123.4)) instanceof window.File", "'Type
Error: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obj
ect.'"); |
79 shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeE
rror: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obje
ct.'"); | 91 shouldThrow("(new File([], 'world.html', true)) instanceof window.File", "'TypeE
rror: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obje
ct.'"); |
80 shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'Type
Error: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obj
ect.'"); | 92 shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'Type
Error: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obj
ect.'"); |
81 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File"); | 93 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File"); |
82 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); | 94 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 149 |
138 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in file
s. | 150 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in file
s. |
139 shouldBe("new Blob([new Blob([new Int32Array(100)]), new File([new Uint16Array(1
00)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new
ArrayBuffer(100))]).size", "1200"); | 151 shouldBe("new Blob([new Blob([new Int32Array(100)]), new File([new Uint16Array(1
00)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new
ArrayBuffer(100))]).size", "1200"); |
140 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), new File([new Uint
16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Ar
ray(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1200"); | 152 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), new File([new Uint
16Array(100).buffer], 'world.txt'), (new Uint8Array(100)).buffer, (new Float32Ar
ray(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).size", "1200"); |
141 | 153 |
142 // Test passing blob parts in objects with indexed properties. | 154 // Test passing blob parts in objects with indexed properties. |
143 // (This depends on the bindings code handling of sequence<T>) | 155 // (This depends on the bindings code handling of sequence<T>) |
144 shouldBe("new File({length: 0}, 'world.txt').size", "0"); | 156 shouldBe("new File({length: 0}, 'world.txt').size", "0"); |
145 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); | 157 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); |
146 </script> | 158 </script> |
OLD | NEW |