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

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

Issue 111373003: Migrate bindings constructors to the new ExceptionState model. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Ugh. Created 7 years 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 Blob constructor."); 5 description("Test the Blob constructor.");
6 6
7 // Test the different ways you can construct a Blob. 7 // Test the different ways you can construct a Blob.
8 shouldBeTrue("(new Blob()) instanceof window.Blob"); 8 shouldBeTrue("(new Blob()) instanceof window.Blob");
9 shouldBeTrue("(new Blob([])) instanceof window.Blob"); 9 shouldBeTrue("(new Blob([])) instanceof window.Blob");
10 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob"); 10 shouldBeTrue("(new Blob(['hello'])) instanceof window.Blob");
(...skipping 20 matching lines...) Expand all
31 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st ring "[object HTMLDocument]" 31 shouldBe("(new Blob([document])).size", "21"); // document.toString() is the st ring "[object HTMLDocument]"
32 32
33 var toStringingObj = { toString: function() { return "A string"; } }; 33 var toStringingObj = { toString: function() { return "A string"; } };
34 shouldBe("(new Blob([toStringingObj])).size", "8"); 34 shouldBe("(new Blob([toStringingObj])).size", "8");
35 35
36 var throwingObj = { toString: function() { throw "Error"; } }; 36 var throwingObj = { toString: function() { throw "Error"; } };
37 shouldThrow("new Blob([throwingObj])", "'Error'"); 37 shouldThrow("new Blob([throwingObj])", "'Error'");
38 38
39 // Test some invalid property bags. 39 // Test some invalid property bags.
40 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys 40 shouldBeTrue("(new Blob([], {unknownKey:'value'})) instanceof window.Blob"); // Ignore invalid keys
41 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to con struct \\'Blob\\': The \"endings\" property must be either \"transparent\" or \" native\".'"); 41 shouldThrow("new Blob([], {endings:'illegalValue'})", "'TypeError: Failed to con struct \\'Blob\\': The \\'endings\\' property must be either \\'transparent\\' o r \\'native\\'.'");
42 shouldThrow("new Blob([], {endings:throwingObj})", "'Error'"); 42 shouldThrow("new Blob([], {endings:throwingObj})", "'Error'");
43 shouldThrow("new Blob([], {type:throwingObj})", "'Error'"); 43 shouldThrow("new Blob([], {type:throwingObj})", "'Error'");
44 shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to const ruct \\'Blob\\': The \"type\" property must consist of ASCII characters.'"); 44 shouldThrow("new Blob([], {type:'hello\u00EE'})", "'SyntaxError: Failed to const ruct \\'Blob\\': The \\'type\\' property must consist of ASCII characters.'");
45 45
46 // Test that order of property bag evaluation is lexigraphical 46 // Test that order of property bag evaluation is lexigraphical
47 var throwingObj1 = { toString: function() { throw "Error 1"; } }; 47 var throwingObj1 = { toString: function() { throw "Error 1"; } };
48 var throwingObj2 = { toString: function() { throw "Error 2"; } }; 48 var throwingObj2 = { toString: function() { throw "Error 2"; } };
49 shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1 '"); 49 shouldThrow("new Blob([], {endings:throwingObj1, type:throwingObj2})", "'Error 1 '");
50 shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1 '"); 50 shouldThrow("new Blob([], {type:throwingObj2, endings:throwingObj1})", "'Error 1 '");
51 shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \"endings\" property must be either \"trans parent\" or \"native\".'"); 51 shouldThrow("new Blob([], {type:throwingObj2, endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \\'endings\\' property must be either \\'tr ansparent\\' or \\'native\\'.'");
52 52
53 // Test various non-object literals being used as property bags. 53 // Test various non-object literals being used as property bags.
54 shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': The 2nd argument is not of type Object.'"); 54 shouldThrow("(new Blob([], null)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': The 2nd argument is not of type Object.'");
55 shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Fai led to construct \\'Blob\\': The 2nd argument is not of type Object.'"); 55 shouldThrow("(new Blob([], undefined)) instanceof window.Blob", "'TypeError: Fai led to construct \\'Blob\\': The 2nd argument is not of type Object.'");
56 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); 56 shouldThrow("(new Blob([], 123)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'");
57 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); 57 shouldThrow("(new Blob([], 123.4)) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'");
58 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': The 2nd argument is not of type Object.'"); 58 shouldThrow("(new Blob([], true)) instanceof window.Blob", "'TypeError: Failed t o construct \\'Blob\\': The 2nd argument is not of type Object.'");
59 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'"); 59 shouldThrow("(new Blob([], 'abc')) instanceof window.Blob", "'TypeError: Failed to construct \\'Blob\\': The 2nd argument is not of type Object.'");
60 shouldBeTrue("(new Blob([], [])) instanceof window.Blob"); 60 shouldBeTrue("(new Blob([], [])) instanceof window.Blob");
61 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob"); 61 shouldBeTrue("(new Blob([], /abc/)) instanceof window.Blob");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800"); 101 shouldBe("new Blob([(new Float64Array(100)).buffer]).size", "800");
102 shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer , (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).si ze", "1400"); 102 shouldBe("new Blob([(new Float64Array(100)).buffer, (new Int32Array(100)).buffer , (new Uint8Array(100)).buffer, (new DataView(new ArrayBuffer(100))).buffer]).si ze", "1400");
103 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10 0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))) .buffer]).size", "1000"); 103 shouldBe("new Blob([new Blob([(new Int32Array(100)).buffer]), (new Uint8Array(10 0)).buffer, (new Float32Array(100)).buffer, (new DataView(new ArrayBuffer(100))) .buffer]).size", "1000");
104 104
105 // Test passing blob parts in sequences. 105 // Test passing blob parts in sequences.
106 shouldBeTrue("new Blob({length: 0}) instanceof window.Blob"); 106 shouldBeTrue("new Blob({length: 0}) instanceof window.Blob");
107 shouldBe("new Blob({length: 0}).size", "0"); 107 shouldBe("new Blob({length: 0}).size", "0");
108 shouldBe("new Blob({length: 1, 0: 'string'}).size", "6"); 108 shouldBe("new Blob({length: 1, 0: 'string'}).size", "6");
109 shouldBe("new Blob({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}). size", "300"); 109 shouldBe("new Blob({length: 2, 0: new Uint8Array(100), 1: new Int16Array(100)}). size", "300");
110 shouldBe("new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type", "'text/ html'"); 110 shouldBe("new Blob({length: 1, 0: 'string'}, {type: 'text/html'}).type", "'text/ html'");
111 shouldThrow("new Blob({length: 0}, {endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \"endings\" property must be either \"transparent\" o r \"native\".'"); 111 shouldThrow("new Blob({length: 0}, {endings:'illegal'})", "'TypeError: Failed to construct \\'Blob\\': The \\'endings\\' property must be either \\'transparent\ \' or \\'native\\'.'");
112 112
113 // Test passing blog parts in a sequence-like object that throws on property acc ess. 113 // Test passing blog parts in a sequence-like object that throws on property acc ess.
114 var throwingSequence = {length: 4, 0: 'hello', 3: 'world'}; 114 var throwingSequence = {length: 4, 0: 'hello', 3: 'world'};
115 Object.defineProperty(throwingSequence, "1", { 115 Object.defineProperty(throwingSequence, "1", {
116 get: function() { throw new Error("Misbehaving property"); }, 116 get: function() { throw new Error("Misbehaving property"); },
117 enumerable: true, configurable: true 117 enumerable: true, configurable: true
118 }); 118 });
119 Object.defineProperty(throwingSequence, "2", { 119 Object.defineProperty(throwingSequence, "2", {
120 get: function() { throw new Error("This should not be thrown"); }, 120 get: function() { throw new Error("This should not be thrown"); },
121 enumerable: true, configurable: true 121 enumerable: true, configurable: true
122 }); 122 });
123 shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'"); 123 shouldThrow("new Blob(throwingSequence)", "'Error: Misbehaving property'");
124 </script> 124 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698