| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File"); | 80 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File"); |
| 81 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); | 81 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); |
| 82 shouldBeTrue("(new File([], 'world.html', function () {})) instanceof window.Fil
e"); | 82 shouldBeTrue("(new File([], 'world.html', function () {})) instanceof window.Fil
e"); |
| 83 | 83 |
| 84 // Test that the name/type/size are correctly added to the File. | 84 // Test that the name/type/size are correctly added to the File. |
| 85 shouldBe("(new File([], 'world.html', {type:'text/html'})).name", "'world.html'"
); | 85 shouldBe("(new File([], 'world.html', {type:'text/html'})).name", "'world.html'"
); |
| 86 shouldBe("(new File([], 'world.html', {type:'text/html'})).type", "'text/html'")
; | 86 shouldBe("(new File([], 'world.html', {type:'text/html'})).type", "'text/html'")
; |
| 87 shouldBe("(new File([], 'world.html', {type:'text/html'})).size", "0"); | 87 shouldBe("(new File([], 'world.html', {type:'text/html'})).size", "0"); |
| 88 shouldBe("(new File([], 'world.html', {type:'text/plain;charset=UTF-8'})).type",
"'text/plain;charset=utf-8'"); | 88 shouldBe("(new File([], 'world.html', {type:'text/plain;charset=UTF-8'})).type",
"'text/plain;charset=utf-8'"); |
| 89 | 89 |
| 90 // Test that the lastModified is correctly added to the File. |
| 91 var aDate = new Date(441532800000); |
| 92 shouldBe("(new File([], 'world.html', {lastModified: 441532800000})).lastModifie
d", "441532800000"); |
| 93 // Unless specified, lastModified should default to now. |
| 94 shouldBeNow("(new File([], 'world.html')).lastModified", 20000); |
| 95 shouldBeNow("(new File([], 'world.html', {})).lastModified", 20000); |
| 96 shouldBeNow("(new File([], 'world.html', {type: 'text/plain'})).lastModified", 2
0000); |
| 97 // Test that Date instances are implicitly converted to numbers. |
| 98 shouldBe("(new File([], 'world.html', {lastModified: new Date(441532800000)})).l
astModified", "441532800000"); |
| 99 |
| 100 // Test the deprecated attribute lastModifiedDate. |
| 101 shouldBeTrue("(new File([], 'world.html', {lastModified: 441532800000})).lastMod
ifiedDate instanceof Date"); |
| 102 shouldBe("(new File([], 'world.html', {lastModified: 441532800000})).lastModifie
dDate.valueOf()", "441532800000"); |
| 103 |
| 90 // Test the number of expected arguments in the File constructor. | 104 // Test the number of expected arguments in the File constructor. |
| 91 shouldBe("window.File.length", "2"); | 105 shouldBe("window.File.length", "2"); |
| 92 | 106 |
| 93 // Test ArrayBufferView parameters. | 107 // Test ArrayBufferView parameters. |
| 94 shouldBe("new File([new DataView(new ArrayBuffer(100))], 'world.html').size", "1
00"); | 108 shouldBe("new File([new DataView(new ArrayBuffer(100))], 'world.html').size", "1
00"); |
| 95 shouldBe("new File([new Uint8Array(100)], 'world.html').size", "100"); | 109 shouldBe("new File([new Uint8Array(100)], 'world.html').size", "100"); |
| 96 shouldBe("new File([new Uint8ClampedArray(100)], 'world.html').size", "100"); | 110 shouldBe("new File([new Uint8ClampedArray(100)], 'world.html').size", "100"); |
| 97 shouldBe("new File([new Uint16Array(100)], 'world.html').size", "200"); | 111 shouldBe("new File([new Uint16Array(100)], 'world.html').size", "200"); |
| 98 shouldBe("new File([new Uint32Array(100)], 'world.html').size", "400"); | 112 shouldBe("new File([new Uint32Array(100)], 'world.html').size", "400"); |
| 99 shouldBe("new File([new Int8Array(100)], 'world.html').size", "100"); | 113 shouldBe("new File([new Int8Array(100)], 'world.html').size", "100"); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 Object.defineProperty(throwingSequence, "1", { | 151 Object.defineProperty(throwingSequence, "1", { |
| 138 get: function() { throw new Error("Misbehaving property"); }, | 152 get: function() { throw new Error("Misbehaving property"); }, |
| 139 enumerable: true, configurable: true | 153 enumerable: true, configurable: true |
| 140 }); | 154 }); |
| 141 Object.defineProperty(throwingSequence, "2", { | 155 Object.defineProperty(throwingSequence, "2", { |
| 142 get: function() { throw new Error("This should not be thrown"); }, | 156 get: function() { throw new Error("This should not be thrown"); }, |
| 143 enumerable: true, configurable: true | 157 enumerable: true, configurable: true |
| 144 }); | 158 }); |
| 145 shouldThrow("new File(throwingSequence, 'world.txt')", "'Error: Misbehaving prop
erty'"); | 159 shouldThrow("new File(throwingSequence, 'world.txt')", "'Error: Misbehaving prop
erty'"); |
| 146 </script> | 160 </script> |
| OLD | NEW |