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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 recordCreated = true; | 91 recordCreated = true; |
92 return "bar"; | 92 return "bar"; |
93 }, | 93 }, |
94 enumerable: true | 94 enumerable: true |
95 }) | 95 }) |
96 | 96 |
97 // Object.observe | 97 // Object.observe |
98 assertThrows(function() { Object.observe("non-object", observer.callback); }, Ty
peError); | 98 assertThrows(function() { Object.observe("non-object", observer.callback); }, Ty
peError); |
99 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError); | 99 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError); |
100 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); | 100 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); |
| 101 assertEquals(obj, Object.observe(obj, observer.callback)); |
101 | 102 |
102 // Object.unobserve | 103 // Object.unobserve |
103 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); | 104 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); |
104 assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError); | 105 assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError); |
| 106 assertEquals(obj, Object.unobserve(obj, observer.callback)); |
105 | 107 |
106 // Object.getNotifier | 108 // Object.getNotifier |
107 var notifier = Object.getNotifier(obj); | 109 var notifier = Object.getNotifier(obj); |
108 assertSame(notifier, Object.getNotifier(obj)); | 110 assertSame(notifier, Object.getNotifier(obj)); |
109 assertEquals(null, Object.getNotifier(Object.freeze({}))); | 111 assertEquals(null, Object.getNotifier(Object.freeze({}))); |
110 assertFalse(notifier.hasOwnProperty('notify')); | 112 assertFalse(notifier.hasOwnProperty('notify')); |
111 assertEquals([], Object.keys(notifier)); | 113 assertEquals([], Object.keys(notifier)); |
112 var notifyDesc = Object.getOwnPropertyDescriptor(notifier.__proto__, 'notify'); | 114 var notifyDesc = Object.getOwnPropertyDescriptor(notifier.__proto__, 'notify'); |
113 assertTrue(notifyDesc.configurable); | 115 assertTrue(notifyDesc.configurable); |
114 assertTrue(notifyDesc.writable); | 116 assertTrue(notifyDesc.writable); |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
614 Object.observe(dummy, observer.callback); | 616 Object.observe(dummy, observer.callback); |
615 Object.unobserve(dummy, observer.callback); | 617 Object.unobserve(dummy, observer.callback); |
616 var array = [0]; | 618 var array = [0]; |
617 Object.observe(array, observer.callback); | 619 Object.observe(array, observer.callback); |
618 array.splice(0, 1); | 620 array.splice(0, 1); |
619 Object.deliverChangeRecords(observer.callback); | 621 Object.deliverChangeRecords(observer.callback); |
620 observer.assertCallbackRecords([ | 622 observer.assertCallbackRecords([ |
621 { object: array, name: '0', type: 'deleted', oldValue: 0 }, | 623 { object: array, name: '0', type: 'deleted', oldValue: 0 }, |
622 { object: array, name: 'length', type: 'updated', oldValue: 1}, | 624 { object: array, name: 'length', type: 'updated', oldValue: 1}, |
623 ]); | 625 ]); |
OLD | NEW |