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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 enumerable: true | 93 enumerable: true |
94 }) | 94 }) |
95 | 95 |
96 // Object.observe | 96 // Object.observe |
97 assertThrows(function() { Object.observe("non-object", observer.callback); }, Ty
peError); | 97 assertThrows(function() { Object.observe("non-object", observer.callback); }, Ty
peError); |
98 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError); | 98 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError); |
99 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); | 99 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); |
100 | 100 |
101 // Object.unobserve | 101 // Object.unobserve |
102 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); | 102 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); |
| 103 assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError); |
103 | 104 |
104 // Object.getNotifier | 105 // Object.getNotifier |
105 var notifier = Object.getNotifier(obj); | 106 var notifier = Object.getNotifier(obj); |
106 assertSame(notifier, Object.getNotifier(obj)); | 107 assertSame(notifier, Object.getNotifier(obj)); |
107 assertEquals(null, Object.getNotifier(Object.freeze({}))); | 108 assertEquals(null, Object.getNotifier(Object.freeze({}))); |
108 assertFalse(notifier.hasOwnProperty('notify')); | 109 assertFalse(notifier.hasOwnProperty('notify')); |
109 assertEquals([], Object.keys(notifier)); | 110 assertEquals([], Object.keys(notifier)); |
110 var notifyDesc = Object.getOwnPropertyDescriptor(notifier.__proto__, 'notify'); | 111 var notifyDesc = Object.getOwnPropertyDescriptor(notifier.__proto__, 'notify'); |
111 assertTrue(notifyDesc.configurable); | 112 assertTrue(notifyDesc.configurable); |
112 assertTrue(notifyDesc.writable); | 113 assertTrue(notifyDesc.writable); |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 var array = {0: 1, 1: 2, 2: 3, length: 3}; | 583 var array = {0: 1, 1: 2, 2: 3, length: 3}; |
583 Object.observe(array, observer.callback); | 584 Object.observe(array, observer.callback); |
584 Array.prototype.splice.call(array, 1, 1, 4, 5); | 585 Array.prototype.splice.call(array, 1, 1, 4, 5); |
585 Object.deliverChangeRecords(observer.callback); | 586 Object.deliverChangeRecords(observer.callback); |
586 observer.assertCallbackRecords([ | 587 observer.assertCallbackRecords([ |
587 { object: array, name: '3', type: 'new' }, | 588 { object: array, name: '3', type: 'new' }, |
588 { object: array, name: '1', type: 'updated', oldValue: 2 }, | 589 { object: array, name: '1', type: 'updated', oldValue: 2 }, |
589 { object: array, name: '2', type: 'updated', oldValue: 3 }, | 590 { object: array, name: '2', type: 'updated', oldValue: 3 }, |
590 { object: array, name: 'length', type: 'updated', oldValue: 3 }, | 591 { object: array, name: 'length', type: 'updated', oldValue: 3 }, |
591 ]); | 592 ]); |
OLD | NEW |