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

Side by Side Diff: LayoutTests/fast/storage/serialized-script-value.html

Issue 23992003: blob hacking webcore style (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 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 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../js/resources/js-test-pre.js"></script> 3 <script src="../js/resources/js-test-pre.js"></script>
4 <script src="../storage/resources/serialized-script-value.js"></script> 4 <script src="../storage/resources/serialized-script-value.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <script> 7 <script>
8 8
9 function testSerialization(obj, values, oldFormat, serializeExceptionValue) { 9 function testSerialization(obj, values, oldFormat, serializeExceptionValue) {
10 _testSerialization(2, obj, values, oldFormat, serializeExceptionValue); 10 _testSerialization(2, obj, values, oldFormat, serializeExceptionValue);
11 } 11 }
12 12
13 // we only test a few cases of the "old" serialization format because 13 // we only test a few cases of the "old" serialization format because
14 // that is all that was left around from previous tests. Those values 14 // that is all that was left around from previous tests. Those values
15 // are only persisted out in the world in IndexedDB stores that were 15 // are only persisted out in the world in IndexedDB stores that were
16 // written with implementations built before mid-2011. 16 // written with implementations built before mid-2011.
17 testSerialization({foo: 'zoo', bar: {baz: 'myNewKey'}}, 17 testSerialization({foo: 'zoo', bar: {baz: 'myNewKey'}},
18 [ 0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 18 [ 0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6603,
19 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, 19 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f,
20 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f, 20 0x5301, 0x6203, 0x7261, 0x013f, 0x3f6f,
21 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853, 21 0x5302, 0x6203, 0x7a61, 0x023f, 0x0853,
22 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b, 22 0x796d, 0x654e, 0x4b77, 0x7965, 0x017b,
23 0x027b ]); 23 0x027b ]);
24 24
25 testSerialization({foo: 'zoo', bar: 'myNewKey'}, 25 testSerialization({foo: 'zoo', bar: 'myNewKey'},
26 [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 26 [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6603,
27 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f, 27 0x6f6f, 0x013f, 0x0353, 0x6f7a, 0x3f6f,
28 0x5301, 0x6203, 0x7261, 0x013f, 0x0853, 28 0x5301, 0x6203, 0x7261, 0x013f, 0x0853,
29 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b]); 29 0x796d, 0x654e, 0x4b77, 0x7965, 0x027b]);
30 30
31 testSerialization([], [0x02ff, 0x003f, 0x0041, 0x0024, 0x0000 ]); 31 testSerialization([], [0x03ff, 0x003f, 0x0041, 0x0024, 0x0000 ]);
32 testSerialization({foo: "zoo"}, 32 testSerialization({foo: "zoo"},
33 [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 0x6f6f, 33 [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 0x6f6f,
34 0x013f, 0x0353, 0x6f7a, 0x7b6f, 0x0001], 34 0x013f, 0x0353, 0x6f7a, 0x7b6f, 0x0001],
35 [0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x017b]); 35 [0x0353, 0x6f66, 0x536f, 0x7a03, 0x6f6f, 0x017b]);
36 testSerialization({foo: null}, 36 testSerialization({foo: null},
37 [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 0x6f6f, 37 [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6603, 0x6f6f,
38 0x013f, 0x7b30, 0x0001], 38 0x013f, 0x7b30, 0x0001],
39 [0x0353, 0x6f66, 0x306f, 0x017b]); 39 [0x0353, 0x6f66, 0x306f, 0x017b]);
40 testSerialization({}, [0x02ff, 0x003f, 0x7b6f, 0x0000], [0x007b]); 40 testSerialization({}, [0x03ff, 0x003f, 0x7b6f, 0x0000], [0x007b]);
41 41
42 testSerialization(undefined, [0x02ff, 0x003f, 0x005f]); 42 testSerialization(undefined, [0x03ff, 0x003f, 0x005f]);
43 testSerialization(true, [0x02ff, 0x003f, 0x0054]); 43 testSerialization(true, [0x03ff, 0x003f, 0x0054]);
44 testSerialization(false, [0x02ff, 0x003f, 0x0046]); 44 testSerialization(false, [0x03ff, 0x003f, 0x0046]);
45 // Sparse array deserialization is broken. 45 // Sparse array deserialization is broken.
46 // See: https://bugs.webkit.org/show_bug.cgi?id=96838 46 // See: https://bugs.webkit.org/show_bug.cgi?id=96838
47 // testSerialization(new Array(100), [0x02ff, 0x003f, 0x6461, 0x0040, 0x0064]); 47 // testSerialization(new Array(100), [0x03ff, 0x003f, 0x6461, 0x0040, 0x0064]);
48 testSerialization(10, [0x02ff, 0x003f, 0x1449]); 48 testSerialization(10, [0x03ff, 0x003f, 0x1449]);
49 testSerialization(-10, [0x02ff, 0x003f, 0x1349]); 49 testSerialization(-10, [0x03ff, 0x003f, 0x1349]);
50 testSerialization(Math.pow(2,30), [0x02ff, 0x003f, 0x8049, 0x8080, 0x0880]); 50 testSerialization(Math.pow(2,30), [0x03ff, 0x003f, 0x8049, 0x8080, 0x0880]);
51 testSerialization(Math.pow(2,55), [0x02ff, 0x003f, 0x004e, 0x0000, 0x0000, 51 testSerialization(Math.pow(2,55), [0x03ff, 0x003f, 0x004e, 0x0000, 0x0000,
52 0x6000, 0x0043]); 52 0x6000, 0x0043]);
53 testSerialization(1.23, [0x02ff, 0x003f, 0xae4e, 0xe147, 0x147a, 0xf3ae, 0x003f] ); 53 testSerialization(1.23, [0x03ff, 0x003f, 0xae4e, 0xe147, 0x147a, 0xf3ae, 0x003f] );
54 54
55 // Exercise special cases for Int32/Uint32. 55 // Exercise special cases for Int32/Uint32.
56 testSerialization( 0x7fffffff, [0x02ff, 0x003f, 0xfe49, 0xffff, 0x0fff]); 56 testSerialization( 0x7fffffff, [0x03ff, 0x003f, 0xfe49, 0xffff, 0x0fff]);
57 testSerialization(-0x80000000, [0x02ff, 0x003f, 0xff49, 0xffff, 0x0fff]); 57 testSerialization(-0x80000000, [0x03ff, 0x003f, 0xff49, 0xffff, 0x0fff]);
58 testSerialization( 0x80000000, [0x02ff, 0x003f, 0x8055, 0x8080, 0x0880]); 58 testSerialization( 0x80000000, [0x03ff, 0x003f, 0x8055, 0x8080, 0x0880]);
59 testSerialization( 0xffffffff, [0x02ff, 0x003f, 0xff55, 0xffff, 0x0fff]); 59 testSerialization( 0xffffffff, [0x03ff, 0x003f, 0xff55, 0xffff, 0x0fff]);
60 60
61 testSerialization("", [0x02ff, 0x003f, 0x0053]); 61 testSerialization("", [0x03ff, 0x003f, 0x0053]);
62 testSerialization("abc", [0x02ff, 0x003f, 0x0353, 0x6261, 0x0063]); 62 testSerialization("abc", [0x03ff, 0x003f, 0x0353, 0x6261, 0x0063]);
63 testSerialization({integer: 123}, [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6907, 63 testSerialization({integer: 123}, [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6907,
64 0x746e, 0x6765, 0x7265, 0x013f, 0xf649, 64 0x746e, 0x6765, 0x7265, 0x013f, 0xf649,
65 0x7b01, 0x0001]); 65 0x7b01, 0x0001]);
66 testSerialization({string: "str"}, [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x7306, 66 testSerialization({string: "str"}, [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x7306,
67 0x7274, 0x6e69, 0x3f67, 0x5301, 0x7303, 67 0x7274, 0x6e69, 0x3f67, 0x5301, 0x7303,
68 0x7274, 0x017b]); 68 0x7274, 0x017b]);
69 testSerialization({list: [1,2,3]}, [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6c04, 69 testSerialization({list: [1,2,3]}, [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6c04,
70 0x7369, 0x3f74, 0x4101, 0x3f03, 0x4902, 70 0x7369, 0x3f74, 0x4101, 0x3f03, 0x4902,
71 0x3f02, 0x4902, 0x3f04, 0x4902, 0x2406, 71 0x3f02, 0x4902, 0x3f04, 0x4902, 0x2406,
72 0x0300, 0x017b]); 72 0x0300, 0x017b]);
73 testSerialization(null, [0x02ff, 0x003f, 0x0030]); 73 testSerialization(null, [0x03ff, 0x003f, 0x0030]);
74 testSerialization(/abc/, [0x02ff, 0x003f, 0x0352, 0x6261, 0x0063]); 74 testSerialization(/abc/, [0x03ff, 0x003f, 0x0352, 0x6261, 0x0063]);
75 75
76 var innerObject = {hello: "there"}; 76 var innerObject = {hello: "there"};
77 var outerObject = {inner: innerObject}; 77 var outerObject = {inner: innerObject};
78 outerObject['outer'] = innerObject; 78 outerObject['outer'] = innerObject;
79 testSerialization(outerObject, [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6905, 79 testSerialization(outerObject, [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6905,
80 0x6e6e, 0x7265, 0x013f, 0x3f6f, 0x5302, 80 0x6e6e, 0x7265, 0x013f, 0x3f6f, 0x5302,
81 0x6805, 0x6c65, 0x6f6c, 0x023f, 0x0553, 81 0x6805, 0x6c65, 0x6f6c, 0x023f, 0x0553,
82 0x6874, 0x7265, 0x7b65, 0x3f01, 0x5302, 82 0x6874, 0x7265, 0x7b65, 0x3f01, 0x5302,
83 0x6f05, 0x7475, 0x7265, 0x023f, 0x015e, 83 0x6f05, 0x7475, 0x7265, 0x023f, 0x015e,
84 0x027b]); 84 0x027b]);
85 testSerialization(innerObject, [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6805, 85 testSerialization(innerObject, [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6805,
86 0x6c65, 0x6f6c, 0x013f, 0x0553, 0x6874, 86 0x6c65, 0x6f6c, 0x013f, 0x0553, 0x6874,
87 0x7265, 0x7b65, 0x0001]); 87 0x7265, 0x7b65, 0x0001]);
88 88
89 var unicodeObject = {a: 'a', u: String.fromCharCode(0x03B1,0x03B2), d: 42}; 89 var unicodeObject = {a: 'a', u: String.fromCharCode(0x03B1,0x03B2), d: 42};
90 testSerialization(unicodeObject, 90 testSerialization(unicodeObject,
91 [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6101, 91 [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6101,
92 0x013f, 0x0153, 0x3f61, 0x5301, 0x7501, 92 0x013f, 0x0153, 0x3f61, 0x5301, 0x7501,
93 0x013f, 0x0463, 0x03b1, 0x03b2, 0x013f, 93 0x013f, 0x0463, 0x03b1, 0x03b2, 0x013f,
94 0x0153, 0x3f64, 0x4901, 0x7b54, 0x0003], 94 0x0153, 0x3f64, 0x4901, 0x7b54, 0x0003],
95 [0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6101, 95 [0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6101,
96 0x013f, 0x0153, 0x3f61, 0x5301, 0x7501, 96 0x013f, 0x0153, 0x3f61, 0x5301, 0x7501,
97 0x013f, 0x0453, 0xb1ce, 0xb2ce, 0x013f, 97 0x013f, 0x0453, 0xb1ce, 0xb2ce, 0x013f,
98 0x0153, 0x3f64, 0x4901, 0x7b54, 0x0003]); 98 0x0153, 0x3f64, 0x4901, 0x7b54, 0x0003]);
99 unicodeObject.a = 'ab'; 99 unicodeObject.a = 'ab';
100 testSerialization(unicodeObject, 100 testSerialization(unicodeObject,
101 [0x02ff, 0x003f, 0x3f6f, 0x5301, 0x6101, 101 [0x03ff, 0x003f, 0x3f6f, 0x5301, 0x6101,
102 0x013f, 0x0253, 0x6261, 0x013f, 0x0153, 102 0x013f, 0x0253, 0x6261, 0x013f, 0x0153,
103 0x3f75, 0x0001, 0x0463, 0x03b1, 0x03b2, 103 0x3f75, 0x0001, 0x0463, 0x03b1, 0x03b2,
104 0x013f, 0x0153, 0x3f64, 0x4901, 0x7b54, 104 0x013f, 0x0153, 0x3f64, 0x4901, 0x7b54,
105 0x0003], 105 0x0003],
106 [0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6101, 106 [0x01ff, 0x003f, 0x3f6f, 0x5301, 0x6101,
107 0x013f, 0x0253, 0x6261, 0x013f, 0x0153, 107 0x013f, 0x0253, 0x6261, 0x013f, 0x0153,
108 0x3f75, 0x5301, 0xce04, 0xceb1, 0x3fb2, 108 0x3f75, 0x5301, 0xce04, 0xceb1, 0x3fb2,
109 0x5301, 0x6401, 0x013f, 0x5449, 0x037b]); 109 0x5301, 0x6401, 0x013f, 0x5449, 0x037b]);
110 110
111 var arrayObject = []; 111 var arrayObject = [];
112 arrayObject['a'] = true; 112 arrayObject['a'] = true;
113 arrayObject['b'] = false; 113 arrayObject['b'] = false;
114 arrayObject['foo'] = 123; 114 arrayObject['foo'] = 123;
115 arrayObject['bar'] = 456; 115 arrayObject['bar'] = 456;
116 arrayObject[''] = null; 116 arrayObject[''] = null;
117 testSerialization(arrayObject, 117 testSerialization(arrayObject,
118 [0x02ff, 0x003f, 0x0041, 0x013f, 0x0153, 118 [0x03ff, 0x003f, 0x0041, 0x013f, 0x0153,
119 0x3f61, 0x5401, 0x013f, 0x0153, 0x3f62, 119 0x3f61, 0x5401, 0x013f, 0x0153, 0x3f62,
120 0x4601, 0x013f, 0x0353, 0x6f66, 0x3f6f, 120 0x4601, 0x013f, 0x0353, 0x6f66, 0x3f6f,
121 0x4901, 0x01f6, 0x013f, 0x0353, 0x6162, 121 0x4901, 0x01f6, 0x013f, 0x0353, 0x6162,
122 0x3f72, 0x4901, 0x0790, 0x013f, 0x0053, 122 0x3f72, 0x4901, 0x0790, 0x013f, 0x0053,
123 0x013f, 0x2430, 0x0005], 123 0x013f, 0x2430, 0x0005],
124 [0x01ff, 0x003f, 0x0041, 0x013f, 0x0153, 124 [0x02ff, 0x003f, 0x0041, 0x013f, 0x0153, // deserialize from v 2
125 0x3f61, 0x5401, 0x013f, 0x0153, 0x3f62, 125 0x3f61, 0x5401, 0x013f, 0x0153, 0x3f62,
126 0x4601, 0x013f, 0x0353, 0x6f66, 0x3f6f, 126 0x4601, 0x013f, 0x0353, 0x6f66, 0x3f6f,
127 0x4901, 0x01f6, 0x013f, 0x0353, 0x6162, 127 0x4901, 0x01f6, 0x013f, 0x0353, 0x6162,
128 0x3f72, 0x4901, 0x0790, 0x013f, 0x0053, 128 0x3f72, 0x4901, 0x0790, 0x013f, 0x0053,
129 0x013f, 0x2430, 0x0005]); 129 0x013f, 0x2430, 0x0005]);
130 130
131 arrayObject[0] = 'foo'; 131 arrayObject[0] = 'foo';
132 arrayObject[1] = 'bar'; 132 arrayObject[1] = 'bar';
133 testSerialization(arrayObject, 133 testSerialization(arrayObject,
134 [0x02ff, 0x003f, 0x0241, 0x013f, 0x0353, 134 [0x03ff, 0x003f, 0x0241, 0x013f, 0x0353,
135 0x6f66, 0x3f6f, 0x5301, 0x6203, 0x7261, 135 0x6f66, 0x3f6f, 0x5301, 0x6203, 0x7261,
136 0x013f, 0x0153, 0x3f61, 0x5401, 0x013f, 136 0x013f, 0x0153, 0x3f61, 0x5401, 0x013f,
137 0x0153, 0x3f62, 0x4601, 0x013f, 0x0353, 137 0x0153, 0x3f62, 0x4601, 0x013f, 0x0353,
138 0x6f66, 0x3f6f, 0x4901, 0x01f6, 0x013f, 138 0x6f66, 0x3f6f, 0x4901, 0x01f6, 0x013f,
139 0x0353, 0x6162, 0x3f72, 0x4901, 0x0790, 139 0x0353, 0x6162, 0x3f72, 0x4901, 0x0790,
140 0x013f, 0x0053, 0x013f, 0x2430, 0x0205], 140 0x013f, 0x0053, 0x013f, 0x2430, 0x0205],
141 [0x01ff, 0x003f, 0x0241, 0x013f, 0x0353, 141 [0x01ff, 0x003f, 0x0241, 0x013f, 0x0353,
142 0x6f66, 0x3f6f, 0x5301, 0x6203, 0x7261, 142 0x6f66, 0x3f6f, 0x5301, 0x6203, 0x7261,
143 0x013f, 0x0153, 0x3f61, 0x5401, 0x013f, 143 0x013f, 0x0153, 0x3f61, 0x5401, 0x013f,
144 0x0153, 0x3f62, 0x4601, 0x013f, 0x0353, 144 0x0153, 0x3f62, 0x4601, 0x013f, 0x0353,
145 0x6f66, 0x3f6f, 0x4901, 0x01f6, 0x013f, 145 0x6f66, 0x3f6f, 0x4901, 0x01f6, 0x013f,
146 0x0353, 0x6162, 0x3f72, 0x4901, 0x0790, 146 0x0353, 0x6162, 0x3f72, 0x4901, 0x0790,
147 0x013f, 0x0053, 0x013f, 0x2430, 0x0205]); 147 0x013f, 0x0053, 0x013f, 0x2430, 0x0205]);
148 148
149 testSerialization(function(){}, [], null, DOMException.DATA_CLONE_ERR); 149 testSerialization(function(){}, [], null, DOMException.DATA_CLONE_ERR);
150
151 testBlobSerialization();
152
150 </script> 153 </script>
151 <script src="../js/resources/js-test-post.js"></script> 154 <script src="../js/resources/js-test-post.js"></script>
152 </body> 155 </body>
153 </html> 156 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698