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

Side by Side Diff: test/webkit/preventExtensions.js

Issue 1011823003: [es6] don't throw if argument is non-object (O.freeze, O.seal, O.preventExtensions) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« test/mjsunit/object-freeze.js ('K') | « test/mjsunit/object-seal.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. 2 // Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 1. Redistributions of source code must retain the above copyright 7 // 1. Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer. 8 // notice, this list of conditions and the following disclaimer.
9 // 2. Redistributions in binary form must reproduce the above copyright 9 // 2. Redistributions in binary form must reproduce the above copyright
10 // notice, this list of conditions and the following disclaimer in the 10 // notice, this list of conditions and the following disclaimer in the
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 shouldBeTrue("(new frozen).prototypeExists"); 85 shouldBeTrue("(new frozen).prototypeExists");
86 86
87 shouldBe('test(obj())', '"(b:4)(c:3)E"'); // extensible, can delete a, can modif y b, and can add c 87 shouldBe('test(obj())', '"(b:4)(c:3)E"'); // extensible, can delete a, can modif y b, and can add c
88 shouldBe('test(preventExtensions(obj()))', '"(b:4)"'); // <nothing>, can delete a, can modify b, and CANNOT add c 88 shouldBe('test(preventExtensions(obj()))', '"(b:4)"'); // <nothing>, can delete a, can modify b, and CANNOT add c
89 shouldBe('test(seal(obj()))', '"(a:1)(b:4)S"'); // sealed, CANNOT delete a, can modify b, and CANNOT add c 89 shouldBe('test(seal(obj()))', '"(a:1)(b:4)S"'); // sealed, CANNOT delete a, can modify b, and CANNOT add c
90 shouldBe('test(freeze(obj()))', '"(a:1)(b:2)SF"'); // sealed and frozen, CANNOT delete a, CANNOT modify b, and CANNOT add c 90 shouldBe('test(freeze(obj()))', '"(a:1)(b:2)SF"'); // sealed and frozen, CANNOT delete a, CANNOT modify b, and CANNOT add c
91 91
92 // check that we can preventExtensions on a host function. 92 // check that we can preventExtensions on a host function.
93 shouldBe('Object.preventExtensions(Math.sin)', 'Math.sin'); 93 shouldBe('Object.preventExtensions(Math.sin)', 'Math.sin');
94 94
95 shouldThrow('var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: " Should not see this" }; o.newProp;'); 95 shouldBe('var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Sho uld not see this" }; o.newProp;');
arv (Not doing code reviews) 2015/03/19 19:38:08 This looks strange. shouldBe takes two strings tha
caitp (gmail) 2015/03/19 20:16:15 Looks like in this case, it should throw https://p
96 shouldThrow('"use strict"; var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" }; o.newProp;'); 96 shouldBe('"use strict"; var o = {}; Object.preventExtensions(o); o.__proto__ = { newProp: "Should not see this" }; o.newProp;');
arv (Not doing code reviews) 2015/03/19 19:38:08 This should still throw, shouldn't it?
caitp (gmail) 2015/03/19 19:42:10 Yeah. I passed make check, but I guess the WebKit
97 97
98 // check that we can still access static properties on an object after calling p reventExtensions. 98 // check that we can still access static properties on an object after calling p reventExtensions.
99 shouldBe('Object.preventExtensions(Math); Math.sqrt(4)', '2'); 99 shouldBe('Object.preventExtensions(Math); Math.sqrt(4)', '2');
100 100
101 // Should not be able to add properties to a preventExtensions array. 101 // Should not be able to add properties to a preventExtensions array.
102 shouldBeUndefined('var arr = Object.preventExtensions([]); arr[0] = 42; arr[0]') ; 102 shouldBeUndefined('var arr = Object.preventExtensions([]); arr[0] = 42; arr[0]') ;
103 shouldBe('var arr = Object.preventExtensions([]); arr[0] = 42; arr.length', '0') ; 103 shouldBe('var arr = Object.preventExtensions([]); arr[0] = 42; arr.length', '0') ;
104 // In strict mode, this throws. 104 // In strict mode, this throws.
105 shouldThrow('"use strict"; var arr = Object.preventExtensions([]); arr[0] = 42; arr[0]'); 105 shouldThrow('"use strict"; var arr = Object.preventExtensions([]); arr[0] = 42; arr[0]');
106 106
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 Object.freeze(x); 148 Object.freeze(x);
149 return Object.isFrozen(x); 149 return Object.isFrozen(x);
150 } 150 }
151 shouldBeTrue('preventExtensionsFreezeIsFrozen(function foo(){})') 151 shouldBeTrue('preventExtensionsFreezeIsFrozen(function foo(){})')
152 shouldBeTrue('preventExtensionsFreezeIsFrozen(function foo(){ "use strict"; })') 152 shouldBeTrue('preventExtensionsFreezeIsFrozen(function foo(){ "use strict"; })')
153 shouldBeTrue('preventExtensionsFreezeIsFrozen([0,1,2])') 153 shouldBeTrue('preventExtensionsFreezeIsFrozen([0,1,2])')
154 shouldBeTrue('preventExtensionsFreezeIsFrozen((function(){ return arguments; })( 0,1,2))') 154 shouldBeTrue('preventExtensionsFreezeIsFrozen((function(){ return arguments; })( 0,1,2))')
155 155
156 shouldBeFalse('Object.getOwnPropertyDescriptor(freeze({0:0}), 0).configurable'); 156 shouldBeFalse('Object.getOwnPropertyDescriptor(freeze({0:0}), 0).configurable');
157 shouldBeFalse('Object.getOwnPropertyDescriptor(freeze({10000001:0}), 10000001).c onfigurable'); 157 shouldBeFalse('Object.getOwnPropertyDescriptor(freeze({10000001:0}), 10000001).c onfigurable');
OLDNEW
« test/mjsunit/object-freeze.js ('K') | « test/mjsunit/object-seal.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698