OLD | NEW |
---|---|
1 document.getElementById("description").innerHTML = "Tests that we clone object h ierarchies"; | 1 document.getElementById("description").innerHTML = "Tests that we clone object h ierarchies"; |
2 | 2 |
3 tryPostMessage('null'); | 3 tryPostMessage('null'); |
4 tryPostMessage('undefined'); | 4 tryPostMessage('undefined'); |
5 tryPostMessage('1'); | 5 tryPostMessage('1'); |
6 tryPostMessage('true'); | 6 tryPostMessage('true'); |
7 tryPostMessage('"1"'); | 7 tryPostMessage('"1"'); |
8 tryPostMessage('({})'); | 8 tryPostMessage('({})'); |
9 tryPostMessage('({a:1})'); | 9 tryPostMessage('({a:1})'); |
10 tryPostMessage('({a:"a"})'); | 10 tryPostMessage('({a:"a"})'); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 tryPostMessage(thunk( | 147 tryPostMessage(thunk( |
148 'var obja = {get p() { return 42; }}; ' + | 148 'var obja = {get p() { return 42; }}; ' + |
149 'var msg = {a: obja, get b() { return obja; }}; ' + | 149 'var msg = {a: obja, get b() { return obja; }}; ' + |
150 'return msg;' | 150 'return msg;' |
151 ), false, "evalThunk", function(v) { | 151 ), false, "evalThunk", function(v) { |
152 // Interestingly, the standard admits two answers here! | 152 // Interestingly, the standard admits two answers here! |
153 doPassFail(v.a === v.b, "reference equality preserved (opposite order)") ; | 153 doPassFail(v.a === v.b, "reference equality preserved (opposite order)") ; |
154 doPassFail((v.b.p === 42 && v.a.p === 42) || | 154 doPassFail((v.b.p === 42 && v.a.p === 42) || |
155 (v.b.p === null && v.a.p === null), "accessors used (opposite order)"); | 155 (v.b.p === null && v.a.p === null), "accessors used (opposite order)"); |
156 }); | 156 }); |
157 // We should nullify the results from accessors more than one level deep, | 157 |
158 // but leave other fields untouched. | 158 // Accessor properties (getters) are allowed on the cloned object, |
159 // with no side conditions on the values they might return. For a | |
160 // short period, the spec mandated that accessor properties appearing | |
161 // within the value of what an 'outermost' accessor property returned | |
162 // should all map to null -- | |
163 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=12101. This change | |
164 // was reverted and accessor properties were allowed with no spec | |
165 // restrictions on nesting. | |
166 // | |
167 // The tests below verify behavior surrounding such object structures, | |
168 // but the coercions to null must no longer happen. We keep | |
169 // the tests, as they usefully verify correctness in the handling of | |
170 // accessor properties overall. | |
Mike West
2013/12/01 20:26:49
I'd suggest just adding something like "Verify tha
sof
2013/12/01 21:35:11
Done; indeed, information better kept with the com
| |
159 tryPostMessage(thunk( | 171 tryPostMessage(thunk( |
160 'var obja = {get p() { return 42; }, q: 43}; ' + | 172 'var obja = {get p() { return 42; }, q: 43}; ' + |
161 'return {get a() { return obja; }};' | 173 'return {get a() { return obja; }};' |
162 ), false, "evalThunk", function(v) { | 174 ), false, "evalThunk", function(v) { |
163 doPassFail(v.a.p === null, "accessor value was nullified"); | 175 doPassFail(v.a.p === 42, "accessor value was not nullified"); |
164 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); | 176 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); |
165 }); | 177 }); |
166 tryPostMessage(thunk( | 178 tryPostMessage(thunk( |
167 'var objb = {get r() { return 44; }, t: 45}; ' + | 179 'var objb = {get r() { return 44; }, t: 45}; ' + |
168 'var obja = {get p() { return 42; }, q: 43, s: objb}; ' + | 180 'var obja = {get p() { return 42; }, q: 43, s: objb}; ' + |
169 'return {get a() { return obja; }};' | 181 'return {get a() { return obja; }};' |
170 ), false, "evalThunk", function(v) { | 182 ), false, "evalThunk", function(v) { |
171 doPassFail(v.a.p === null, "accessor value was nullified"); | 183 doPassFail(v.a.p === 42, "accessor value was not nullified"); |
172 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); | 184 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); |
173 doPassFail(v.s !== null, "non-accessor value was not nullified"); | 185 doPassFail(v.s !== null, "non-accessor value was not nullified"); |
174 doPassFail(v.a.s.r === null, "accessor value was nullified"); | 186 doPassFail(v.a.s.r === 44, "accessor value was not nullified"); |
175 doPassFail(v.a.s.t === 45, "non-accessor value was not nullified"); | 187 doPassFail(v.a.s.t === 45, "non-accessor value was not nullified"); |
176 }); | 188 }); |
177 tryPostMessage(thunk( | 189 tryPostMessage(thunk( |
178 'var objb = {get r() { return 44; }, t: 45}; ' + | 190 'var objb = {get r() { return 44; }, t: 45}; ' + |
179 'var obja = {get p() { return 42; }, q: 43, s: [objb]}; ' + | 191 'var obja = {get p() { return 42; }, q: 43, s: [objb]}; ' + |
180 'return {get c() { return 47; }, get a() { return obja; }, get b() { ret urn 46; } };' | 192 'return {get c() { return 47; }, get a() { return obja; }, get b() { ret urn 46; } };' |
181 ), false, "evalThunk", function(v) { | 193 ), false, "evalThunk", function(v) { |
182 doPassFail(v.b === 46, "accessor value was not nullified"); | 194 doPassFail(v.b === 46, "accessor value was not nullified"); |
183 doPassFail(v.c === 47, "accessor value was not nullified"); | 195 doPassFail(v.c === 47, "accessor value was not nullified"); |
184 doPassFail(v.a.p === null, "accessor value was nullified"); | 196 doPassFail(v.a.p === 42, "accessor value was not nullified"); |
185 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); | 197 doPassFail(v.a.q === 43, "non-accessor value was not nullified"); |
186 doPassFail(v.a.s !== null, "non-accessor value was not nullified"); | 198 doPassFail(v.a.s !== null, "non-accessor value was not nullified"); |
187 doPassFail(v.a.s !== undefined, "non-accessor value is defined"); | 199 doPassFail(v.a.s !== undefined, "non-accessor value is defined"); |
188 doPassFail(v.a.s[0] !== null, "non-accessor value was not nullified"); | 200 doPassFail(v.a.s[0] !== null, "non-accessor value was not nullified"); |
189 doPassFail(v.a.s[0] !== undefined, "non-accessor value is defined"); | 201 doPassFail(v.a.s[0] !== undefined, "non-accessor value is defined"); |
190 doPassFail(v.a.s[0].r === null, "accessor value was nullified"); | 202 doPassFail(v.a.s[0].r === 44, "accessor value was not nullified"); |
191 doPassFail(v.a.s[0].t === 45, "non-accessor value was not nullified"); | 203 doPassFail(v.a.s[0].t === 45, "non-accessor value was not nullified"); |
192 }); | 204 }); |
193 | 205 |
194 // We need to pass out the exception raised from internal accessors. | 206 // We need to pass out the exception raised from internal accessors. |
195 tryPostMessage(thunk( | 207 tryPostMessage(thunk( |
196 'return {get a() { throw "accessor-exn"; }};' | 208 'return {get a() { throw "accessor-exn"; }};' |
197 ), true, null, 'accessor-exn'); | 209 ), true, null, 'accessor-exn'); |
198 // We should still return the exception raised from nulled-out accessors. | |
199 tryPostMessage(thunk( | 210 tryPostMessage(thunk( |
200 'var obja = {get p() { throw "accessor-exn"; }}; ' + | 211 'var obja = {get p() { throw "accessor-exn"; }}; ' + |
201 'return {get a() { return obja; }};' | 212 'return {get a() { return obja; }};' |
202 ), true, null, 'accessor-exn'); | 213 ), true, null, 'accessor-exn'); |
203 // We should run the first nullified accessor, but no more. | |
204 tryPostMessage(thunk( | 214 tryPostMessage(thunk( |
205 'window.bcalled = undefined; ' + | 215 'window.bcalled = undefined; ' + |
206 'window.acalled = undefined; ' + | 216 'window.acalled = undefined; ' + |
207 'window.pcalled = undefined; ' + | 217 'window.pcalled = undefined; ' + |
208 'var objb = {get b() { window.bcalled = true; return 42; }}; ' + | 218 'var objb = {get b() { window.bcalled = true; return 42; }}; ' + |
209 'var obja = {get a() { window.acalled = true; return objb; }}; ' + | 219 'var obja = {get a() { window.acalled = true; return objb; }}; ' + |
210 'return { get p() { window.pcalled = true; return obja; }};' | 220 'return { get p() { window.pcalled = true; return obja; }};' |
211 ), false, "evalThunk", function(v) { | 221 ), false, "evalThunk", function(v) { |
212 doPassFail(v.p.a === null, "accessor value was nullified"); | 222 doPassFail(v.p.a.b === 42, "accessor value was not nullified"); |
213 doPassFail(window.pcalled === true, "window.pcalled === true"); | 223 doPassFail(window.pcalled === true, "window.pcalled === true"); |
214 doPassFail(window.acalled === true, "window.acalled === true"); | 224 doPassFail(window.acalled === true, "window.acalled === true"); |
215 doPassFail(window.bcalled === undefined, "window.bcalled === undefined") ; | 225 doPassFail(window.bcalled === true, "window.bcalled === true"); |
216 }); | 226 }); |
217 | 227 |
218 // Reference equality between Boolean objects must be maintained. | 228 // Reference equality between Boolean objects must be maintained. |
219 tryPostMessage(thunk( | 229 tryPostMessage(thunk( |
220 'var t1 = new Boolean(true); ' + | 230 'var t1 = new Boolean(true); ' + |
221 'var t2 = new Boolean(true); ' + | 231 'var t2 = new Boolean(true); ' + |
222 'var f1 = new Boolean(false); ' + | 232 'var f1 = new Boolean(false); ' + |
223 'var f2 = new Boolean(false); ' + | 233 'var f2 = new Boolean(false); ' + |
224 'return [t1, t1, t2, f1, f1, f2];' | 234 'return [t1, t1, t2, f1, f1, f2];' |
225 ), false, "evalThunk", function(v) { | 235 ), false, "evalThunk", function(v) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 doPassFail(v[0].length === window.fileList.length, "FileList length sent correctly"); | 335 doPassFail(v[0].length === window.fileList.length, "FileList length sent correctly"); |
326 doPassFail(v[0][0] !== v[1], "FileList should not respect reference equality (0)"); | 336 doPassFail(v[0][0] !== v[1], "FileList should not respect reference equality (0)"); |
327 doPassFail(v[0][1] !== v[2], "FileList should not respect reference equality (1)"); | 337 doPassFail(v[0][1] !== v[2], "FileList should not respect reference equality (1)"); |
328 doPassFail(v[0][0].name == window.file0.name, "FileList preserves or der and data (name0)"); | 338 doPassFail(v[0][0].name == window.file0.name, "FileList preserves or der and data (name0)"); |
329 doPassFail(v[0][1].name == window.file1.name, "FileList preserves or der and data (name1)"); | 339 doPassFail(v[0][1].name == window.file1.name, "FileList preserves or der and data (name1)"); |
330 doPassFail(equal(v[0][0].lastModifiedDate, window.file0.lastModified Date), "FileList preserves order and data (date0)"); | 340 doPassFail(equal(v[0][0].lastModifiedDate, window.file0.lastModified Date), "FileList preserves order and data (date0)"); |
331 doPassFail(equal(v[0][1].lastModifiedDate, window.file1.lastModified Date), "FileList preserves order and data (date1)"); | 341 doPassFail(equal(v[0][1].lastModifiedDate, window.file1.lastModified Date), "FileList preserves order and data (date1)"); |
332 }); | 342 }); |
333 } | 343 } |
334 tryPostMessage('"done"'); | 344 tryPostMessage('"done"'); |
OLD | NEW |