Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: test/mjsunit/harmony/proxies.js

Issue 10534090: Rollback of r11719, r11717, r11716, r11714, r11700, r11699, r11697, r11695, r11694 in trunk branch. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/override-read-only-property.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 get: function(pr, pk) { 569 get: function(pr, pk) {
570 return function(r, k, v) { throw "myexn" } 570 return function(r, k, v) { throw "myexn" }
571 } 571 }
572 })) 572 }))
573 573
574 574
575 var rec 575 var rec
576 var key 576 var key
577 var val 577 var val
578 578
579 function TestSetForDerived(trap) { 579 function TestSetForDerived(handler) {
580 TestWithProxies(TestSetForDerived2, trap) 580 TestWithProxies(TestSetForDerived2, handler)
581 } 581 }
582 582
583 function TestSetForDerived2(create, trap) { 583 function TestSetForDerived2(create, handler) {
584 var p = create({getPropertyDescriptor: trap, getOwnPropertyDescriptor: trap}) 584 var p = create(handler)
585 var o = Object.create(p, {x: {value: 88, writable: true}, 585 var o = Object.create(p, {x: {value: 88, writable: true},
586 '1': {value: 89, writable: true}}) 586 '1': {value: 89, writable: true}})
587 587
588 key = "" 588 key = ""
589 assertEquals(48, o.x = 48) 589 assertEquals(48, o.x = 48)
590 assertEquals("", key) // trap not invoked 590 assertEquals("", key) // trap not invoked
591 assertEquals(48, o.x) 591 assertEquals(48, o.x)
592 592
593 assertEquals(47, o[1] = 47) 593 assertEquals(47, o[1] = 47)
594 assertEquals("", key) // trap not invoked 594 assertEquals("", key) // trap not invoked
595 assertEquals(47, o[1]) 595 assertEquals(47, o[1])
596 596
597 assertEquals(49, o.y = 49) 597 assertEquals(49, o.y = 49)
598 assertEquals("y", key) 598 assertEquals("y", key)
599 assertEquals(49, o.y) 599 assertEquals(49, o.y)
600 600
601 assertEquals(50, o[2] = 50) 601 assertEquals(50, o[2] = 50)
602 assertEquals("2", key) 602 assertEquals("2", key)
603 assertEquals(50, o[2]) 603 assertEquals(50, o[2])
604 604
605 assertEquals(44, o.p_writable = 44) 605 assertEquals(44, o.p_writable = 44)
606 assertEquals("p_writable", key) 606 assertEquals("p_writable", key)
607 assertEquals(44, o.p_writable) 607 assertEquals(44, o.p_writable)
608 608
609 assertEquals(45, o.p_nonwritable = 45) 609 assertEquals(45, o.p_nonwritable = 45)
610 assertEquals("p_nonwritable", key) 610 assertEquals("p_nonwritable", key)
611 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nonwritable")) 611 assertEquals(45, o.p_nonwritable)
612 612
613 assertThrows(function(){ "use strict"; o.p_nonwritable = 45 }, TypeError)
614 assertEquals("p_nonwritable", key)
615 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nonwritable"))
616
617 val = ""
618 assertEquals(46, o.p_setter = 46) 613 assertEquals(46, o.p_setter = 46)
619 assertEquals("p_setter", key) 614 assertEquals("p_setter", key)
620 assertSame(o, rec) 615 assertSame(o, rec)
621 assertEquals(46, val) // written to parent 616 assertEquals(46, val) // written to parent
622 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_setter")) 617 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_setter"))
623 618
624 val = "" 619 val = ""
625 assertEquals(47, o.p_nosetter = 47) 620 assertEquals(47, o.p_nosetter = 47)
626 assertEquals("p_nosetter", key) 621 assertEquals("p_nosetter", key)
627 assertEquals("", val) // not written at all 622 assertEquals("", val) // not written at all
628 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nosetter")); 623 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nosetter"));
629 624
630 key = "" 625 key = ""
631 assertThrows(function(){ "use strict"; o.p_nosetter = 50 }, TypeError) 626 assertThrows(function(){ "use strict"; o.p_nosetter = 50 }, TypeError)
632 assertEquals("p_nosetter", key) 627 assertEquals("p_nosetter", key)
633 assertEquals("", val) // not written at all 628 assertEquals("", val) // not written at all
634 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nosetter"));
635 629
636 assertThrows(function(){ o.p_nonconf = 53 }, TypeError) 630 assertThrows(function(){ o.p_nonconf = 53 }, TypeError)
637 assertEquals("p_nonconf", key) 631 assertEquals("p_nonconf", key)
638 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_nonconf"));
639 632
640 assertThrows(function(){ o.p_throw = 51 }, "myexn") 633 assertThrows(function(){ o.p_throw = 51 }, "myexn")
641 assertEquals("p_throw", key) 634 assertEquals("p_throw", key)
642 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_throw"));
643 635
644 assertThrows(function(){ o.p_setterthrow = 52 }, "myexn") 636 assertThrows(function(){ o.p_setterthrow = 52 }, "myexn")
645 assertEquals("p_setterthrow", key) 637 assertEquals("p_setterthrow", key)
646 assertFalse(Object.prototype.hasOwnProperty.call(o, "p_setterthrow"));
647 } 638 }
648 639
649 640 TestSetForDerived({
650 TestSetForDerived( 641 getPropertyDescriptor: function(k) {
651 function(k) {
652 key = k; 642 key = k;
653 switch (k) { 643 switch (k) {
654 case "p_writable": return {writable: true, configurable: true} 644 case "p_writable": return {writable: true, configurable: true}
655 case "p_nonwritable": return {writable: false, configurable: true} 645 case "p_nonwritable": return {writable: false, configurable: true}
656 case "p_setter": return { 646 case "p_setter":return {
657 set: function(x) { rec = this; val = x }, 647 set: function(x) { rec = this; val = x },
658 configurable: true 648 configurable: true
659 } 649 }
660 case "p_nosetter": return { 650 case "p_nosetter": return {
661 get: function() { return 1 }, 651 get: function() { return 1 },
662 configurable: true 652 configurable: true
663 } 653 }
664 case "p_nonconf": return {} 654 case "p_nonconf":return {}
665 case "p_throw": throw "myexn" 655 case "p_throw": throw "myexn"
666 case "p_setterthrow": return {set: function(x) { throw "myexn" }} 656 case "p_setterthrow": return {set: function(x) { throw "myexn" }}
667 default: return undefined 657 default: return undefined
668 } 658 }
669 } 659 }
670 ) 660 })
671 661
672 662
673 // Evil proxy-induced side-effects shouldn't crash. 663 // Evil proxy-induced side-effects shouldn't crash.
674 // TODO(rossberg): proper behaviour isn't really spec'ed yet, so ignore results. 664 // TODO(rossberg): proper behaviour isn't really spec'ed yet, so ignore results.
675 665
676 TestWithProxies(function(create) { 666 TestWithProxies(function(create) {
677 var calls = 0 667 var calls = 0
678 var handler = { 668 var handler = {
679 getPropertyDescriptor: function() { 669 getPropertyDescriptor: function() {
680 ++calls 670 ++calls
(...skipping 1606 matching lines...) Expand 10 before | Expand all | Expand 10 after
2287 function TestConstructorWithProxyPrototype2(create, handler) { 2277 function TestConstructorWithProxyPrototype2(create, handler) {
2288 function C() {}; 2278 function C() {};
2289 C.prototype = create(handler); 2279 C.prototype = create(handler);
2290 2280
2291 var o = new C; 2281 var o = new C;
2292 assertSame(C.prototype, o.__proto__); 2282 assertSame(C.prototype, o.__proto__);
2293 assertSame(C.prototype, Object.getPrototypeOf(o)); 2283 assertSame(C.prototype, Object.getPrototypeOf(o));
2294 } 2284 }
2295 2285
2296 TestConstructorWithProxyPrototype(); 2286 TestConstructorWithProxyPrototype();
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/override-read-only-property.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698