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

Side by Side Diff: test/mjsunit/strong/object-freeze-property.js

Issue 1142393003: [strong] Implement per-object restrictions behaviour of property freezing (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test, improve error message Created 5 years, 7 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
« src/v8natives.js ('K') | « src/v8natives.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
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --strong-mode --allow-natives-syntax
6
7 // TODO(conradw): Track implementation of strong bit for other objects, add
8 // tests.
9
10 function getSloppyObjects() {
11 return [(function(){}), ({})];
12 }
13
14 function getStrictObjects() {
15 "use strict";
16 return [(function(){}), ({})];
17 }
18
19 function getStrongObjects() {
20 "use strong";
21 // Strong functions can't have properties added to them.
rossberg 2015/05/22 13:10:28 Nit: indentation
conradw 2015/05/22 14:07:08 Done.
22 return [({})];
23 }
24
25 function testStrongObjectFreezeProp() {
26 "use strict";
27 let sloppyObjects = getSloppyObjects();
28 let strictObjects = getStrictObjects();
29 let strongObjects = getStrongObjects();
30 let nonStrongObjects = sloppyObjects.concat(strictObjects);
rossberg 2015/05/22 13:10:28 Nit: weakObjects
conradw 2015/05/22 14:07:08 Done.
31
32 for (let o of nonStrongObjects) {
33 Object.defineProperty(o, "foo", { enumerable:true, writable:true });
rossberg 2015/05/22 13:10:28 Nit: why care about enumerable in all these tests?
conradw 2015/05/22 14:07:08 The defineProperties case needs it to work, and I
rossberg 2015/05/22 14:15:29 Actually, I don't understand your use of definePro
conradw 2015/05/27 18:15:45 Fixed now.
34 assertDoesNotThrow(
35 function() {
36 "use strong";
37 Object.defineProperty(o, "foo", { enumerable:true, writable:false });
38 });
39 }
40 for (let o of strongObjects) {
41 let defProp = function(o) {
rossberg 2015/05/22 13:10:28 Nit: function defProp(o) { (same below)
conradw 2015/05/22 14:07:08 Done.
42 Object.defineProperty(o, "foo", { enumerable:true, writable:false });
43 };
44 let defProps = function(o) {
45 let props = {};
46 Object.defineProperty(props, "foo", { enumerable:true, writable:false });
47 Object.defineProperties(o, props);
48 };
49 let freeze = function(o) { Object.freeze(o); };
50 Object.defineProperty(o, "foo", { enumerable:true, writable:true });
51 for (let func of [defProp, defProps, freeze]) {
rossberg 2015/05/22 13:10:28 Nit: you can just use OBject.freeze here directly
conradw 2015/05/22 14:07:08 Wanted to give an opportunity for some sort of low
52 assertThrows(function(){func(o)}, TypeError);
53 assertThrows(function(){func(o)}, TypeError);
54 assertThrows(function(){func(o)}, TypeError);
55 %OptimizeFunctionOnNextCall(func);
56 assertThrows(function(){func(o)}, TypeError);
57 %DeoptimizeFunction(func);
58 assertThrows(function(){func(o)}, TypeError);
59 }
60 }
61 }
62 testStrongObjectFreezeProp();
OLDNEW
« src/v8natives.js ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698