| Index: third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
|
| index 8f5b5c556d952f8684ed0ecc65228cfba2d22711..3e1faf9e4389d8ca9bba6a33cf6c963ab9b59f7e 100644
|
| --- a/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/ResourceTreeModel.js
|
| @@ -79,6 +79,13 @@ WebInspector.ResourceTreeModel.EventTypes = {
|
| ColorPicked: "ColorPicked"
|
| }
|
|
|
| +/**
|
| + * @param {!WebInspector.Target} target
|
| + * @return {?WebInspector.ResourceTreeModel}
|
| + */
|
| +WebInspector.ResourceTreeModel.fromTarget = function(target) {
|
| + return /** @type {?WebInspector.ResourceTreeModel} */ (target.model(WebInspector.ResourceTreeModel));
|
| +}
|
|
|
| /**
|
| * @return {!Array.<!WebInspector.ResourceTreeFrame>}
|
| @@ -86,8 +93,11 @@ WebInspector.ResourceTreeModel.EventTypes = {
|
| WebInspector.ResourceTreeModel.frames = function()
|
| {
|
| var result = [];
|
| - for (var target of WebInspector.targetManager.targets())
|
| - result = result.concat(Object.values(target.resourceTreeModel._frames));
|
| + for (var target of WebInspector.targetManager.targets()) {
|
| + var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
|
| + if (resourceTreeModel)
|
| + result = result.concat(Object.values(resourceTreeModel._frames));
|
| + }
|
| return result;
|
| }
|
|
|
| @@ -98,7 +108,8 @@ WebInspector.ResourceTreeModel.frames = function()
|
| WebInspector.ResourceTreeModel.resourceForURL = function(url)
|
| {
|
| for (var target of WebInspector.targetManager.targets()) {
|
| - var mainFrame = target.resourceTreeModel.mainFrame;
|
| + var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(target);
|
| + var mainFrame = resourceTreeModel && resourceTreeModel.mainFrame;
|
| var result = mainFrame ? mainFrame.resourceForURL(url) : null;
|
| if (result)
|
| return result;
|
| @@ -526,6 +537,20 @@ WebInspector.ResourceTreeFrame = function(model, parentFrame, frameId, payload)
|
| this._parentFrame._childFrames.push(this);
|
| }
|
|
|
| +
|
| +/**
|
| + * @param {!WebInspector.ExecutionContext|!WebInspector.CSSStyleSheetHeader|!WebInspector.Resource} object
|
| + * @return {?WebInspector.ResourceTreeFrame}
|
| + */
|
| +WebInspector.ResourceTreeFrame._fromObject = function(object)
|
| +{
|
| + var resourceTreeModel = WebInspector.ResourceTreeModel.fromTarget(object.target());
|
| + var frameId = object.frameId;
|
| + if (!resourceTreeModel || !frameId)
|
| + return null;
|
| + return resourceTreeModel.frameForId(frameId);
|
| +}
|
| +
|
| /**
|
| * @param {!WebInspector.Script} script
|
| * @return {?WebInspector.ResourceTreeFrame}
|
| @@ -533,9 +558,9 @@ WebInspector.ResourceTreeFrame = function(model, parentFrame, frameId, payload)
|
| WebInspector.ResourceTreeFrame.fromScript = function(script)
|
| {
|
| var executionContext = script.executionContext();
|
| - if (!executionContext || !executionContext.frameId)
|
| + if (!executionContext)
|
| return null;
|
| - return script.target().resourceTreeModel.frameForId(executionContext.frameId);
|
| + return WebInspector.ResourceTreeFrame._fromObject(executionContext);
|
| }
|
|
|
| /**
|
| @@ -544,7 +569,7 @@ WebInspector.ResourceTreeFrame.fromScript = function(script)
|
| */
|
| WebInspector.ResourceTreeFrame.fromStyleSheet = function(header)
|
| {
|
| - return header.target().resourceTreeModel.frameForId(header.frameId);
|
| + return WebInspector.ResourceTreeFrame._fromObject(header);
|
| }
|
|
|
| /**
|
| @@ -553,7 +578,7 @@ WebInspector.ResourceTreeFrame.fromStyleSheet = function(header)
|
| */
|
| WebInspector.ResourceTreeFrame.fromResource = function(resource)
|
| {
|
| - return resource.target().resourceTreeModel.frameForId(resource.frameId);
|
| + return WebInspector.ResourceTreeFrame._fromObject(resource);
|
| }
|
|
|
| WebInspector.ResourceTreeFrame.prototype = {
|
|
|