OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 "use strict"; | 5 "use strict"; |
6 | 6 |
7 // This list must be in sync with the enum in ExceptionCode.h. The order matter
s. | 7 var installedClasses = {}; |
8 var domExceptions = [ | |
9 "IndexSizeError", | |
10 "HierarchyRequestError", | |
11 "WrongDocumentError", | |
12 "InvalidCharacterError", | |
13 "NoModificationAllowedError", | |
14 "NotFoundError", | |
15 "NotSupportedError", | |
16 "InUseAttributeError", // Historical. Only used in setAttributeNode etc whic
h have been removed from the DOM specs. | |
17 | |
18 // Introduced in DOM Level 2: | |
19 "InvalidStateError", | |
20 "SyntaxError", | |
21 "InvalidModificationError", | |
22 "NamespaceError", | |
23 "InvalidAccessError", | |
24 | |
25 // Introduced in DOM Level 3: | |
26 "TypeMismatchError", // Historical; use TypeError instead | |
27 | |
28 // XMLHttpRequest extension: | |
29 "SecurityError", | |
30 | |
31 // Others introduced in HTML5: | |
32 "NetworkError", | |
33 "AbortError", | |
34 "URLMismatchError", | |
35 "QuotaExceededError", | |
36 "TimeoutError", | |
37 "InvalidNodeTypeError", | |
38 "DataCloneError", | |
39 | |
40 // These are IDB-specific. | |
41 "UnknownError", | |
42 "ConstraintError", | |
43 "DataError", | |
44 "TransactionInactiveError", | |
45 "ReadOnlyError", | |
46 "VersionError", | |
47 | |
48 // File system | |
49 "NotReadableError", | |
50 "EncodingError", | |
51 "PathExistsError", | |
52 | |
53 // SQL | |
54 "SQLDatabaseError", // Naming conflict with DatabaseError class. | |
55 | |
56 // Web Crypto | |
57 "OperationError", | |
58 ]; | |
59 | |
60 var domExceptionCode = {}; | 8 var domExceptionCode = {}; |
61 var installedClasses = {}; | |
62 | |
63 function init() | |
64 { | |
65 var code = 1; | |
66 domExceptions.forEach(function (exception) { | |
67 domExceptionCode[exception] = code; | |
68 code++; | |
69 }); | |
70 } | |
71 | 9 |
72 function DOMExceptionInPrivateScript(code, message) | 10 function DOMExceptionInPrivateScript(code, message) |
73 { | 11 { |
74 this.code = domExceptionCode[code] || 0; | 12 this.code = domExceptionCode[code] || 0; |
75 this.message = message; | 13 this.message = message; |
76 this.name = "DOMExceptionInPrivateScript"; | 14 this.name = "DOMExceptionInPrivateScript"; |
77 } | 15 } |
78 | 16 |
79 function privateScriptClass() | |
80 { | |
81 } | |
82 | |
83 function installClass(className, implementation) | 17 function installClass(className, implementation) |
84 { | 18 { |
| 19 function privateScriptClass() |
| 20 { |
| 21 } |
| 22 |
85 if (!(className in installedClasses)) | 23 if (!(className in installedClasses)) |
86 installedClasses[className] = new privateScriptClass(); | 24 installedClasses[className] = new privateScriptClass(); |
87 implementation(window, installedClasses[className]); | 25 implementation(installedClasses[className]); |
88 } | 26 } |
89 | 27 |
90 init(); | 28 (function (global) { |
| 29 // This list must be in sync with the enum in ExceptionCode.h. The order mat
ters. |
| 30 var domExceptions = [ |
| 31 "IndexSizeError", |
| 32 "HierarchyRequestError", |
| 33 "WrongDocumentError", |
| 34 "InvalidCharacterError", |
| 35 "NoModificationAllowedError", |
| 36 "NotFoundError", |
| 37 "NotSupportedError", |
| 38 "InUseAttributeError", // Historical. Only used in setAttributeNode etc
which have been removed from the DOM specs. |
| 39 |
| 40 // Introduced in DOM Level 2: |
| 41 "InvalidStateError", |
| 42 "SyntaxError", |
| 43 "InvalidModificationError", |
| 44 "NamespaceError", |
| 45 "InvalidAccessError", |
| 46 |
| 47 // Introduced in DOM Level 3: |
| 48 "TypeMismatchError", // Historical; use TypeError instead |
| 49 |
| 50 // XMLHttpRequest extension: |
| 51 "SecurityError", |
| 52 |
| 53 // Others introduced in HTML5: |
| 54 "NetworkError", |
| 55 "AbortError", |
| 56 "URLMismatchError", |
| 57 "QuotaExceededError", |
| 58 "TimeoutError", |
| 59 "InvalidNodeTypeError", |
| 60 "DataCloneError", |
| 61 |
| 62 // These are IDB-specific. |
| 63 "UnknownError", |
| 64 "ConstraintError", |
| 65 "DataError", |
| 66 "TransactionInactiveError", |
| 67 "ReadOnlyError", |
| 68 "VersionError", |
| 69 |
| 70 // File system |
| 71 "NotReadableError", |
| 72 "EncodingError", |
| 73 "PathExistsError", |
| 74 |
| 75 // SQL |
| 76 "SQLDatabaseError", // Naming conflict with DatabaseError class. |
| 77 |
| 78 // Web Crypto |
| 79 "OperationError", |
| 80 ]; |
| 81 |
| 82 var code = 1; |
| 83 domExceptions.forEach(function (exception) { |
| 84 global.domExceptionCode[exception] = code; |
| 85 code++; |
| 86 }); |
| 87 })(window); |
91 | 88 |
92 // This line must be the last statement of this JS file. | 89 // This line must be the last statement of this JS file. |
93 // A parenthesis is needed, because the caller of this script (PrivateScriptRunn
er.cpp) | 90 // A parenthesis is needed, because the caller of this script (PrivateScriptRunn
er.cpp) |
94 // is depending on the completion value of this script. | 91 // is depending on the completion value of this script. |
95 (installedClasses); | 92 (installedClasses); |
OLD | NEW |