| 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"); |
| 11 shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html'})) instanceof
window.File"); | 11 shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html'})) instanceof
window.File"); |
| 12 shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html', endings:'nat
ive'})) instanceof window.File"); | |
| 13 shouldBeTrue("(new File(['hello'], 'world.html', {type:'text/html', endings:'tra
nsparent'})) instanceof window.File"); | |
| 14 | 12 |
| 15 // Test that File inherits from File. | 13 // Test that File inherits from File. |
| 16 shouldBeTrue("(new File([], 'world.html')) instanceof window.File") | 14 shouldBeTrue("(new File([], 'world.html')) instanceof window.File") |
| 17 | 15 |
| 18 // Verify that the file name argument is required. | 16 // Verify that the file name argument is required. |
| 19 shouldThrow("(new File())", '"TypeError: Failed to construct \'File\': 2 argumen
ts required, but only 0 present."'); | 17 shouldThrow("(new File())", '"TypeError: Failed to construct \'File\': 2 argumen
ts required, but only 0 present."'); |
| 20 shouldThrow("(new File([]))", '"TypeError: Failed to construct \'File\': 2 argum
ents required, but only 1 present."'); | 18 shouldThrow("(new File([]))", '"TypeError: Failed to construct \'File\': 2 argum
ents required, but only 1 present."'); |
| 21 | 19 |
| 22 // Test valid file names. | 20 // Test valid file names. |
| 23 shouldBeTrue("(new File([], null)) instanceof window.File"); | 21 shouldBeTrue("(new File([], null)) instanceof window.File"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 shouldBe("(new File([], null)).name", "'null'"); | 57 shouldBe("(new File([], null)).name", "'null'"); |
| 60 shouldBe("(new File([], 12)).name", "'12'"); | 58 shouldBe("(new File([], 12)).name", "'12'"); |
| 61 shouldBe("(new File([], '')).name", "''"); | 59 shouldBe("(new File([], '')).name", "''"); |
| 62 shouldBe("(new File([], {})).name", "'[object Object]'"); | 60 shouldBe("(new File([], {})).name", "'[object Object]'"); |
| 63 shouldBe("(new File([], document)).name", "'[object HTMLDocument]'"); | 61 shouldBe("(new File([], document)).name", "'[object HTMLDocument]'"); |
| 64 shouldBe("(new File([], toStringingObj)).name", "'A string'"); | 62 shouldBe("(new File([], toStringingObj)).name", "'A string'"); |
| 65 shouldThrow("(new File([], throwingObj)).name", "'Error'"); | 63 shouldThrow("(new File([], throwingObj)).name", "'Error'"); |
| 66 | 64 |
| 67 // Test some invalid property bags. | 65 // Test some invalid property bags. |
| 68 shouldBeTrue("(new File([], 'world.html', {unknownKey:'value'})) instanceof wind
ow.File"); // Ignore invalid keys | 66 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.'"); | |
| 70 shouldThrow("new File([], 'world.html', {endings:throwingObj})", "'Error'"); | |
| 71 shouldThrow("new File([], 'world.html', {type:throwingObj})", "'Error'"); | 67 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.'"); | 68 shouldThrow("new File([], 'world.html', {type:'hello\u00EE'})", "'SyntaxError: F
ailed to construct \\'File\\': The \\'type\\' property must consist of ASCII cha
racters.'"); |
| 73 | 69 |
| 74 // Test various non-object literals being used as property bags. | 70 // Test various non-object literals being used as property bags. |
| 75 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File"); | 71 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File"); |
| 76 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File"); | 72 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.'"); | 73 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.'"); | 74 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.'"); | 75 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.'"); | 76 shouldThrow("(new File([], 'world.html', 'abc')) instanceof window.File", "'Type
Error: Failed to construct \\'File\\': parameter 3 (\\'options\\') is not an obj
ect.'"); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 | 133 |
| 138 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in file
s. | 134 // 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"); | 135 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"); | 136 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 | 137 |
| 142 // Test passing blob parts in objects with indexed properties. | 138 // Test passing blob parts in objects with indexed properties. |
| 143 // (This depends on the bindings code handling of sequence<T>) | 139 // (This depends on the bindings code handling of sequence<T>) |
| 144 shouldBe("new File({length: 0}, 'world.txt').size", "0"); | 140 shouldBe("new File({length: 0}, 'world.txt').size", "0"); |
| 145 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); | 141 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); |
| 146 </script> | 142 </script> |
| OLD | NEW |