Revision: 8800
Author:   [email protected]
Date:     Wed Aug  3 02:53:14 2011
Log:      Revert "Make window.{undefined,NaN,Infinity} read-only"

This reverts r8766.

TEST=WebKit LayoutTests green again.

Review URL: http://codereview.chromium.org/7562005
http://code.google.com/p/v8/source/detail?r=8800

Modified:
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/v8natives.js
 /branches/bleeding_edge/test/cctest/test-decls.cc
 /branches/bleeding_edge/test/es5conform/es5conform.status
 /branches/bleeding_edge/test/mjsunit/undeletable-functions.js
 /branches/bleeding_edge/test/sputnik/sputnik.status

=======================================
--- /branches/bleeding_edge/src/runtime.cc      Tue Aug  2 02:28:55 2011
+++ /branches/bleeding_edge/src/runtime.cc      Wed Aug  3 02:53:14 2011
@@ -1172,7 +1172,7 @@
             return ThrowRedeclarationError(isolate, "const", name);
           }
           // Otherwise, we check for locally conflicting declarations.
-          if (is_local && is_const_property) {
+          if (is_local && (is_read_only || is_const_property)) {
             const char* type = (is_read_only) ? "const" : "var";
             return ThrowRedeclarationError(isolate, type, name);
           }
@@ -1406,11 +1406,12 @@
           // make sure to introduce it.
           found = false;
         } else if ((intercepted & READ_ONLY) != 0) {
-          // The property is present, but read-only, so we ignore the
-          // redeclaration. However if we found readonly property
+          // The property is present, but read-only. Since we're trying to
+          // overwrite it with a variable declaration we must throw a
+          // re-declaration error.  However if we found readonly property
           // on one of hidden prototypes, just shadow it.
           if (real_holder != isolate->context()->global()) break;
-          return isolate->heap()->undefined_value();
+          return ThrowRedeclarationError(isolate, "const", name);
         }
       }

=======================================
--- /branches/bleeding_edge/src/v8natives.js    Mon Aug  1 05:18:03 2011
+++ /branches/bleeding_edge/src/v8natives.js    Wed Aug  3 02:53:14 2011
@@ -162,14 +162,13 @@

 function SetupGlobal() {
   // ECMA 262 - 15.1.1.1.
-  %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY);
+  %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE);

   // ECMA-262 - 15.1.1.2.
- %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE | READ_ONLY);
+  %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE);

   // ECMA-262 - 15.1.1.3.
-  %SetProperty(global, "undefined", void 0,
-               DONT_ENUM | DONT_DELETE | READ_ONLY);
+  %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE);

   // Setup non-enumerable function on the global object.
   InstallFunctions(global, DONT_ENUM, $Array(
=======================================
--- /branches/bleeding_edge/test/cctest/test-decls.cc Mon Aug 1 05:18:03 2011 +++ /branches/bleeding_edge/test/cctest/test-decls.cc Wed Aug 3 02:53:14 2011
@@ -498,7 +498,7 @@
                   0,
                   2,  // var declaration + const initialization
                   4,  // 2 x declaration + 2 x initialization
-                  EXPECT_RESULT, Undefined());  // x = 0 fails for a const.
+                  EXPECT_EXCEPTION);  // x has already been declared!
   }
 }

=======================================
--- /branches/bleeding_edge/test/es5conform/es5conform.status Mon Aug 1 05:18:03 2011 +++ /branches/bleeding_edge/test/es5conform/es5conform.status Wed Aug 3 02:53:14 2011
@@ -41,6 +41,16 @@
 # We are compatible with Safari and Firefox.
 chapter11/11.1/11.1.5: UNIMPLEMENTED

+# We do not have a global object called 'global' as required by tests.
+chapter15/15.1: FAIL_OK
+
+# NaN is writable. We are compatible with JSC.
+chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-178: FAIL_OK
+# Infinity is writable. We are compatible with JSC.
+chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-179: FAIL_OK
+# undefined is writable. We are compatible with JSC.
+chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-180: FAIL_OK
+
 # Our Function object has an "arguments" property which is used as a
 # non-property in the test.
 chapter15/15.2/15.2.3/15.2.3.3/15.2.3.3-4-183: FAIL_OK
=======================================
--- /branches/bleeding_edge/test/mjsunit/undeletable-functions.js Mon Aug 1 05:18:03 2011 +++ /branches/bleeding_edge/test/mjsunit/undeletable-functions.js Wed Aug 3 02:53:14 2011
@@ -76,8 +76,6 @@
   "execScript"];
 CheckEcmaSemantics(this, array, "Global");
 CheckReadOnlyAttr(this, "Infinity");
-CheckReadOnlyAttr(this, "NaN");
-CheckReadOnlyAttr(this, "undefined");

 array = ["exec", "test", "toString", "compile"];
 CheckEcmaSemantics(RegExp.prototype, array, "RegExp prototype");
@@ -191,7 +189,7 @@
   assertFalse(deleted, "delete operator returned true: " + prop);
   assertTrue(type.hasOwnProperty(prop), "not there after delete: " + prop);
   type[prop] = "foo";
-  assertEquals(old, type[prop], "overwritable: " + prop);
+  assertEquals("foo", type[prop], "overwritable: " + prop);
 }

 print("OK");
=======================================
--- /branches/bleeding_edge/test/sputnik/sputnik.status Mon Aug 1 05:18:03 2011 +++ /branches/bleeding_edge/test/sputnik/sputnik.status Wed Aug 3 02:53:14 2011
@@ -178,17 +178,6 @@
 S15.5.4.14_A1_T3: FAIL_OK
 S15.5.4.15_A1_T3: FAIL_OK

-# NaN, Infinity and undefined are read-only according to ES5.
-S15.1.1.1_A2_T1: FAIL_OK  # NaN
-S15.1.1.1_A2_T2: FAIL_OK  # NaN
-S15.1.1.2_A2_T1: FAIL_OK  # Infinity
-# S15.1.1.2_A2_T2 would fail if it weren't bogus in r97. sputnik bug #45.
-S15.1.1.3_A2_T1: FAIL_OK  # undefined
-S15.1.1.3_A2_T2: FAIL_OK  # undefined
-S8.1_A3: FAIL_OK # undefined (comment is correct, test itself is bogus/ES3)
-S8.5_A4: FAIL_OK  # NaN
-S8.5_A10: FAIL_OK  # Infinity
-
 ##################### SKIPPED TESTS #####################

 # These tests take a looong time to run in debug mode.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to