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

Side by Side Diff: test/mjsunit/readonly.js

Issue 1417063011: [runtime] support new Proxy() instead of Proxy.create and install getPrototypeOf trap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: removing unreachable code Created 5 years, 1 month 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
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regress/regress-crbug-493568.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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 o[name] = -44; 113 o[name] = -44;
114 Object.freeze(o); 114 Object.freeze(o);
115 } 115 }
116 116
117 function ReadonlyByProto(o, name) { 117 function ReadonlyByProto(o, name) {
118 var p = Object.create(o.__proto__); 118 var p = Object.create(o.__proto__);
119 Object.defineProperty(p, name, {value: -45, writable: false}); 119 Object.defineProperty(p, name, {value: -45, writable: false});
120 o.__proto__ = p; 120 o.__proto__ = p;
121 } 121 }
122 122
123 // TODO(neis,cbruni): Enable once the necessary traps work again.
123 // Allow Proxy to be undefined, so test can run in non-Harmony mode as well. 124 // Allow Proxy to be undefined, so test can run in non-Harmony mode as well.
124 var global = this; 125 var global = this;
125 126
126 function ReadonlyByProxy(o, name) { 127 function ReadonlyByProxy(o, name) {
127 if (!global.Proxy) return ReadonlyByFreeze(o, name); // Dummy. 128 if (!global.Proxy) return ReadonlyByFreeze(o, name); // Dummy.
128 var p = global.Proxy.create({ 129 var p = new global.Proxy({}, {
129 getPropertyDescriptor: function() { 130 getPropertyDescriptor: function() {
130 return {value: -46, writable: false, configurable: true}; 131 return {value: -46, writable: false, configurable: true};
131 } 132 }
132 }); 133 });
133 o.__proto__ = p; 134 o.__proto__ = p;
134 } 135 }
135 136
136 var readonlys = [ 137 var readonlys = [
137 ReadonlyByNonwritableDataProperty, ReadonlyByAccessorPropertyWithoutSetter, 138 ReadonlyByNonwritableDataProperty, ReadonlyByAccessorPropertyWithoutSetter,
138 ReadonlyByGetter, ReadonlyByFreeze, ReadonlyByProto, ReadonlyByProxy 139 ReadonlyByGetter, ReadonlyByFreeze, ReadonlyByProto // ReadonlyByProxy
139 ] 140 ]
140 141
141 function TestAllReadonlys(f) { 142 function TestAllReadonlys(f) {
142 // Provide various methods to making a property read-only. 143 // Provide various methods to making a property read-only.
143 for (var i = 0; i < readonlys.length; ++i) { 144 for (var i = 0; i < readonlys.length; ++i) {
144 print(" readonly =", i) 145 print(" readonly =", i)
145 f(readonlys[i]); 146 f(readonlys[i]);
146 } 147 }
147 } 148 }
148 149
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 var o = c(); 224 var o = c();
224 Assign2(o, i); 225 Assign2(o, i);
225 assertEquals(i, o.a); 226 assertEquals(i, o.a);
226 } 227 }
227 %OptimizeFunctionOnNextCall(Assign2); 228 %OptimizeFunctionOnNextCall(Assign2);
228 ReadonlyByNonwritableDataProperty(p, "a"); 229 ReadonlyByNonwritableDataProperty(p, "a");
229 var o = c(); 230 var o = c();
230 Assign2(o, 0); 231 Assign2(o, 0);
231 assertTrue(o.a < 0); 232 assertTrue(o.a < 0);
232 })(); 233 })();
OLDNEW
« no previous file with comments | « test/mjsunit/mjsunit.status ('k') | test/mjsunit/regress/regress-crbug-493568.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698