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

Unified Diff: src/messages.js

Issue 7736018: Make functions on the built-in object non-writable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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
Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index cbbb70eb1a8e37392676cc8258cdfb17afacd89b..0a00d356246a52a0e7ae62e924f921ba6e8f959f 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -29,17 +29,17 @@
// -------------------------------------------------------------------
//
// Matches Script::Type from objects.h
-var TYPE_NATIVE = 0;
-var TYPE_EXTENSION = 1;
-var TYPE_NORMAL = 2;
+const TYPE_NATIVE = 0;
Kevin Millikin (Chromium) 2011/09/01 07:58:24 Is this change necessary? If it is, can you inste
Lasse Reichstein 2011/09/01 09:26:58 Nothing here is *necessary*, but it's an attempt t
Kevin Millikin (Chromium) 2011/09/01 09:53:14 I think something like that, even if you have to i
+const TYPE_EXTENSION = 1;
+const TYPE_NORMAL = 2;
// Matches Script::CompilationType from objects.h
-var COMPILATION_TYPE_HOST = 0;
-var COMPILATION_TYPE_EVAL = 1;
-var COMPILATION_TYPE_JSON = 2;
+const COMPILATION_TYPE_HOST = 0;
+const COMPILATION_TYPE_EVAL = 1;
+const COMPILATION_TYPE_JSON = 2;
// Matches Messages::kNoLineNumberInfo from v8.h
-var kNoLineNumberInfo = 0;
+const kNoLineNumberInfo = 0;
// If this object gets passed to an error constructor the error will
// get an accessor for .message that constructs a descriptive error
@@ -1007,7 +1007,7 @@ function DefineError(f) {
// user code.
var name = f.name;
%SetProperty(global, name, f, DONT_ENUM);
- this['$' + name] = f;
+ %SetProperty(this, '$' + name, f, DONT_ENUM | DONT_DELETE | READ_ONLY);
// Configure the error function.
if (name == 'Error') {
// The prototype of the Error object must itself be an error.
@@ -1024,7 +1024,7 @@ function DefineError(f) {
%FunctionSetInstanceClassName(f, 'Error');
%SetProperty(f.prototype, 'constructor', f, DONT_ENUM);
// The name property on the prototype of error objects is not
- // specified as being read-one and dont-delete. However, allowing
+ // specified as being read-only and dont-delete. However, allowing
// overwriting allows leaks of error objects between script blocks
// in the same context in a browser setting. Therefore we fix the
// name.

Powered by Google App Engine
This is Rietveld 408576698