Reviewers: Mads Ager, Lasse Reichstein,
Message:
This came up as part of strict mode work. Firefox and Safari already have
NaN,
Infinity and undefined as writable: false.
The only difference now is how they treat redeclaration of constants. V8
throws,
others are silent about it.
http://codereview.chromium.org/6580056/diff/1/test/es5conform/es5conform.status
File test/es5conform/es5conform.status (left):
http://codereview.chromium.org/6580056/diff/1/test/es5conform/es5conform.status#oldcode47
test/es5conform/es5conform.status:47: # NaN is writable. We are
compatible with JSC.
Both Safari and Firefox have Nan, Infinity and undefined as writable:
false
Where we differ now is that V8 throws on redeclaration of those globals
whereas jsc and firefox don't
Description:
Make global NaN, Infinity and undefined read only.
Change test expectation files where tests now pass, or newly fail.
BUG=
TEST=sputnik, es5conform, mozilla
Please review this at http://codereview.chromium.org/6580056/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/v8natives.js
M test/es5conform/es5conform.status
M test/mjsunit/undeletable-functions.js
M test/sputnik/sputnik.status
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index
91e19c13d8ed6c4f70e268961e6228e2ee7822eb..013f54860dcb7b3dac6c39c095139c721bd4a710
100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -163,13 +163,14 @@ function GlobalExecScript(expr, lang) {
function SetupGlobal() {
// ECMA 262 - 15.1.1.1.
- %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE);
+ %SetProperty(global, "NaN", $NaN, DONT_ENUM | DONT_DELETE | READ_ONLY);
// ECMA-262 - 15.1.1.2.
- %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE);
+ %SetProperty(global, "Infinity", 1/0, DONT_ENUM | DONT_DELETE |
READ_ONLY);
// ECMA-262 - 15.1.1.3.
- %SetProperty(global, "undefined", void 0, DONT_ENUM | DONT_DELETE);
+ %SetProperty(global, "undefined", void 0,
+ DONT_ENUM | DONT_DELETE | READ_ONLY);
// Setup non-enumerable function on the global object.
InstallFunctions(global, DONT_ENUM, $Array(
Index: test/es5conform/es5conform.status
diff --git a/test/es5conform/es5conform.status
b/test/es5conform/es5conform.status
index
e021fc54dc6e2b265aac5cb00e13398e034d3deb..aabb2ff0e11a80264a64013291bb770e13080f94
100644
--- a/test/es5conform/es5conform.status
+++ b/test/es5conform/es5conform.status
@@ -36,21 +36,6 @@ chapter10/10.4/10.4.2/10.4.2-3-c-2-s: FAIL_OK
chapter10/10.4/10.4.2/10.4.2-3-c-1-s: FAIL_OK
chapter10/10.4/10.4.2/10.4.2-2-c-1: FAIL_OK
-# We do not implement the error chekcs specified in the production rules
-# of 11.1.5 (Object initializer).
-# 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
Index: test/mjsunit/undeletable-functions.js
diff --git a/test/mjsunit/undeletable-functions.js
b/test/mjsunit/undeletable-functions.js
index
04fd06068d0b7b7616070b143ec4aa4b9c015a36..6a0fe8dab1f376c1a505d8d02d5525cc05b0555f
100644
--- a/test/mjsunit/undeletable-functions.js
+++ b/test/mjsunit/undeletable-functions.js
@@ -189,7 +189,7 @@ function CheckReadOnlyAttr(type, prop) {
assertFalse(deleted, "delete operator returned true: " + prop);
assertTrue(type.hasOwnProperty(prop), "not there after delete: " + prop);
type[prop] = "foo";
- assertEquals("foo", type[prop], "overwritable: " + prop);
+ assertEquals(old, type[prop], "not overwritable: " + prop);
}
print("OK");
Index: test/sputnik/sputnik.status
diff --git a/test/sputnik/sputnik.status b/test/sputnik/sputnik.status
index
6da87eac95acb69806dafab2271e5cf092412055..237a3d5682cb4cb0097527ade6092f55959f2486
100644
--- a/test/sputnik/sputnik.status
+++ b/test/sputnik/sputnik.status
@@ -186,6 +186,24 @@ S9.9_A2: FAIL_OK
S15.1.3.2_A2.5_T1: PASS, SKIP if $mode == debug
S15.1.3.1_A2.5_T1: PASS, SKIP if $mode == debug
+# Invalid test: NaN is read only (ES5 15.1.1.1)
+# Should V8 throw or ignore the assignment?
+S8.5_A4: FAIL
+S15.1.1.1_A2_T1: FAIL
+S15.1.1.1_A2_T2: FAIL
+# Invalid test: Infinity is read only (ES5 15.1.1.2)
+# Should V8 throw or ignore the assignment?
+S8.5_A10: FAIL
+S15.1.1.2_A2_T1: FAIL
+
+# Invalid test: V8 correctly throws TypeError on assignment to undefined
+# but Sputnik still not happy.
+S8.1_A3: FAIL
+# Invalid test: undefined is read only (ES5 15.1.1.3)
+# Should V8 throw or ignore the assignment?
+S15.1.1.3_A2_T1: FAIL
+S15.1.1.3_A2_T2: FAIL
+
# V8 Bug: http://code.google.com/p/v8/issues/detail?id=1196
S8.7_A5_T2: FAIL
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev