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

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: cl feedback 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.
22 return [({})];
23 }
24
25 function testStrongObjectFreezeProp() {
26 "use strict";
27 let sloppyObjects = getSloppyObjects();
28 let strictObjects = getStrictObjects();
29 let strongObjects = getStrongObjects();
30 let weakObjects = sloppyObjects.concat(strictObjects);
31
32 for (let o of nonStrongObjects) {
33 Object.defineProperty(o, "foo", { enumerable:true, writable:true });
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 function defProp(o) {
42 Object.defineProperty(o, "foo", { enumerable:true, writable:false });
43 }
44 function defProps(o) {
45 let props = {};
46 Object.defineProperty(props, "foo", { enumerable:true, writable:false });
47 Object.defineProperties(o, props);
48 }
49 function freezeProp(o) {
50 Object.freeze(o);
51 }
52 Object.defineProperty(o, "foo", { enumerable:true, writable:true });
53 for (let func of [defProp, defProps, freezeProp]) {
54 assertThrows(function(){func(o)}, TypeError);
55 assertThrows(function(){func(o)}, TypeError);
56 assertThrows(function(){func(o)}, TypeError);
57 %OptimizeFunctionOnNextCall(func);
58 assertThrows(function(){func(o)}, TypeError);
59 %DeoptimizeFunction(func);
60 assertThrows(function(){func(o)}, TypeError);
61 }
62 }
63 }
64 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