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

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

Issue 104013008: Reland v8:18458 "Load the global proxy from the context of the target function." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 11 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/mjsunit/contextual-calls.js ('k') | no next file » | 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 47
48 // Calling (call, Function.prototype.call, Function.prototype.apply, 48 // Calling (call, Function.prototype.call, Function.prototype.apply,
49 // Function.prototype.bind). 49 // Function.prototype.bind).
50 50
51 var global_object = this 51 var global_object = this
52 var receiver 52 var receiver
53 53
54 function TestCall(isStrict, callTrap) { 54 function TestCall(isStrict, callTrap) {
55 assertEquals(42, callTrap(5, 37)) 55 assertEquals(42, callTrap(5, 37))
56 // TODO(rossberg): strict mode seems to be broken on x64... 56 assertSame(isStrict ? undefined : global_object, receiver)
57 // assertSame(isStrict ? undefined : global_object, receiver)
58 57
59 var handler = { 58 var handler = {
60 get: function(r, k) { 59 get: function(r, k) {
61 return k == "length" ? 2 : Function.prototype[k] 60 return k == "length" ? 2 : Function.prototype[k]
62 } 61 }
63 } 62 }
64 var f = Proxy.createFunction(handler, callTrap) 63 var f = Proxy.createFunction(handler, callTrap)
65 var o = {f: f} 64 var o = {f: f}
66 global_object.f = f 65 global_object.f = f
67 66
68 receiver = 333 67 receiver = 333
69 assertEquals(42, f(11, 31)) 68 assertEquals(42, f(11, 31))
70 // TODO(rossberg): strict mode seems to be broken on x64... 69 assertSame(isStrict ? undefined : global_object, receiver)
71 // assertSame(isStrict ? undefined : global_object, receiver)
72 receiver = 333 70 receiver = 333
73 assertEquals(42, o.f(10, 32)) 71 assertEquals(42, o.f(10, 32))
74 assertSame(o, receiver) 72 assertSame(o, receiver)
75 receiver = 333 73 receiver = 333
76 assertEquals(42, o["f"](9, 33)) 74 assertEquals(42, o["f"](9, 33))
77 assertSame(o, receiver) 75 assertSame(o, receiver)
78 receiver = 333 76 receiver = 333
79 assertEquals(42, (1, o).f(8, 34)) 77 assertEquals(42, (1, o).f(8, 34))
80 assertSame(o, receiver) 78 assertSame(o, receiver)
81 receiver = 333 79 receiver = 333
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 } 737 }
740 } 738 }
741 } 739 }
742 } 740 }
743 } 741 }
744 } 742 }
745 } 743 }
746 744
747 TestCalls() 745 TestCalls()
748 */ 746 */
747
748 var realms = [Realm.create(), Realm.create()];
749 Realm.shared = {};
750
751 Realm.eval(realms[0], "function f() { return this; };");
752 Realm.eval(realms[0], "Realm.shared.f = f;");
753 Realm.eval(realms[0], "Realm.shared.fg = this;");
754 Realm.eval(realms[1], "function g() { return this; };");
755 Realm.eval(realms[1], "Realm.shared.g = g;");
756 Realm.eval(realms[1], "Realm.shared.gg = this;");
757
758 var fp = Proxy.createFunction({}, Realm.shared.f);
759 var gp = Proxy.createFunction({}, Realm.shared.g);
760
761 for (var i = 0; i < 10; i++) {
762 assertEquals(Realm.shared.fg, fp());
763 assertEquals(Realm.shared.gg, gp());
764
765 with (this) {
766 assertEquals(Realm.shared.fg, fp());
767 assertEquals(Realm.shared.gg, gp());
768 }
769
770 with ({}) {
771 assertEquals(Realm.shared.fg, fp());
772 assertEquals(Realm.shared.gg, gp());
773 }
774 }
OLDNEW
« no previous file with comments | « test/mjsunit/contextual-calls.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698