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

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

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

Powered by Google App Engine
This is Rietveld 408576698