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

Unified Diff: Source/bindings/core/v8/PrivateScriptRunner.js

Issue 466623002: Refactor PrivateScriptRunner.js to reduce the number of globally exposed variables (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « no previous file | Source/core/html/HTMLMarqueeElement.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/PrivateScriptRunner.js
diff --git a/Source/bindings/core/v8/PrivateScriptRunner.js b/Source/bindings/core/v8/PrivateScriptRunner.js
index 88b9bed2f82cd428c1828486d87aedf4fbf51950..a9713204548bb24d6e0d12ebeeea8ce2610fe991 100644
--- a/Source/bindings/core/v8/PrivateScriptRunner.js
+++ b/Source/bindings/core/v8/PrivateScriptRunner.js
@@ -4,70 +4,8 @@
"use strict";
-// This list must be in sync with the enum in ExceptionCode.h. The order matters.
-var domExceptions = [
- "IndexSizeError",
- "HierarchyRequestError",
- "WrongDocumentError",
- "InvalidCharacterError",
- "NoModificationAllowedError",
- "NotFoundError",
- "NotSupportedError",
- "InUseAttributeError", // Historical. Only used in setAttributeNode etc which have been removed from the DOM specs.
-
- // Introduced in DOM Level 2:
- "InvalidStateError",
- "SyntaxError",
- "InvalidModificationError",
- "NamespaceError",
- "InvalidAccessError",
-
- // Introduced in DOM Level 3:
- "TypeMismatchError", // Historical; use TypeError instead
-
- // XMLHttpRequest extension:
- "SecurityError",
-
- // Others introduced in HTML5:
- "NetworkError",
- "AbortError",
- "URLMismatchError",
- "QuotaExceededError",
- "TimeoutError",
- "InvalidNodeTypeError",
- "DataCloneError",
-
- // These are IDB-specific.
- "UnknownError",
- "ConstraintError",
- "DataError",
- "TransactionInactiveError",
- "ReadOnlyError",
- "VersionError",
-
- // File system
- "NotReadableError",
- "EncodingError",
- "PathExistsError",
-
- // SQL
- "SQLDatabaseError", // Naming conflict with DatabaseError class.
-
- // Web Crypto
- "OperationError",
-];
-
-var domExceptionCode = {};
var installedClasses = {};
-
-function init()
-{
- var code = 1;
- domExceptions.forEach(function (exception) {
- domExceptionCode[exception] = code;
- code++;
- });
-}
+var domExceptionCode = {};
function DOMExceptionInPrivateScript(code, message)
{
@@ -76,18 +14,77 @@ function DOMExceptionInPrivateScript(code, message)
this.name = "DOMExceptionInPrivateScript";
}
-function privateScriptClass()
-{
-}
-
function installClass(className, implementation)
{
+ function privateScriptClass()
+ {
+ }
+
if (!(className in installedClasses))
installedClasses[className] = new privateScriptClass();
- implementation(window, installedClasses[className]);
+ implementation(installedClasses[className]);
}
-init();
+(function (global) {
+ // This list must be in sync with the enum in ExceptionCode.h. The order matters.
+ var domExceptions = [
+ "IndexSizeError",
+ "HierarchyRequestError",
+ "WrongDocumentError",
+ "InvalidCharacterError",
+ "NoModificationAllowedError",
+ "NotFoundError",
+ "NotSupportedError",
+ "InUseAttributeError", // Historical. Only used in setAttributeNode etc which have been removed from the DOM specs.
+
+ // Introduced in DOM Level 2:
+ "InvalidStateError",
+ "SyntaxError",
+ "InvalidModificationError",
+ "NamespaceError",
+ "InvalidAccessError",
+
+ // Introduced in DOM Level 3:
+ "TypeMismatchError", // Historical; use TypeError instead
+
+ // XMLHttpRequest extension:
+ "SecurityError",
+
+ // Others introduced in HTML5:
+ "NetworkError",
+ "AbortError",
+ "URLMismatchError",
+ "QuotaExceededError",
+ "TimeoutError",
+ "InvalidNodeTypeError",
+ "DataCloneError",
+
+ // These are IDB-specific.
+ "UnknownError",
+ "ConstraintError",
+ "DataError",
+ "TransactionInactiveError",
+ "ReadOnlyError",
+ "VersionError",
+
+ // File system
+ "NotReadableError",
+ "EncodingError",
+ "PathExistsError",
+
+ // SQL
+ "SQLDatabaseError", // Naming conflict with DatabaseError class.
+
+ // Web Crypto
+ "OperationError",
+ ];
+
+ var code = 1;
+ domExceptions.forEach(function (exception) {
+ global.domExceptionCode[exception] = code;
+ code++;
+ });
+})(window);
// This line must be the last statement of this JS file.
// A parenthesis is needed, because the caller of this script (PrivateScriptRunner.cpp)
« no previous file with comments | « no previous file | Source/core/html/HTMLMarqueeElement.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698