| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 ]); | 243 ]); |
| 244 | 244 |
| 245 // Observing named properties. | 245 // Observing named properties. |
| 246 reset(); | 246 reset(); |
| 247 var obj = {a: 1} | 247 var obj = {a: 1} |
| 248 Object.observe(obj, observer.callback); | 248 Object.observe(obj, observer.callback); |
| 249 obj.a = 2; | 249 obj.a = 2; |
| 250 obj["a"] = 3; | 250 obj["a"] = 3; |
| 251 delete obj.a; | 251 delete obj.a; |
| 252 obj.a = 4; | 252 obj.a = 4; |
| 253 obj.a = 4; // ignored |
| 253 obj.a = 5; | 254 obj.a = 5; |
| 254 Object.defineProperty(obj, "a", {value: 6}); | 255 Object.defineProperty(obj, "a", {value: 6}); |
| 255 Object.defineProperty(obj, "a", {writable: false}); | 256 Object.defineProperty(obj, "a", {writable: false}); |
| 256 obj.a = 7; // ignored | 257 obj.a = 7; // ignored |
| 257 Object.defineProperty(obj, "a", {value: 8}); | 258 Object.defineProperty(obj, "a", {value: 8}); |
| 259 Object.defineProperty(obj, "a", {value: 7, writable: true}); |
| 260 Object.defineProperty(obj, "a", {get: function() {}}); |
| 258 Object.defineProperty(obj, "a", {get: function() {}}); | 261 Object.defineProperty(obj, "a", {get: function() {}}); |
| 259 delete obj.a; | 262 delete obj.a; |
| 260 Object.defineProperty(obj, "a", {get: function() {}}); | 263 delete obj.a; |
| 264 Object.defineProperty(obj, "a", {get: function() {}, configurable: true}); |
| 265 Object.defineProperty(obj, "a", {value: 9, writable: true}); |
| 266 obj.a = 10; |
| 261 Object.deliverChangeRecords(observer.callback); | 267 Object.deliverChangeRecords(observer.callback); |
| 262 // TODO(observe): oldValue not included yet. | |
| 263 observer.assertCallbackRecords([ | 268 observer.assertCallbackRecords([ |
| 264 { object: obj, name: "a", type: "updated" }, | 269 { object: obj, name: "a", type: "updated", oldValue: 1 }, |
| 265 { object: obj, name: "a", type: "updated" }, | 270 { object: obj, name: "a", type: "updated", oldValue: 2 }, |
| 266 { object: obj, name: "a", type: "deleted" }, | 271 { object: obj, name: "a", type: "deleted", oldValue: 3 }, |
| 267 { object: obj, name: "a", type: "new" }, | 272 { object: obj, name: "a", type: "new" }, |
| 268 { object: obj, name: "a", type: "updated" }, | 273 { object: obj, name: "a", type: "updated", oldValue: 4 }, |
| 269 { object: obj, name: "a", type: "updated" }, | 274 { object: obj, name: "a", type: "updated", oldValue: 5 }, |
| 270 { object: obj, name: "a", type: "reconfigured" }, | 275 { object: obj, name: "a", type: "reconfigured", oldValue: 6 }, |
| 271 { object: obj, name: "a", type: "updated" }, | 276 { object: obj, name: "a", type: "updated", oldValue: 6 }, |
| 277 { object: obj, name: "a", type: "reconfigured", oldValue: 8 }, |
| 278 { object: obj, name: "a", type: "reconfigured", oldValue: 7 }, |
| 272 { object: obj, name: "a", type: "reconfigured" }, | 279 { object: obj, name: "a", type: "reconfigured" }, |
| 273 { object: obj, name: "a", type: "deleted" }, | 280 { object: obj, name: "a", type: "deleted" }, |
| 274 { object: obj, name: "a", type: "new" }, | 281 { object: obj, name: "a", type: "new" }, |
| 282 { object: obj, name: "a", type: "reconfigured" }, |
| 283 { object: obj, name: "a", type: "updated", oldValue: 9 }, |
| 275 ]); | 284 ]); |
| OLD | NEW |