| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.TargetAwareObject} |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 35 */ | 35 */ |
| 36 WebInspector.RuntimeModel = function(target) | 36 WebInspector.RuntimeModel = function(target) |
| 37 { | 37 { |
| 38 WebInspector.TargetAwareObject.call(this, target); |
| 39 |
| 38 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameAdded, this._frameAdded, this); | 40 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameAdded, this._frameAdded, this); |
| 39 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameNavigated, this._frameNavigated, this); | 41 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameNavigated, this._frameNavigated, this); |
| 40 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameDetached, this._frameDetached, this); | 42 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.FrameDetached, this._frameDetached, this); |
| 41 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.CachedResourcesLoaded, this._didLoadCachedResources, this); | 43 target.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.Eve
ntTypes.CachedResourcesLoaded, this._didLoadCachedResources, this); |
| 42 this._target = target; | |
| 43 this._debuggerModel = target.debuggerModel; | 44 this._debuggerModel = target.debuggerModel; |
| 44 this._agent = target.runtimeAgent(); | 45 this._agent = target.runtimeAgent(); |
| 45 this._contextListById = {}; | 46 this._contextListById = {}; |
| 46 } | 47 } |
| 47 | 48 |
| 48 WebInspector.RuntimeModel.Events = { | 49 WebInspector.RuntimeModel.Events = { |
| 49 ExecutionContextListAdded: "ExecutionContextListAdded", | 50 ExecutionContextListAdded: "ExecutionContextListAdded", |
| 50 ExecutionContextListRemoved: "ExecutionContextListRemoved", | 51 ExecutionContextListRemoved: "ExecutionContextListRemoved", |
| 51 } | 52 } |
| 52 | 53 |
| 53 WebInspector.RuntimeModel.prototype = { | 54 WebInspector.RuntimeModel.prototype = { |
| 54 | 55 |
| 55 /** | 56 /** |
| 56 * @param {string} url | 57 * @param {string} url |
| 57 */ | 58 */ |
| 58 addWorkerContextList: function(url) | 59 addWorkerContextList: function(url) |
| 59 { | 60 { |
| 60 console.assert(this._target.isWorkerTarget(), "Worker context list was a
dded in a non-worker target"); | 61 console.assert(this.target().isWorkerTarget(), "Worker context list was
added in a non-worker target"); |
| 61 var fakeContextList = new WebInspector.WorkerExecutionContextList("worke
r", url); | 62 var fakeContextList = new WebInspector.WorkerExecutionContextList("worke
r", url); |
| 62 this._addContextList(fakeContextList); | 63 this._addContextList(fakeContextList); |
| 63 var fakeExecutionContext = new WebInspector.ExecutionContext(undefined,
url, true); | 64 var fakeExecutionContext = new WebInspector.ExecutionContext(undefined,
url, true); |
| 64 fakeContextList._addExecutionContext(fakeExecutionContext); | 65 fakeContextList._addExecutionContext(fakeExecutionContext); |
| 65 }, | 66 }, |
| 66 | 67 |
| 67 /** | 68 /** |
| 68 * @param {?WebInspector.ExecutionContext} executionContext | 69 * @param {?WebInspector.ExecutionContext} executionContext |
| 69 */ | 70 */ |
| 70 setCurrentExecutionContext: function(executionContext) | 71 setCurrentExecutionContext: function(executionContext) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 contextListByFrame: function(frame) | 96 contextListByFrame: function(frame) |
| 96 { | 97 { |
| 97 return this._contextListById[frame.id]; | 98 return this._contextListById[frame.id]; |
| 98 }, | 99 }, |
| 99 | 100 |
| 100 /** | 101 /** |
| 101 * @param {!WebInspector.Event} event | 102 * @param {!WebInspector.Event} event |
| 102 */ | 103 */ |
| 103 _frameAdded: function(event) | 104 _frameAdded: function(event) |
| 104 { | 105 { |
| 105 console.assert(!this._target.isWorkerTarget() ,"Frame was added in a wor
ker target.t"); | 106 console.assert(!this.target().isWorkerTarget() ,"Frame was added in a wo
rker target.t"); |
| 106 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 107 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); |
| 107 var contextList = new WebInspector.FrameExecutionContextList(frame); | 108 var contextList = new WebInspector.FrameExecutionContextList(frame); |
| 108 this._addContextList(contextList); | 109 this._addContextList(contextList); |
| 109 }, | 110 }, |
| 110 | 111 |
| 111 _addContextList: function(executionContextList) | 112 _addContextList: function(executionContextList) |
| 112 { | 113 { |
| 113 this._contextListById[executionContextList.id()] = executionContextList; | 114 this._contextListById[executionContextList.id()] = executionContextList; |
| 114 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution
ContextListAdded, executionContextList); | 115 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution
ContextListAdded, executionContextList); |
| 115 }, | 116 }, |
| 116 | 117 |
| 117 /** | 118 /** |
| 118 * @param {!WebInspector.Event} event | 119 * @param {!WebInspector.Event} event |
| 119 */ | 120 */ |
| 120 _frameNavigated: function(event) | 121 _frameNavigated: function(event) |
| 121 { | 122 { |
| 122 console.assert(!this._target.isWorkerTarget() ,"Frame was navigated in w
orker's target"); | 123 console.assert(!this.target().isWorkerTarget() ,"Frame was navigated in
worker's target"); |
| 123 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 124 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); |
| 124 var context = this._contextListById[frame.id]; | 125 var context = this._contextListById[frame.id]; |
| 125 if (context) | 126 if (context) |
| 126 context._frameNavigated(frame); | 127 context._frameNavigated(frame); |
| 127 }, | 128 }, |
| 128 | 129 |
| 129 /** | 130 /** |
| 130 * @param {!WebInspector.Event} event | 131 * @param {!WebInspector.Event} event |
| 131 */ | 132 */ |
| 132 _frameDetached: function(event) | 133 _frameDetached: function(event) |
| 133 { | 134 { |
| 134 console.assert(!this._target.isWorkerTarget() ,"Frame was detached in wo
rker's target"); | 135 console.assert(!this.target().isWorkerTarget() ,"Frame was detached in w
orker's target"); |
| 135 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); | 136 var frame = /** @type {!WebInspector.ResourceTreeFrame} */ (event.data); |
| 136 var context = this._contextListById[frame.id]; | 137 var context = this._contextListById[frame.id]; |
| 137 if (!context) | 138 if (!context) |
| 138 return; | 139 return; |
| 139 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution
ContextListRemoved, context); | 140 this.dispatchEventToListeners(WebInspector.RuntimeModel.Events.Execution
ContextListRemoved, context); |
| 140 delete this._contextListById[frame.id]; | 141 delete this._contextListById[frame.id]; |
| 141 }, | 142 }, |
| 142 | 143 |
| 143 _didLoadCachedResources: function() | 144 _didLoadCachedResources: function() |
| 144 { | 145 { |
| 145 this._target.registerRuntimeDispatcher(new WebInspector.RuntimeDispatche
r(this)); | 146 this.target().registerRuntimeDispatcher(new WebInspector.RuntimeDispatch
er(this)); |
| 146 this._agent.enable(); | 147 this._agent.enable(); |
| 147 }, | 148 }, |
| 148 | 149 |
| 149 _executionContextCreated: function(context) | 150 _executionContextCreated: function(context) |
| 150 { | 151 { |
| 151 var contextList = this._contextListById[context.frameId]; | 152 var contextList = this._contextListById[context.frameId]; |
| 152 console.assert(contextList); | 153 console.assert(contextList); |
| 153 contextList._addExecutionContext(new WebInspector.ExecutionContext(conte
xt.id, context.name, context.isPageContext)); | 154 contextList._addExecutionContext(new WebInspector.ExecutionContext(conte
xt.id, context.name, context.isPageContext)); |
| 154 }, | 155 }, |
| 155 | 156 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 183 function evalCallback(error, result, wasThrown) | 184 function evalCallback(error, result, wasThrown) |
| 184 { | 185 { |
| 185 if (error) { | 186 if (error) { |
| 186 callback(null, false); | 187 callback(null, false); |
| 187 return; | 188 return; |
| 188 } | 189 } |
| 189 | 190 |
| 190 if (returnByValue) | 191 if (returnByValue) |
| 191 callback(null, !!wasThrown, wasThrown ? null : result); | 192 callback(null, !!wasThrown, wasThrown ? null : result); |
| 192 else | 193 else |
| 193 callback(this._target.runtimeModel.createRemoteObject(result), !
!wasThrown); | 194 callback(this.target().runtimeModel.createRemoteObject(result),
!!wasThrown); |
| 194 } | 195 } |
| 195 this._agent.evaluate(expression, objectGroup, includeCommandLineAPI, doN
otPauseOnExceptionsAndMuteConsole, this._currentExecutionContext ? this._current
ExecutionContext.id : undefined, returnByValue, generatePreview, evalCallback.bi
nd(this)); | 196 this._agent.evaluate(expression, objectGroup, includeCommandLineAPI, doN
otPauseOnExceptionsAndMuteConsole, this._currentExecutionContext ? this._current
ExecutionContext.id : undefined, returnByValue, generatePreview, evalCallback.bi
nd(this)); |
| 196 }, | 197 }, |
| 197 | 198 |
| 198 /** | 199 /** |
| 199 * @param {!Element} proxyElement | 200 * @param {!Element} proxyElement |
| 200 * @param {!Range} wordRange | 201 * @param {!Range} wordRange |
| 201 * @param {boolean} force | 202 * @param {boolean} force |
| 202 * @param {function(!Array.<string>, number=)} completionsReadyCallback | 203 * @param {function(!Array.<string>, number=)} completionsReadyCallback |
| 203 */ | 204 */ |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 } | 371 } |
| 371 completionsReadyCallback(results); | 372 completionsReadyCallback(results); |
| 372 }, | 373 }, |
| 373 | 374 |
| 374 /** | 375 /** |
| 375 * @return {!WebInspector.RemoteObject} | 376 * @return {!WebInspector.RemoteObject} |
| 376 */ | 377 */ |
| 377 createRemoteObject: function(payload) | 378 createRemoteObject: function(payload) |
| 378 { | 379 { |
| 379 console.assert(typeof payload === "object", "Remote object payload shoul
d only be an object"); | 380 console.assert(typeof payload === "object", "Remote object payload shoul
d only be an object"); |
| 380 return new WebInspector.RemoteObjectImpl(this._target, payload.objectId,
payload.type, payload.subtype, payload.value, payload.description, payload.prev
iew); | 381 return new WebInspector.RemoteObjectImpl(this.target(), payload.objectId
, payload.type, payload.subtype, payload.value, payload.description, payload.pre
view); |
| 381 }, | 382 }, |
| 382 | 383 |
| 383 /** | 384 /** |
| 384 * @param {number|string|boolean} value | 385 * @param {number|string|boolean} value |
| 385 * @return {!WebInspector.RemoteObject} | 386 * @return {!WebInspector.RemoteObject} |
| 386 */ | 387 */ |
| 387 createRemoteObjectFromPrimitiveValue: function(value) | 388 createRemoteObjectFromPrimitiveValue: function(value) |
| 388 { | 389 { |
| 389 return new WebInspector.RemoteObjectImpl(this._target, undefined, typeof
value, undefined, value); | 390 return new WebInspector.RemoteObjectImpl(this.target(), undefined, typeo
f value, undefined, value); |
| 390 }, | 391 }, |
| 391 | 392 |
| 392 /** | 393 /** |
| 393 * @param {string} name | 394 * @param {string} name |
| 394 * @param {string} value | 395 * @param {string} value |
| 395 * @return {!WebInspector.RemoteObjectProperty} | 396 * @return {!WebInspector.RemoteObjectProperty} |
| 396 */ | 397 */ |
| 397 createRemotePropertyFromPrimitiveValue: function(name, value) | 398 createRemotePropertyFromPrimitiveValue: function(name, value) |
| 398 { | 399 { |
| 399 return new WebInspector.RemoteObjectProperty(name, this.createRemoteObje
ctFromPrimitiveValue(value)); | 400 return new WebInspector.RemoteObjectProperty(name, this.createRemoteObje
ctFromPrimitiveValue(value)); |
| 400 }, | 401 }, |
| 401 | 402 |
| 402 /** | 403 /** |
| 403 * @param {!RuntimeAgent.RemoteObject} payload | 404 * @param {!RuntimeAgent.RemoteObject} payload |
| 404 * @param {!WebInspector.ScopeRef=} scopeRef | 405 * @param {!WebInspector.ScopeRef=} scopeRef |
| 405 * @return {!WebInspector.RemoteObject} | 406 * @return {!WebInspector.RemoteObject} |
| 406 */ | 407 */ |
| 407 createScopedObject: function(payload, scopeRef) | 408 createScopedObject: function(payload, scopeRef) |
| 408 { | 409 { |
| 409 if (scopeRef) | 410 if (scopeRef) |
| 410 return new WebInspector.ScopeRemoteObject(this._target, payload.obje
ctId, scopeRef, payload.type, payload.subtype, payload.value, payload.descriptio
n, payload.preview); | 411 return new WebInspector.ScopeRemoteObject(this.target(), payload.obj
ectId, scopeRef, payload.type, payload.subtype, payload.value, payload.descripti
on, payload.preview); |
| 411 else | 412 else |
| 412 return new WebInspector.RemoteObjectImpl(this._target, payload.objec
tId, payload.type, payload.subtype, payload.value, payload.description, payload.
preview); | 413 return new WebInspector.RemoteObjectImpl(this.target(), payload.obje
ctId, payload.type, payload.subtype, payload.value, payload.description, payload
.preview); |
| 413 }, | 414 }, |
| 414 | 415 |
| 415 __proto__: WebInspector.Object.prototype | 416 __proto__: WebInspector.TargetAwareObject.prototype |
| 416 } | 417 } |
| 417 | 418 |
| 418 /** | 419 /** |
| 419 * @type {!WebInspector.RuntimeModel} | 420 * @type {!WebInspector.RuntimeModel} |
| 420 */ | 421 */ |
| 421 WebInspector.runtimeModel; | 422 WebInspector.runtimeModel; |
| 422 | 423 |
| 423 /** | 424 /** |
| 424 * @constructor | 425 * @constructor |
| 425 * @implements {RuntimeAgent.Dispatcher} | 426 * @implements {RuntimeAgent.Dispatcher} |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 /** | 638 /** |
| 638 * @return {string} | 639 * @return {string} |
| 639 */ | 640 */ |
| 640 displayName: function() | 641 displayName: function() |
| 641 { | 642 { |
| 642 return this._url; | 643 return this._url; |
| 643 }, | 644 }, |
| 644 | 645 |
| 645 __proto__: WebInspector.ExecutionContextList.prototype | 646 __proto__: WebInspector.ExecutionContextList.prototype |
| 646 } | 647 } |
| OLD | NEW |