Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/files/file-constructor.html

Issue 1526183004: Prevent SharedArrayBuffer views from being used in bindings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 shouldBe("new File([new Uint32Array(100)], 'world.html').size", "400"); 113 shouldBe("new File([new Uint32Array(100)], 'world.html').size", "400");
114 shouldBe("new File([new Int8Array(100)], 'world.html').size", "100"); 114 shouldBe("new File([new Int8Array(100)], 'world.html').size", "100");
115 shouldBe("new File([new Int16Array(100)], 'world.html').size", "200"); 115 shouldBe("new File([new Int16Array(100)], 'world.html').size", "200");
116 shouldBe("new File([new Int32Array(100)], 'world.html').size", "400"); 116 shouldBe("new File([new Int32Array(100)], 'world.html').size", "400");
117 shouldBe("new File([new Float32Array(100)], 'world.html').size", "400"); 117 shouldBe("new File([new Float32Array(100)], 'world.html').size", "400");
118 shouldBe("new File([new Float64Array(100)], 'world.html').size", "800"); 118 shouldBe("new File([new Float64Array(100)], 'world.html').size", "800");
119 shouldBe("new File([new Float64Array(100), new Int32Array(100), new Uint8Array(1 00), new DataView(new ArrayBuffer(100))], 'world.html').size", "1400"); 119 shouldBe("new File([new Float64Array(100), new Int32Array(100), new Uint8Array(1 00), new DataView(new ArrayBuffer(100))], 'world.html').size", "1400");
120 shouldBe("new File([new Blob([new Int32Array(100)]), new Uint8Array(100), new Fl oat32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1000 "); 120 shouldBe("new File([new Blob([new Int32Array(100)]), new Uint8Array(100), new Fl oat32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1000 ");
121 shouldBe("new File([new Blob([new Int32Array(100)]), new File([new Uint16Array(1 00)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1200"); 121 shouldBe("new File([new Blob([new Int32Array(100)]), new File([new Uint16Array(1 00)], 'world.txt'), new Uint8Array(100), new Float32Array(100), new DataView(new ArrayBuffer(100))], 'world.html').size", "1200");
122 122
123 // Test SharedArrayBuffer view parameters.
124 if (window.internals && internals.runtimeFlags.sharedArrayBufferEnabled && windo w.SharedArrayBuffer) {
125 shouldThrow("new File([new Uint8Array(new SharedArrayBuffer(100))], 'world.htm l')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
126 shouldThrow("new File([new Uint8ClampedArray(new SharedArrayBuffer(100))], 'wo rld.html')", '"TypeError: Failed to construct \'File\': sequence parameter 1 con tains a view of a SharedArrayBuffer."');
127 shouldThrow("new File([new Uint16Array(new SharedArrayBuffer(100))], 'world.ht ml')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
128 shouldThrow("new File([new Uint32Array(new SharedArrayBuffer(100))], 'world.ht ml')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
129 shouldThrow("new File([new Int8Array(new SharedArrayBuffer(100))], 'world.html ')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
130 shouldThrow("new File([new Int16Array(new SharedArrayBuffer(100))], 'world.htm l')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
131 shouldThrow("new File([new Int32Array(new SharedArrayBuffer(100))], 'world.htm l')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
132 shouldThrow("new File([new Float32Array(new SharedArrayBuffer(100))], 'world.h tml')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
133 shouldThrow("new File([new Float64Array(new SharedArrayBuffer(104))], 'world.h tml')", '"TypeError: Failed to construct \'File\': sequence parameter 1 contains a view of a SharedArrayBuffer."');
134 }
135
123 // Test ArrayBuffer parameters. 136 // Test ArrayBuffer parameters.
124 shouldBe("new File([(new DataView(new ArrayBuffer(100))).buffer], 'world.html'). size", "100"); 137 shouldBe("new File([(new DataView(new ArrayBuffer(100))).buffer], 'world.html'). size", "100");
125 shouldBe("new File([(new Uint8Array(100)).buffer], 'world.html').size", "100"); 138 shouldBe("new File([(new Uint8Array(100)).buffer], 'world.html').size", "100");
126 shouldBe("new File([(new Uint8ClampedArray(100)).buffer], 'world.html').size", " 100"); 139 shouldBe("new File([(new Uint8ClampedArray(100)).buffer], 'world.html').size", " 100");
127 shouldBe("new File([(new Uint16Array(100)).buffer], 'world.html').size", "200"); 140 shouldBe("new File([(new Uint16Array(100)).buffer], 'world.html').size", "200");
128 shouldBe("new File([(new Uint32Array(100)).buffer], 'world.html').size", "400"); 141 shouldBe("new File([(new Uint32Array(100)).buffer], 'world.html').size", "400");
129 shouldBe("new File([(new Int8Array(100)).buffer], 'world.html').size", "100"); 142 shouldBe("new File([(new Int8Array(100)).buffer], 'world.html').size", "100");
130 shouldBe("new File([(new Int16Array(100)).buffer], 'world.html').size", "200"); 143 shouldBe("new File([(new Int16Array(100)).buffer], 'world.html').size", "200");
131 shouldBe("new File([(new Int32Array(100)).buffer], 'world.html').size", "400"); 144 shouldBe("new File([(new Int32Array(100)).buffer], 'world.html').size", "400");
132 shouldBe("new File([(new Float32Array(100)).buffer], 'world.html').size", "400") ; 145 shouldBe("new File([(new Float32Array(100)).buffer], 'world.html').size", "400") ;
133 shouldBe("new File([(new Float64Array(100)).buffer], 'world.html').size", "800") ; 146 shouldBe("new File([(new Float64Array(100)).buffer], 'world.html').size", "800") ;
134 shouldBe("new File([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer , (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'w orld.html').size", "1400"); 147 shouldBe("new File([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer , (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer], 'w orld.html').size", "1400");
135 shouldBe("new File([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10 0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))) .buffer], 'world.html').size", "1000"); 148 shouldBe("new File([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10 0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))) .buffer], 'world.html').size", "1000");
136 shouldBe("new File([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], 'world.html').si ze", "1200"); 149 shouldBe("new File([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], 'world.html').si ze", "1200");
137 150
138 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in file s. 151 // 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"); 152 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"); 153 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 154
142 // Test passing blob parts in objects with indexed properties. 155 // Test passing blob parts in objects with indexed properties.
143 // (This depends on the bindings code handling of sequence<T>) 156 // (This depends on the bindings code handling of sequence<T>)
144 shouldBe("new File({length: 0}, 'world.txt').size", "0"); 157 shouldBe("new File({length: 0}, 'world.txt').size", "0");
145 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); 158 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6");
146 </script> 159 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698