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 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 Object.observe(dummy, observer.callback); | 803 Object.observe(dummy, observer.callback); |
804 Object.unobserve(dummy, observer.callback); | 804 Object.unobserve(dummy, observer.callback); |
805 var array = [0]; | 805 var array = [0]; |
806 Object.observe(array, observer.callback); | 806 Object.observe(array, observer.callback); |
807 array.splice(0, 1); | 807 array.splice(0, 1); |
808 Object.deliverChangeRecords(observer.callback); | 808 Object.deliverChangeRecords(observer.callback); |
809 observer.assertCallbackRecords([ | 809 observer.assertCallbackRecords([ |
810 { object: array, name: '0', type: 'deleted', oldValue: 0 }, | 810 { object: array, name: '0', type: 'deleted', oldValue: 0 }, |
811 { object: array, name: 'length', type: 'updated', oldValue: 1}, | 811 { object: array, name: 'length', type: 'updated', oldValue: 1}, |
812 ]); | 812 ]); |
| 813 |
| 814 // __proto__ |
| 815 reset(); |
| 816 var obj = {}; |
| 817 Object.observe(obj, observer.callback); |
| 818 var p = {foo: 'yes'}; |
| 819 var q = {bar: 'no'}; |
| 820 obj.__proto__ = p; |
| 821 obj.__proto__ = p; // ignored |
| 822 obj.__proto__ = null; |
| 823 obj.__proto__ = q; |
| 824 // TODO(adamk): Add tests for objects with hidden prototypes |
| 825 // once we support observing the global object. |
| 826 Object.deliverChangeRecords(observer.callback); |
| 827 observer.assertCallbackRecords([ |
| 828 { object: obj, name: '__proto__', type: 'prototype', |
| 829 oldValue: Object.prototype }, |
| 830 { object: obj, name: '__proto__', type: 'prototype', oldValue: p }, |
| 831 { object: obj, name: '__proto__', type: 'prototype', oldValue: null }, |
| 832 ]); |
OLD | NEW |