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

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

Issue 1362963003: Blob/File constructors/slice method shouldn't throw on invalid types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated win expectation Created 3 years, 9 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 Blob constructor."); 5 description("Test the Blob constructor.");
6 var jsTestIsAsync = true; 6 var jsTestIsAsync = true;
7 7
8 // Test the different ways you can construct a Blob. 8 // Test the different ways you can construct a Blob.
9 shouldBeTrue("(new Blob()) instanceof window.Blob"); 9 shouldBeTrue("(new Blob()) instanceof window.Blob");
10 shouldBeTrue("(new Blob(undefined)) instanceof window.Blob"); 10 shouldBeTrue("(new Blob(undefined)) instanceof window.Blob");
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 shouldBe("(new Blob([toStringingObj])).size", "8"); 43 shouldBe("(new Blob([toStringingObj])).size", "8");
44 44
45 var throwingObj = { toString: function() { throw "Error"; } }; 45 var throwingObj = { toString: function() { throw "Error"; } };
46 shouldThrow("new Blob([throwingObj])", "'Error'"); 46 shouldThrow("new Blob([throwingObj])", "'Error'");
47 47
48 // Test some invalid property bags. 48 // Test some invalid property bags.
49 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys 49 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys
50 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to con struct \\'Blob\\': The provided value \\'illegalValue\\' is not a valid enum val ue of type NormalizeLineEndings.'"); 50 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to con struct \\'Blob\\': The provided value \\'illegalValue\\' is not a valid enum val ue of type NormalizeLineEndings.'");
51 shouldThrow("new Blob([], {endings:throwingObj})", "'Error'"); 51 shouldThrow("new Blob([], {endings:throwingObj})", "'Error'");
52 shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); 52 shouldThrow("new Blob([], {type:throwingObj})", "'Error'");
53 shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to const ruct \\'Blob\\': The \\'type\\' property must consist of ASCII characters.'");
54 53
55 // Test that order of property bag evaluation is lexigraphical 54 // Test that order of property bag evaluation is lexigraphical
56 var throwingObj1 = { toString: function() { throw "Error 1"; } }; 55 var throwingObj1 = { toString: function() { throw "Error 1"; } };
57 var throwingObj2 = { toString: function() { throw "Error 2"; } }; 56 var throwingObj2 = { toString: function() { throw "Error 2"; } };
58 shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1 '"); 57 shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1 '");
59 shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1 '"); 58 shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1 '");
60 shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The provided value \\'illegal\\' is not a valid enum value of type NormalizeLineEndings.'"); 59 shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The provided value \\'illegal\\' is not a valid enum value of type NormalizeLineEndings.'");
61 60
61 // Test non-ASCII type handling
62 shouldBeEqualToString("new Blob([], {type:'hello\\u00EE'}).type", "");
63
64 // Test non-printable-ASCII type handling
65 shouldBeEqualToString("new Blob([], {type:'hello\\u001F'}).type", "");
66 shouldBeEqualToString("new Blob([], {type:'hello\\u007F'}).type", "");
67
68 // Test lowercasing of type
69 shouldBeEqualToString("new Blob([], {type:'ABC/abc'}).type", "abc/abc");
70
71 // Test non-parsable type
72 shouldBeEqualToString("new Blob([], {type:'123ABCabc'}).type", "123abcabc");
73
62 // Test various non-object literals being used as property bags. 74 // Test various non-object literals being used as property bags.
63 shouldBeTrue("(new Blob([], null)) instanceof window.Blob"); 75 shouldBeTrue("(new Blob([], null)) instanceof window.Blob");
64 shouldBeTrue("(new Blob([], undefined)) instanceof window.Blob"); 76 shouldBeTrue("(new Blob([], undefined)) instanceof window.Blob");
65 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); 77 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'");
66 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); 78 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'");
67 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); 79 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'");
68 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'"); 80 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': parameter 2 (\\'options\\') is not an object.'");
69 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); 81 shouldBeTrue("(new Blob([], [])) instanceof window.Blob");
70 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); 82 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob");
71 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob"); 83 shouldBeTrue("(new Blob([], function () {})) instanceof window.Blob");
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 reader = new FileReader(); 150 reader = new FileReader();
139 reader.readAsText(new Blob([CONTAINS_UNPAIRED_SURROGATES])); 151 reader.readAsText(new Blob([CONTAINS_UNPAIRED_SURROGATES]));
140 reader.onload = function() { 152 reader.onload = function() {
141 shouldBe("reader.result.charCodeAt(3)", "0xFFFD"); 153 shouldBe("reader.result.charCodeAt(3)", "0xFFFD");
142 shouldBe("reader.result.charCodeAt(7)", "0xFFFD"); 154 shouldBe("reader.result.charCodeAt(7)", "0xFFFD");
143 finishJSTest(); 155 finishJSTest();
144 }; 156 };
145 } 157 }
146 158
147 </script> 159 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698