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

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

Issue 1235213004: Blob/File constructors/slice method shouldn't throw on invalid types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove debugging spew Created 5 years, 5 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 | Annotate | Revision Log
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 lowercasing of type
77 shouldBeEqualToString("new File([], 'world.html', {type:'123ABCabc'}).type", "12 3abcabc");
73 78
74 // Test various non-object literals being used as property bags. 79 // Test various non-object literals being used as property bags.
75 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File"); 80 shouldBeTrue("(new File([], 'world.html', null)) instanceof window.File");
76 shouldBeTrue("(new File([], 'world.html', undefined)) instanceof window.File"); 81 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.'"); 82 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.'"); 83 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.'"); 84 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.'"); 85 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"); 86 shouldBeTrue("(new File([], 'world.html', [])) instanceof window.File");
82 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File"); 87 shouldBeTrue("(new File([], 'world.html', /abc/)) instanceof window.File");
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 142
138 // Test building Blobs with ArrayBuffer / ArrayBufferView parts enclosed in file s. 143 // 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"); 144 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"); 145 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 146
142 // Test passing blob parts in objects with indexed properties. 147 // Test passing blob parts in objects with indexed properties.
143 // (This depends on the bindings code handling of sequence<T>) 148 // (This depends on the bindings code handling of sequence<T>)
144 shouldBe("new File({length: 0}, 'world.txt').size", "0"); 149 shouldBe("new File({length: 0}, 'world.txt').size", "0");
145 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6"); 150 shouldBe("new File({length: 1, 0: 'string'}, 'world.txt').size", "6");
146 </script> 151 </script>
OLDNEW
« no previous file with comments | « LayoutTests/fast/files/blob-constructor-expected.txt ('k') | LayoutTests/fast/files/file-constructor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698