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

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

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

Powered by Google App Engine
This is Rietveld 408576698