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

Unified Diff: test/mjsunit/object-freeze.js

Issue 1103473003: Revert of [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, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/mjsunit/messages.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/object-freeze.js
diff --git a/test/mjsunit/object-freeze.js b/test/mjsunit/object-freeze.js
index 23f5af0f0c2c9de4489828fa5f0e628ad5d05d3d..5d1f8b7c5b0abb092639c90945c70aec48753a44 100644
--- a/test/mjsunit/object-freeze.js
+++ b/test/mjsunit/object-freeze.js
@@ -25,20 +25,33 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Tests the Object.freeze and Object.isFrozen methods - ES 19.1.2.5 and
-// ES 19.1.2.12
+// Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and
+// ES 15.2.3.12
// Flags: --allow-natives-syntax
-// Test that we return obj if non-object is passed as argument
-var non_objects = new Array(undefined, null, 1, -1, 0, 42.43, Symbol("test"));
+// Test that we throw an error if an object is not passed as argument.
+var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
for (var key in non_objects) {
- assertSame(non_objects[key], Object.freeze(non_objects[key]));
+ var exception = false;
+ try {
+ Object.freeze(non_objects[key]);
+ } catch(e) {
+ exception = true;
+ assertTrue(/Object.freeze called on non-object/.test(e));
+ }
+ assertTrue(exception);
}
-// Test that isFrozen always returns true for non-objects
for (var key in non_objects) {
- assertTrue(Object.isFrozen(non_objects[key]));
+ exception = false;
+ try {
+ Object.isFrozen(non_objects[key]);
+ } catch(e) {
+ exception = true;
+ assertTrue(/Object.isFrozen called on non-object/.test(e));
+ }
+ assertTrue(exception);
}
// Test normal data properties.
@@ -335,64 +348,3 @@
Object.freeze(obj);
assertTrue(Object.isSealed(obj));
assertTrue(Object.isFrozen(obj));
-
-
-(function propertiesOfFrozenObjectNotFrozen() {
- function Frozen() {}
- Object.freeze(Frozen);
- assertDoesNotThrow(function() { return new Frozen(); });
- Frozen.prototype.prototypeExists = true;
- assertTrue((new Frozen()).prototypeExists);
-})();
-
-
-(function frozenPrototypePreventsPUT() {
- // A read-only property on the prototype should prevent a [[Put]] .
- function Constructor() {}
- Constructor.prototype.foo = 1;
- Object.freeze(Constructor.prototype);
- var obj = new Constructor();
- obj.foo = 2;
- assertSame(1, obj.foo);
-})();
-
-
-(function frozenFunctionSloppy() {
- // Check that freezing a function works correctly.
- var func = Object.freeze(function foo(){});
- assertTrue(Object.isFrozen(func));
- func.prototype = 42;
- assertFalse(func.prototype === 42);
- assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
-})();
-
-
-(function frozenFunctionStrict() {
- // Check that freezing a strict function works correctly.
- var func = Object.freeze(function foo(){ "use strict"; });
- assertTrue(Object.isFrozen(func));
- func.prototype = 42;
- assertFalse(func.prototype === 42);
- assertFalse(Object.getOwnPropertyDescriptor(func, "prototype").writable);
-})();
-
-
-(function frozenArrayObject() {
- // Check that freezing array objects works correctly.
- var array = Object.freeze([0,1,2]);
- assertTrue(Object.isFrozen(array));
- array[0] = 3;
- assertEquals(0, array[0]);
- assertFalse(Object.getOwnPropertyDescriptor(array, "length").writable);
-})();
-
-
-(function frozenArgumentsObject() {
- // Check that freezing arguments objects works correctly.
- var args = Object.freeze((function(){ return arguments; })(0,1,2));
- assertTrue(Object.isFrozen(args));
- args[0] = 3;
- assertEquals(0, args[0]);
- assertFalse(Object.getOwnPropertyDescriptor(args, "length").writable);
- assertFalse(Object.getOwnPropertyDescriptor(args, "callee").writable);
-})();
« no previous file with comments | « test/mjsunit/messages.js ('k') | test/mjsunit/object-seal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698