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 |
11 // with the distribution. | 11 // with the distribution. |
12 // * Neither the name of Google Inc. nor the names of its | 12 // * Neither the name of Google Inc. nor the names of its |
13 // contributors may be used to endorse or promote products derived | 13 // contributors may be used to endorse or promote products derived |
14 // from this software without specific prior written permission. | 14 // from this software without specific prior written permission. |
15 // | 15 // |
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 // Flags: --harmony-observation --harmony-proxies --harmony-collections | 28 // Flags: --harmony-observation --harmony-proxies --harmony-collections |
29 // Flags: --allow-natives-syntax | 29 // Flags: --harmony-symbols --allow-natives-syntax |
30 | 30 |
31 var allObservers = []; | 31 var allObservers = []; |
32 function reset() { | 32 function reset() { |
33 allObservers.forEach(function(observer) { observer.reset(); }); | 33 allObservers.forEach(function(observer) { observer.reset(); }); |
34 } | 34 } |
35 | 35 |
36 function stringifyNoThrow(arg) { | 36 function stringifyNoThrow(arg) { |
37 try { | 37 try { |
38 return JSON.stringify(arg); | 38 return JSON.stringify(arg); |
39 } catch (e) { | 39 } catch (e) { |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 { object: obj, name: "1", type: "reconfigured" }, | 441 { object: obj, name: "1", type: "reconfigured" }, |
442 { object: obj, name: "1", type: "updated", oldValue: 9 }, | 442 { object: obj, name: "1", type: "updated", oldValue: 9 }, |
443 { object: obj, name: "1", type: "updated", oldValue: 10 }, | 443 { object: obj, name: "1", type: "updated", oldValue: 10 }, |
444 { object: obj, name: "1", type: "updated", oldValue: 11 }, | 444 { object: obj, name: "1", type: "updated", oldValue: 11 }, |
445 { object: obj, name: "1", type: "updated", oldValue: 12 }, | 445 { object: obj, name: "1", type: "updated", oldValue: 12 }, |
446 { object: obj, name: "1", type: "deleted", oldValue: 36 }, | 446 { object: obj, name: "1", type: "deleted", oldValue: 36 }, |
447 { object: obj, name: "1", type: "new" }, | 447 { object: obj, name: "1", type: "new" }, |
448 ]); | 448 ]); |
449 | 449 |
450 | 450 |
| 451 // Observing symbol properties (not). |
| 452 print("*****") |
| 453 reset(); |
| 454 var obj = {} |
| 455 var symbol = Symbol("secret"); |
| 456 Object.observe(obj, observer.callback); |
| 457 obj[symbol] = 3; |
| 458 delete obj[symbol]; |
| 459 Object.defineProperty(obj, symbol, {get: function() {}, configurable: true}); |
| 460 Object.defineProperty(obj, symbol, {value: 6}); |
| 461 Object.defineProperty(obj, symbol, {writable: false}); |
| 462 delete obj[symbol]; |
| 463 Object.defineProperty(obj, symbol, {value: 7}); |
| 464 ++obj[symbol]; |
| 465 obj[symbol]++; |
| 466 obj[symbol] *= 3; |
| 467 delete obj[symbol]; |
| 468 obj.__defineSetter__(symbol, function() {}); |
| 469 obj.__defineGetter__(symbol, function() {}); |
| 470 Object.deliverChangeRecords(observer.callback); |
| 471 observer.assertNotCalled(); |
| 472 |
| 473 |
451 // Test all kinds of objects generically. | 474 // Test all kinds of objects generically. |
452 function TestObserveConfigurable(obj, prop) { | 475 function TestObserveConfigurable(obj, prop) { |
453 reset(); | 476 reset(); |
454 obj[prop] = 1; | 477 obj[prop] = 1; |
455 Object.observe(obj, observer.callback); | 478 Object.observe(obj, observer.callback); |
456 obj[prop] = 2; | 479 obj[prop] = 2; |
457 obj[prop] = 3; | 480 obj[prop] = 3; |
458 delete obj[prop]; | 481 delete obj[prop]; |
459 obj[prop] = 4; | 482 obj[prop] = 4; |
460 obj[prop] = 4; // ignored | 483 obj[prop] = 4; // ignored |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 for (var n1 = 0; n1 < 3; ++n1) | 1070 for (var n1 = 0; n1 < 3; ++n1) |
1048 for (var n2 = 0; n2 < 3; ++n2) | 1071 for (var n2 = 0; n2 < 3; ++n2) |
1049 for (var i in mutation) | 1072 for (var i in mutation) |
1050 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); | 1073 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); |
1051 | 1074 |
1052 for (var b1 = 0; b1 < 2; ++b1) | 1075 for (var b1 = 0; b1 < 2; ++b1) |
1053 for (var b2 = 0; b2 < 2; ++b2) | 1076 for (var b2 = 0; b2 < 2; ++b2) |
1054 for (var n = 0; n < 3; ++n) | 1077 for (var n = 0; n < 3; ++n) |
1055 for (var i in mutationByIncr) | 1078 for (var i in mutationByIncr) |
1056 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); | 1079 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); |
OLD | NEW |