| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 "use strict"; | 30 "use strict"; |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * @param {!InjectedScriptHostClass} InjectedScriptHost | 33 * @param {!InjectedScriptHostClass} InjectedScriptHost |
| 34 * @param {!Window} inspectedWindow | 34 * @param {!Window|!WorkerGlobalScope} inspectedGlobalObject |
| 35 * @param {number} injectedScriptId | 35 * @param {number} injectedScriptId |
| 36 */ | 36 */ |
| 37 (function (InjectedScriptHost, inspectedWindow, injectedScriptId) { | 37 (function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId) { |
| 38 | 38 |
| 39 /** | 39 /** |
| 40 * Protect against Object overwritten by the user code. | 40 * Protect against Object overwritten by the user code. |
| 41 * @suppress {duplicate} | 41 * @suppress {duplicate} |
| 42 */ | 42 */ |
| 43 var Object = /** @type {function(new:Object, *=)} */ ({}.constructor); | 43 var Object = /** @type {function(new:Object, *=)} */ ({}.constructor); |
| 44 | 44 |
| 45 /** | 45 /** |
| 46 * @param {!Array.<T>} array | 46 * @param {!Array.<T>} array |
| 47 * @param {...} var_args | 47 * @param {...} var_args |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 | 237 |
| 238 /** | 238 /** |
| 239 * @param {!Object} object | 239 * @param {!Object} object |
| 240 * @param {string} attribute | 240 * @param {string} attribute |
| 241 * @return {boolean} | 241 * @return {boolean} |
| 242 */ | 242 */ |
| 243 function doesAttributeHaveObservableSideEffectOnGet(object, attribute) | 243 function doesAttributeHaveObservableSideEffectOnGet(object, attribute) |
| 244 { | 244 { |
| 245 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) { | 245 for (var interfaceName in domAttributesWithObservableSideEffectOnGet) { |
| 246 var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(func
tion(object, interfaceName) { | 246 var isInstance = InjectedScriptHost.suppressWarningsAndCallFunction(func
tion(object, interfaceName) { |
| 247 return /* suppressBlacklist */ typeof inspectedWindow[interfaceName]
=== "function" && object instanceof inspectedWindow[interfaceName]; | 247 return /* suppressBlacklist */ typeof inspectedGlobalObject[interfac
eName] === "function" && object instanceof inspectedGlobalObject[interfaceName]; |
| 248 }, null, [object, interfaceName]); | 248 }, null, [object, interfaceName]); |
| 249 if (isInstance) { | 249 if (isInstance) { |
| 250 return attribute in domAttributesWithObservableSideEffectOnGet[inter
faceName]; | 250 return attribute in domAttributesWithObservableSideEffectOnGet[inter
faceName]; |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 return false; | 253 return false; |
| 254 } | 254 } |
| 255 | 255 |
| 256 /** | 256 /** |
| 257 * @constructor | 257 * @constructor |
| (...skipping 23 matching lines...) Expand all Loading... |
| 281 */ | 281 */ |
| 282 isPrimitiveValue: function(object) | 282 isPrimitiveValue: function(object) |
| 283 { | 283 { |
| 284 // FIXME(33716): typeof document.all is always 'undefined'. | 284 // FIXME(33716): typeof document.all is always 'undefined'. |
| 285 return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllC
ollection(object); | 285 return InjectedScript.primitiveTypes[typeof object] && !this._isHTMLAllC
ollection(object); |
| 286 }, | 286 }, |
| 287 | 287 |
| 288 /** | 288 /** |
| 289 * @param {*} object | 289 * @param {*} object |
| 290 * @param {string} groupName | 290 * @param {string} groupName |
| 291 * @param {boolean} canAccessInspectedWindow | 291 * @param {boolean} canAccessInspectedGlobalObject |
| 292 * @param {boolean} generatePreview | 292 * @param {boolean} generatePreview |
| 293 * @return {!RuntimeAgent.RemoteObject} | 293 * @return {!RuntimeAgent.RemoteObject} |
| 294 */ | 294 */ |
| 295 wrapObject: function(object, groupName, canAccessInspectedWindow, generatePr
eview) | 295 wrapObject: function(object, groupName, canAccessInspectedGlobalObject, gene
ratePreview) |
| 296 { | 296 { |
| 297 if (canAccessInspectedWindow) | 297 if (canAccessInspectedGlobalObject) |
| 298 return this._wrapObject(object, groupName, false, generatePreview); | 298 return this._wrapObject(object, groupName, false, generatePreview); |
| 299 return this._fallbackWrapper(object); | 299 return this._fallbackWrapper(object); |
| 300 }, | 300 }, |
| 301 | 301 |
| 302 /** | 302 /** |
| 303 * @param {*} object | 303 * @param {*} object |
| 304 * @param {string} groupName | 304 * @param {string} groupName |
| 305 * @param {boolean=} doNotBind | 305 * @param {boolean=} doNotBind |
| 306 * @return {!RuntimeAgent.RemoteObject} | 306 * @return {!RuntimeAgent.RemoteObject} |
| 307 */ | 307 */ |
| (...skipping 11 matching lines...) Expand all Loading... |
| 319 var result = { __proto__: null }; | 319 var result = { __proto__: null }; |
| 320 result.type = typeof object; | 320 result.type = typeof object; |
| 321 if (this.isPrimitiveValue(object)) | 321 if (this.isPrimitiveValue(object)) |
| 322 result.value = object; | 322 result.value = object; |
| 323 else | 323 else |
| 324 result.description = toString(object); | 324 result.description = toString(object); |
| 325 return /** @type {!RuntimeAgent.RemoteObject} */ (result); | 325 return /** @type {!RuntimeAgent.RemoteObject} */ (result); |
| 326 }, | 326 }, |
| 327 | 327 |
| 328 /** | 328 /** |
| 329 * @param {boolean} canAccessInspectedWindow | 329 * @param {boolean} canAccessInspectedGlobalObject |
| 330 * @param {!Object} table | 330 * @param {!Object} table |
| 331 * @param {!Array.<string>|string|boolean} columns | 331 * @param {!Array.<string>|string|boolean} columns |
| 332 * @return {!RuntimeAgent.RemoteObject} | 332 * @return {!RuntimeAgent.RemoteObject} |
| 333 */ | 333 */ |
| 334 wrapTable: function(canAccessInspectedWindow, table, columns) | 334 wrapTable: function(canAccessInspectedGlobalObject, table, columns) |
| 335 { | 335 { |
| 336 if (!canAccessInspectedWindow) | 336 if (!canAccessInspectedGlobalObject) |
| 337 return this._fallbackWrapper(table); | 337 return this._fallbackWrapper(table); |
| 338 var columnNames = null; | 338 var columnNames = null; |
| 339 if (typeof columns === "string") | 339 if (typeof columns === "string") |
| 340 columns = [columns]; | 340 columns = [columns]; |
| 341 if (InjectedScriptHost.subtype(columns) === "array") { | 341 if (InjectedScriptHost.subtype(columns) === "array") { |
| 342 columnNames = []; | 342 columnNames = []; |
| 343 for (var i = 0; i < columns.length; ++i) | 343 for (var i = 0; i < columns.length; ++i) |
| 344 columnNames[i] = toString(columns[i]); | 344 columnNames[i] = toString(columns[i]); |
| 345 } | 345 } |
| 346 return this._wrapObject(table, "console", false, true, columnNames, true
); | 346 return this._wrapObject(table, "console", false, true, columnNames, true
); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 /** | 417 /** |
| 418 * @param {string} methodName | 418 * @param {string} methodName |
| 419 * @param {string} args | 419 * @param {string} args |
| 420 * @return {*} | 420 * @return {*} |
| 421 */ | 421 */ |
| 422 dispatch: function(methodName, args) | 422 dispatch: function(methodName, args) |
| 423 { | 423 { |
| 424 var argsArray = /** @type {!Array.<*>} */ (InjectedScriptHost.eval("(" +
args + ")")); | 424 var argsArray = /** @type {!Array.<*>} */ (InjectedScriptHost.eval("(" +
args + ")")); |
| 425 var result = InjectedScriptHost.callFunction(this[methodName], this, arg
sArray); | 425 var result = InjectedScriptHost.callFunction(this[methodName], this, arg
sArray); |
| 426 if (typeof result === "undefined") { | 426 if (typeof result === "undefined") { |
| 427 inspectedWindow.console.error("Web Inspector error: InjectedScript.%
s returns undefined", methodName); | 427 inspectedGlobalObject.console.error("Web Inspector error: InjectedSc
ript.%s returns undefined", methodName); |
| 428 result = null; | 428 result = null; |
| 429 } | 429 } |
| 430 return result; | 430 return result; |
| 431 }, | 431 }, |
| 432 | 432 |
| 433 /** | 433 /** |
| 434 * @param {string} objectId | 434 * @param {string} objectId |
| 435 * @param {boolean} ownProperties | 435 * @param {boolean} ownProperties |
| 436 * @param {boolean} accessorPropertiesOnly | 436 * @param {boolean} accessorPropertiesOnly |
| 437 * @param {boolean} generatePreview | 437 * @param {boolean} generatePreview |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 * @this {InjectedScript} | 733 * @this {InjectedScript} |
| 734 */ | 734 */ |
| 735 function wrap(object, forceValueType, generatePreview, columnNames, isTa
ble, customObjectConfig) | 735 function wrap(object, forceValueType, generatePreview, columnNames, isTa
ble, customObjectConfig) |
| 736 { | 736 { |
| 737 return this._wrapObject(object, objectGroup, forceValueType, generat
ePreview, columnNames, isTable, false, customObjectConfig); | 737 return this._wrapObject(object, objectGroup, forceValueType, generat
ePreview, columnNames, isTable, false, customObjectConfig); |
| 738 } | 738 } |
| 739 | 739 |
| 740 try { | 740 try { |
| 741 | 741 |
| 742 var remoteObjectAPI = { bindRemoteObject: bind(wrap, this), __proto_
_: null}; | 742 var remoteObjectAPI = { bindRemoteObject: bind(wrap, this), __proto_
_: null}; |
| 743 InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__remoteObje
ctAPI", remoteObjectAPI); | 743 InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__remo
teObjectAPI", remoteObjectAPI); |
| 744 | 744 |
| 745 var func = InjectedScriptHost.eval("with (typeof __remoteObjectAPI !
== 'undefined' ? __remoteObjectAPI : { __proto__: null }) {(" + expression + ")}
"); | 745 var func = InjectedScriptHost.eval("with (typeof __remoteObjectAPI !
== 'undefined' ? __remoteObjectAPI : { __proto__: null }) {(" + expression + ")}
"); |
| 746 if (typeof func !== "function") | 746 if (typeof func !== "function") |
| 747 return "Given expression does not evaluate to a function"; | 747 return "Given expression does not evaluate to a function"; |
| 748 | 748 |
| 749 return { wasThrown: false, | 749 return { wasThrown: false, |
| 750 result: this._wrapObject(InjectedScriptHost.callFunction(fu
nc, object, resolvedArgs), objectGroup, returnByValue), | 750 result: this._wrapObject(InjectedScriptHost.callFunction(fu
nc, object, resolvedArgs), objectGroup, returnByValue), |
| 751 __proto__: null }; | 751 __proto__: null }; |
| 752 } catch (e) { | 752 } catch (e) { |
| 753 return this._createThrownValue(e, objectGroup, false); | 753 return this._createThrownValue(e, objectGroup, false); |
| 754 } finally { | 754 } finally { |
| 755 try { | 755 try { |
| 756 delete inspectedWindow["__remoteObjectAPI"]; | 756 delete inspectedGlobalObject["__remoteObjectAPI"]; |
| 757 } catch(e) { | 757 } catch(e) { |
| 758 } | 758 } |
| 759 } | 759 } |
| 760 }, | 760 }, |
| 761 | 761 |
| 762 /** | 762 /** |
| 763 * @param {string|undefined} objectGroupName | 763 * @param {string|undefined} objectGroupName |
| 764 * @param {*} jsonMLObject | 764 * @param {*} jsonMLObject |
| 765 * @throws {string} error message | 765 * @throws {string} error message |
| 766 */ | 766 */ |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 * @return {*} | 870 * @return {*} |
| 871 */ | 871 */ |
| 872 _evaluateOn: function(callFrame, objectGroup, expression, injectCommandLineA
PI, scopeChain) | 872 _evaluateOn: function(callFrame, objectGroup, expression, injectCommandLineA
PI, scopeChain) |
| 873 { | 873 { |
| 874 // Only install command line api object for the time of evaluation. | 874 // Only install command line api object for the time of evaluation. |
| 875 // Surround the expression in with statements to inject our command line
API so that | 875 // Surround the expression in with statements to inject our command line
API so that |
| 876 // the window object properties still take more precedent than our API f
unctions. | 876 // the window object properties still take more precedent than our API f
unctions. |
| 877 | 877 |
| 878 var scopeExtensionForEval = (callFrame && injectCommandLineAPI) ? new Co
mmandLineAPI(this._commandLineAPIImpl, callFrame) : undefined; | 878 var scopeExtensionForEval = (callFrame && injectCommandLineAPI) ? new Co
mmandLineAPI(this._commandLineAPIImpl, callFrame) : undefined; |
| 879 | 879 |
| 880 injectCommandLineAPI = !scopeExtensionForEval && !callFrame && injectCom
mandLineAPI && !("__commandLineAPI" in inspectedWindow); | 880 injectCommandLineAPI = !scopeExtensionForEval && !callFrame && injectCom
mandLineAPI && !("__commandLineAPI" in inspectedGlobalObject); |
| 881 var injectScopeChain = scopeChain && scopeChain.length && !("__scopeChai
nForEval" in inspectedWindow); | 881 var injectScopeChain = scopeChain && scopeChain.length && !("__scopeChai
nForEval" in inspectedGlobalObject); |
| 882 | 882 |
| 883 try { | 883 try { |
| 884 var prefix = ""; | 884 var prefix = ""; |
| 885 var suffix = ""; | 885 var suffix = ""; |
| 886 if (injectCommandLineAPI) { | 886 if (injectCommandLineAPI) { |
| 887 InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__comman
dLineAPI", new CommandLineAPI(this._commandLineAPIImpl, callFrame)); | 887 InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__
commandLineAPI", new CommandLineAPI(this._commandLineAPIImpl, callFrame)); |
| 888 prefix = "with (typeof __commandLineAPI !== 'undefined' ? __comm
andLineAPI : { __proto__: null }) {"; | 888 prefix = "with (typeof __commandLineAPI !== 'undefined' ? __comm
andLineAPI : { __proto__: null }) {"; |
| 889 suffix = "}"; | 889 suffix = "}"; |
| 890 } | 890 } |
| 891 if (injectScopeChain) { | 891 if (injectScopeChain) { |
| 892 InjectedScriptHost.setNonEnumProperty(inspectedWindow, "__scopeC
hainForEval", scopeChain); | 892 InjectedScriptHost.setNonEnumProperty(inspectedGlobalObject, "__
scopeChainForEval", scopeChain); |
| 893 for (var i = 0; i < scopeChain.length; ++i) { | 893 for (var i = 0; i < scopeChain.length; ++i) { |
| 894 prefix = "with (typeof __scopeChainForEval !== 'undefined' ?
__scopeChainForEval[" + i + "] : { __proto__: null }) {" + (suffix ? " " : "")
+ prefix; | 894 prefix = "with (typeof __scopeChainForEval !== 'undefined' ?
__scopeChainForEval[" + i + "] : { __proto__: null }) {" + (suffix ? " " : "")
+ prefix; |
| 895 if (suffix) | 895 if (suffix) |
| 896 suffix += " }"; | 896 suffix += " }"; |
| 897 else | 897 else |
| 898 suffix = "}"; | 898 suffix = "}"; |
| 899 } | 899 } |
| 900 } | 900 } |
| 901 | 901 |
| 902 if (prefix) | 902 if (prefix) |
| 903 expression = prefix + "\n" + expression + "\n" + suffix; | 903 expression = prefix + "\n" + expression + "\n" + suffix; |
| 904 var wrappedResult = callFrame ? callFrame.evaluateWithExceptionDetai
ls(expression, scopeExtensionForEval) : InjectedScriptHost.evaluateWithException
Details(expression); | 904 var wrappedResult = callFrame ? callFrame.evaluateWithExceptionDetai
ls(expression, scopeExtensionForEval) : InjectedScriptHost.evaluateWithException
Details(expression); |
| 905 if (objectGroup === "console" && !wrappedResult.exceptionDetails) | 905 if (objectGroup === "console" && !wrappedResult.exceptionDetails) |
| 906 this._lastResult = wrappedResult.result; | 906 this._lastResult = wrappedResult.result; |
| 907 return wrappedResult; | 907 return wrappedResult; |
| 908 } finally { | 908 } finally { |
| 909 if (injectCommandLineAPI) { | 909 if (injectCommandLineAPI) { |
| 910 try { | 910 try { |
| 911 delete inspectedWindow["__commandLineAPI"]; | 911 delete inspectedGlobalObject["__commandLineAPI"]; |
| 912 } catch(e) { | 912 } catch(e) { |
| 913 } | 913 } |
| 914 } | 914 } |
| 915 if (injectScopeChain) { | 915 if (injectScopeChain) { |
| 916 try { | 916 try { |
| 917 delete inspectedWindow["__scopeChainForEval"]; | 917 delete inspectedGlobalObject["__scopeChainForEval"]; |
| 918 } catch(e) { | 918 } catch(e) { |
| 919 } | 919 } |
| 920 } | 920 } |
| 921 } | 921 } |
| 922 }, | 922 }, |
| 923 | 923 |
| 924 /** | 924 /** |
| 925 * @param {?Object} callFrame | 925 * @param {?Object} callFrame |
| 926 * @param {number} asyncOrdinal | 926 * @param {number} asyncOrdinal |
| 927 * @return {!Array.<!InjectedScript.CallFrameProxy>|boolean} | 927 * @return {!Array.<!InjectedScript.CallFrameProxy>|boolean} |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 /** | 1100 /** |
| 1101 * @param {string} name | 1101 * @param {string} name |
| 1102 * @param {string} source | 1102 * @param {string} source |
| 1103 * @return {?Object} | 1103 * @return {?Object} |
| 1104 */ | 1104 */ |
| 1105 injectModule: function(name, source) | 1105 injectModule: function(name, source) |
| 1106 { | 1106 { |
| 1107 delete this._modules[name]; | 1107 delete this._modules[name]; |
| 1108 var moduleFunction = InjectedScriptHost.eval("(" + source + ")"); | 1108 var moduleFunction = InjectedScriptHost.eval("(" + source + ")"); |
| 1109 if (typeof moduleFunction !== "function") { | 1109 if (typeof moduleFunction !== "function") { |
| 1110 inspectedWindow.console.error("Web Inspector error: A function was e
xpected for module %s evaluation", name); | 1110 inspectedGlobalObject.console.error("Web Inspector error: A function
was expected for module %s evaluation", name); |
| 1111 return null; | 1111 return null; |
| 1112 } | 1112 } |
| 1113 var module = /** @type {!Object} */ (InjectedScriptHost.callFunction(mod
uleFunction, inspectedWindow, [InjectedScriptHost, inspectedWindow, injectedScri
ptId, this])); | 1113 var module = /** @type {!Object} */ (InjectedScriptHost.callFunction(mod
uleFunction, inspectedGlobalObject, [InjectedScriptHost, inspectedGlobalObject,
injectedScriptId, this])); |
| 1114 this._modules[name] = module; | 1114 this._modules[name] = module; |
| 1115 return module; | 1115 return module; |
| 1116 }, | 1116 }, |
| 1117 | 1117 |
| 1118 /** | 1118 /** |
| 1119 * @param {*} object | 1119 * @param {*} object |
| 1120 * @return {boolean} | 1120 * @return {boolean} |
| 1121 */ | 1121 */ |
| 1122 _isDefined: function(object) | 1122 _isDefined: function(object) |
| 1123 { | 1123 { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1314 * @param {*=} customObjectConfig | 1314 * @param {*=} customObjectConfig |
| 1315 * @return {?RuntimeAgent.CustomPreview} | 1315 * @return {?RuntimeAgent.CustomPreview} |
| 1316 */ | 1316 */ |
| 1317 _customPreview: function(object, objectGroupName, customObjectConfig) | 1317 _customPreview: function(object, objectGroupName, customObjectConfig) |
| 1318 { | 1318 { |
| 1319 /** | 1319 /** |
| 1320 * @param {!Error} error | 1320 * @param {!Error} error |
| 1321 */ | 1321 */ |
| 1322 function logError(error) | 1322 function logError(error) |
| 1323 { | 1323 { |
| 1324 Promise.resolve().then(inspectedWindow.console.error.bind(inspectedW
indow.console, "Custom Formatter Failed: " + error.message)); | 1324 Promise.resolve().then(inspectedGlobalObject.console.error.bind(insp
ectedGlobalObject.console, "Custom Formatter Failed: " + error.message)); |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 try { | 1327 try { |
| 1328 var formatters = inspectedWindow["devtoolsFormatters"]; | 1328 var formatters = inspectedGlobalObject["devtoolsFormatters"]; |
| 1329 if (!formatters || !isArrayLike(formatters)) | 1329 if (!formatters || !isArrayLike(formatters)) |
| 1330 return null; | 1330 return null; |
| 1331 | 1331 |
| 1332 for (var i = 0; i < formatters.length; ++i) { | 1332 for (var i = 0; i < formatters.length; ++i) { |
| 1333 try { | 1333 try { |
| 1334 var formatted = formatters[i].header(object, customObjectCon
fig); | 1334 var formatted = formatters[i].header(object, customObjectCon
fig); |
| 1335 if (!formatted) | 1335 if (!formatted) |
| 1336 continue; | 1336 continue; |
| 1337 | 1337 |
| 1338 var hasBody = formatters[i].hasBody(object, customObjectConf
ig); | 1338 var hasBody = formatters[i].hasBody(object, customObjectConf
ig); |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1682 */ | 1682 */ |
| 1683 function CommandLineAPI(commandLineAPIImpl, callFrame) | 1683 function CommandLineAPI(commandLineAPIImpl, callFrame) |
| 1684 { | 1684 { |
| 1685 /** | 1685 /** |
| 1686 * @param {string} member | 1686 * @param {string} member |
| 1687 * @return {boolean} | 1687 * @return {boolean} |
| 1688 */ | 1688 */ |
| 1689 function inScopeVariables(member) | 1689 function inScopeVariables(member) |
| 1690 { | 1690 { |
| 1691 if (!callFrame) | 1691 if (!callFrame) |
| 1692 return (member in inspectedWindow); | 1692 return (member in inspectedGlobalObject); |
| 1693 | 1693 |
| 1694 var scopeChain = callFrame.scopeChain; | 1694 var scopeChain = callFrame.scopeChain; |
| 1695 for (var i = 0; i < scopeChain.length; ++i) { | 1695 for (var i = 0; i < scopeChain.length; ++i) { |
| 1696 if (member in scopeChain[i]) | 1696 if (member in scopeChain[i]) |
| 1697 return true; | 1697 return true; |
| 1698 } | 1698 } |
| 1699 return false; | 1699 return false; |
| 1700 } | 1700 } |
| 1701 | 1701 |
| 1702 /** | 1702 /** |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1766 /** | 1766 /** |
| 1767 * @param {string} selector | 1767 * @param {string} selector |
| 1768 * @param {!Node=} opt_startNode | 1768 * @param {!Node=} opt_startNode |
| 1769 * @return {*} | 1769 * @return {*} |
| 1770 */ | 1770 */ |
| 1771 $: function (selector, opt_startNode) | 1771 $: function (selector, opt_startNode) |
| 1772 { | 1772 { |
| 1773 if (this._canQuerySelectorOnNode(opt_startNode)) | 1773 if (this._canQuerySelectorOnNode(opt_startNode)) |
| 1774 return opt_startNode.querySelector(selector); | 1774 return opt_startNode.querySelector(selector); |
| 1775 | 1775 |
| 1776 return inspectedWindow.document.querySelector(selector); | 1776 return inspectedGlobalObject.document.querySelector(selector); |
| 1777 }, | 1777 }, |
| 1778 | 1778 |
| 1779 /** | 1779 /** |
| 1780 * @param {string} selector | 1780 * @param {string} selector |
| 1781 * @param {!Node=} opt_startNode | 1781 * @param {!Node=} opt_startNode |
| 1782 * @return {*} | 1782 * @return {*} |
| 1783 */ | 1783 */ |
| 1784 $$: function (selector, opt_startNode) | 1784 $$: function (selector, opt_startNode) |
| 1785 { | 1785 { |
| 1786 if (this._canQuerySelectorOnNode(opt_startNode)) | 1786 if (this._canQuerySelectorOnNode(opt_startNode)) |
| 1787 return opt_startNode.querySelectorAll(selector); | 1787 return opt_startNode.querySelectorAll(selector); |
| 1788 return inspectedWindow.document.querySelectorAll(selector); | 1788 return inspectedGlobalObject.document.querySelectorAll(selector); |
| 1789 }, | 1789 }, |
| 1790 | 1790 |
| 1791 /** | 1791 /** |
| 1792 * @param {!Node=} node | 1792 * @param {!Node=} node |
| 1793 * @return {boolean} | 1793 * @return {boolean} |
| 1794 */ | 1794 */ |
| 1795 _canQuerySelectorOnNode: function(node) | 1795 _canQuerySelectorOnNode: function(node) |
| 1796 { | 1796 { |
| 1797 return !!node && InjectedScriptHost.subtype(node) === "node" && (node.no
deType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nod
eType === Node.DOCUMENT_FRAGMENT_NODE); | 1797 return !!node && InjectedScriptHost.subtype(node) === "node" && (node.no
deType === Node.ELEMENT_NODE || node.nodeType === Node.DOCUMENT_NODE || node.nod
eType === Node.DOCUMENT_FRAGMENT_NODE); |
| 1798 }, | 1798 }, |
| 1799 | 1799 |
| 1800 /** | 1800 /** |
| 1801 * @param {string} xpath | 1801 * @param {string} xpath |
| 1802 * @param {!Node=} opt_startNode | 1802 * @param {!Node=} opt_startNode |
| 1803 * @return {*} | 1803 * @return {*} |
| 1804 */ | 1804 */ |
| 1805 $x: function(xpath, opt_startNode) | 1805 $x: function(xpath, opt_startNode) |
| 1806 { | 1806 { |
| 1807 var doc = (opt_startNode && opt_startNode.ownerDocument) || inspectedWin
dow.document; | 1807 var doc = (opt_startNode && opt_startNode.ownerDocument) || inspectedGlo
balObject.document; |
| 1808 var result = doc.evaluate(xpath, opt_startNode || doc, null, XPathResult
.ANY_TYPE, null); | 1808 var result = doc.evaluate(xpath, opt_startNode || doc, null, XPathResult
.ANY_TYPE, null); |
| 1809 switch (result.resultType) { | 1809 switch (result.resultType) { |
| 1810 case XPathResult.NUMBER_TYPE: | 1810 case XPathResult.NUMBER_TYPE: |
| 1811 return result.numberValue; | 1811 return result.numberValue; |
| 1812 case XPathResult.STRING_TYPE: | 1812 case XPathResult.STRING_TYPE: |
| 1813 return result.stringValue; | 1813 return result.stringValue; |
| 1814 case XPathResult.BOOLEAN_TYPE: | 1814 case XPathResult.BOOLEAN_TYPE: |
| 1815 return result.booleanValue; | 1815 return result.booleanValue; |
| 1816 default: | 1816 default: |
| 1817 var nodes = []; | 1817 var nodes = []; |
| 1818 var node; | 1818 var node; |
| 1819 while (node = result.iterateNext()) | 1819 while (node = result.iterateNext()) |
| 1820 push(nodes, node); | 1820 push(nodes, node); |
| 1821 return nodes; | 1821 return nodes; |
| 1822 } | 1822 } |
| 1823 }, | 1823 }, |
| 1824 | 1824 |
| 1825 /** | 1825 /** |
| 1826 * @return {*} | 1826 * @return {*} |
| 1827 */ | 1827 */ |
| 1828 dir: function(var_args) | 1828 dir: function(var_args) |
| 1829 { | 1829 { |
| 1830 return InjectedScriptHost.callFunction(inspectedWindow.console.dir, insp
ectedWindow.console, slice(arguments)); | 1830 return InjectedScriptHost.callFunction(inspectedGlobalObject.console.dir
, inspectedGlobalObject.console, slice(arguments)); |
| 1831 }, | 1831 }, |
| 1832 | 1832 |
| 1833 /** | 1833 /** |
| 1834 * @return {*} | 1834 * @return {*} |
| 1835 */ | 1835 */ |
| 1836 dirxml: function(var_args) | 1836 dirxml: function(var_args) |
| 1837 { | 1837 { |
| 1838 return InjectedScriptHost.callFunction(inspectedWindow.console.dirxml, i
nspectedWindow.console, slice(arguments)); | 1838 return InjectedScriptHost.callFunction(inspectedGlobalObject.console.dir
xml, inspectedGlobalObject.console, slice(arguments)); |
| 1839 }, | 1839 }, |
| 1840 | 1840 |
| 1841 /** | 1841 /** |
| 1842 * @return {!Array.<string>} | 1842 * @return {!Array.<string>} |
| 1843 */ | 1843 */ |
| 1844 keys: function(object) | 1844 keys: function(object) |
| 1845 { | 1845 { |
| 1846 return Object.keys(object); | 1846 return Object.keys(object); |
| 1847 }, | 1847 }, |
| 1848 | 1848 |
| 1849 /** | 1849 /** |
| 1850 * @return {!Array.<*>} | 1850 * @return {!Array.<*>} |
| 1851 */ | 1851 */ |
| 1852 values: function(object) | 1852 values: function(object) |
| 1853 { | 1853 { |
| 1854 var result = []; | 1854 var result = []; |
| 1855 for (var key in object) | 1855 for (var key in object) |
| 1856 push(result, object[key]); | 1856 push(result, object[key]); |
| 1857 return result; | 1857 return result; |
| 1858 }, | 1858 }, |
| 1859 | 1859 |
| 1860 /** | 1860 /** |
| 1861 * @return {*} | 1861 * @return {*} |
| 1862 */ | 1862 */ |
| 1863 profile: function(opt_title) | 1863 profile: function(opt_title) |
| 1864 { | 1864 { |
| 1865 return InjectedScriptHost.callFunction(inspectedWindow.console.profile,
inspectedWindow.console, slice(arguments)); | 1865 return InjectedScriptHost.callFunction(inspectedGlobalObject.console.pro
file, inspectedGlobalObject.console, slice(arguments)); |
| 1866 }, | 1866 }, |
| 1867 | 1867 |
| 1868 /** | 1868 /** |
| 1869 * @return {*} | 1869 * @return {*} |
| 1870 */ | 1870 */ |
| 1871 profileEnd: function(opt_title) | 1871 profileEnd: function(opt_title) |
| 1872 { | 1872 { |
| 1873 return InjectedScriptHost.callFunction(inspectedWindow.console.profileEn
d, inspectedWindow.console, slice(arguments)); | 1873 return InjectedScriptHost.callFunction(inspectedGlobalObject.console.pro
fileEnd, inspectedGlobalObject.console, slice(arguments)); |
| 1874 }, | 1874 }, |
| 1875 | 1875 |
| 1876 /** | 1876 /** |
| 1877 * @param {!Object} object | 1877 * @param {!Object} object |
| 1878 * @param {!Array.<string>|string=} opt_types | 1878 * @param {!Array.<string>|string=} opt_types |
| 1879 */ | 1879 */ |
| 1880 monitorEvents: function(object, opt_types) | 1880 monitorEvents: function(object, opt_types) |
| 1881 { | 1881 { |
| 1882 if (!object || !object.addEventListener || !object.removeEventListener) | 1882 if (!object || !object.addEventListener || !object.removeEventListener) |
| 1883 return; | 1883 return; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1974 InjectedScriptHost.monitorFunction(fn); | 1974 InjectedScriptHost.monitorFunction(fn); |
| 1975 }, | 1975 }, |
| 1976 | 1976 |
| 1977 unmonitor: function(fn) | 1977 unmonitor: function(fn) |
| 1978 { | 1978 { |
| 1979 InjectedScriptHost.unmonitorFunction(fn); | 1979 InjectedScriptHost.unmonitorFunction(fn); |
| 1980 }, | 1980 }, |
| 1981 | 1981 |
| 1982 table: function(data, opt_columns) | 1982 table: function(data, opt_columns) |
| 1983 { | 1983 { |
| 1984 InjectedScriptHost.callFunction(inspectedWindow.console.table, inspected
Window.console, slice(arguments)); | 1984 InjectedScriptHost.callFunction(inspectedGlobalObject.console.table, ins
pectedGlobalObject.console, slice(arguments)); |
| 1985 }, | 1985 }, |
| 1986 | 1986 |
| 1987 /** | 1987 /** |
| 1988 * @param {number} num | 1988 * @param {number} num |
| 1989 */ | 1989 */ |
| 1990 _inspectedObject: function(num) | 1990 _inspectedObject: function(num) |
| 1991 { | 1991 { |
| 1992 return InjectedScriptHost.inspectedObject(num); | 1992 return InjectedScriptHost.inspectedObject(num); |
| 1993 }, | 1993 }, |
| 1994 | 1994 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2017 push(result, types[i]); | 2017 push(result, types[i]); |
| 2018 } | 2018 } |
| 2019 return result; | 2019 return result; |
| 2020 }, | 2020 }, |
| 2021 | 2021 |
| 2022 /** | 2022 /** |
| 2023 * @param {!Event} event | 2023 * @param {!Event} event |
| 2024 */ | 2024 */ |
| 2025 _logEvent: function(event) | 2025 _logEvent: function(event) |
| 2026 { | 2026 { |
| 2027 inspectedWindow.console.log(event.type, event); | 2027 inspectedGlobalObject.console.log(event.type, event); |
| 2028 } | 2028 } |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 2031 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 2032 return injectedScript; | 2032 return injectedScript; |
| 2033 }) | 2033 }) |
| OLD | NEW |