Changeset 225244 in webkit


Ignore:
Timestamp:
Nov 28, 2017, 3:45:01 PM (7 years ago)
Author:
Joseph Pecoraro
Message:

ServiceWorker Inspector: Frontend changes to support Network tab and sub resources
https://bugs.webkit.org/show_bug.cgi?id=179642
<rdar://problem/35517704>

Reviewed by Brian Burg.

Source/WebInspectorUI:

This patch makes use of the NetworkAgent and ServiceWorker agents in the frontend
for a ServiceWorker inspection target. It also makes changes to ensure that the
subresources requested by a ServiceWorker appear as expected in both the Resources
and Network Tabs.

The backends of ServiceWorkers and DedicatedWorkers for network requests are
different, but we want the presentation to be very similiar. Ultimately we'd like
to move to more similiar backends if possible.

The first (after Inspector.enable) message a ServiceWorker inspector sends to the
backend is ServiceWorker.getInitializationInfo. This parallels a Page inspector
sending Page.getResourceTree. From the response we get enough information to
setup the MainTarget with enough information (targetId, URL) to know what its main
resource URL will be. Like DedicatedWorkers, the target's main resource will be
filled in with the first WI.Script matching the URL. With this initialization
message alone the ServiceWorker Target behaves almost identically to a Worker
target and Network loads associated with the target (by targetId) are added as
sub-resources as expected.

The biggest tension in this patch is within FrameResourceManager. The class, as
its name indicates, assumes page resources with Frames, navigation, and loader
semantics. It takes a few modifications to make it better handle resources not
associated with a Page. A follow-up will rename this to just ResourceManager as
the class' main task is now to associate Resources with Targets.

  • UserInterface/Base/Main.js:

(WI.loaded):
There are assumptions in a few places that the main target is a Page. Those
places can now be reached when the main target is a ServiceWorker. Add a
convenience WI.pageTarget that can be used in these places.

  • UserInterface/Test/Test.js:

(WI.loaded):
Add pageTarget.

  • UserInterface/Controllers/DebuggerManager.js:

(WI.DebuggerManager.prototype.scriptDidParse):
Generalize the condition so the main target can have its main resource populated.
This will be the case when a ServiceWorker is the main target and its main resource
needs to be populated from a Script.

  • UserInterface/Controllers/FrameResourceManager.js:

(WI.FrameResourceManager):
(WI.FrameResourceManager.prototype._processServiceWorkerInitializationInfo):
Handle ServiceWorker Resource initialization which is different from Page initialization.

(WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget):
(WI.FrameResourceManager.prototype._addResourceToTarget):
(WI.FrameResourceManager.prototype._addFrameTreeFromFrameResourceTreePayload):
Eliminate PageAgent, which might not be available in some targets.
Use pageTarget instead of mainTarget where appropriate.

  • UserInterface/Controllers/TargetManager.js:

(WI.TargetManager.prototype.targetForIdentifier):
A ServiceWorker is the first time that the main target has an identifier,
so let TargetManager find it by target id.

  • UserInterface/Models/Resource.js:

(WI.Resource):
(WI.Resource.resolvedType):
(WI.Resource.prototype.updateForResponse):
For Resource.Type.Other resources include a better type inferred from the MIME type.
ServiceWorker loads currently don't have type information and this provides a great
type for such loads. This should also provide nice types for CacheStorage.add*
populated resources which are otherwise type-less fetches.

  • UserInterface/Protocol/Connection.js:

Rename the class since this may no longer be a "Page".

  • UserInterface/Protocol/MainTarget.js:

(WI.MainTarget):
(WI.MainTarget.mainConnectionInfo):
(WI.MainTarget.prototype.get mainResource):
(WI.MainTarget.prototype.set mainResource):
(WI.MainTarget.prototype.get displayName): Deleted.

  • UserInterface/Protocol/Target.js:

(WI.Target.prototype.set identifier):
(WI.Target.prototype.set name):
(WI.Target.prototype.get mainResource):
(WI.Target.prototype.set mainResource):
(WI.Target.prototype.get displayName):
Give richer types for the main target. And allow a few things to be initialized
lazily, which will be necessary from an initialization message.

  • UserInterface/Views/NetworkTabContentView.js:

(WI.NetworkTabContentView.isTabAllowed):
Remove a PageAgent requirement for the Network tab. A ServiceWorker will not
have a PageAgent, but it will have a NetworkAgent, which should be good enough.

  • UserInterface/Views/NetworkTableContentView.js:

(WI.NetworkTableContentView.prototype._populateWithInitialResourcesIfNeeded):
Initial populate should populate all subresources of all targets.

  • UserInterface/Views/ResourceContentView.js:

(WI.ResourceContentView.prototype.contentAvailable):
This was getting used by ResourceType.Other without warning. Make it warn.

  • UserInterface/Views/ResourceSidebarPanel.js:

(WI.ResourceSidebarPanel.prototype._addScript):
(WI.ResourceSidebarPanel.prototype._addTargetWithMainResource):

  • UserInterface/Views/ScriptTreeElement.js:

(WI.ScriptTreeElement):
Allow WorkerTreeElements for ServiceWorker targets which may also be the main target.
Also when adding such a tree element, promote the resource sidebar to a full tree
outline, and stop hiding disclosure buttons.

Source/WebInspectorUI/../../LayoutTests:

  • inspector/unit-tests/target-manager-expected.txt:
  • inspector/unit-tests/target-manager.html:

Generalize.

Source/WebInspectorUI/../JavaScriptCore:

  • inspector/protocol/Network.json:

Expose the NetworkAgent for a Service Worker inspector.

Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r225242 r225244  
     12017-11-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ServiceWorker Inspector: Frontend changes to support Network tab and sub resources
     4        https://bugs.webkit.org/show_bug.cgi?id=179642
     5        <rdar://problem/35517704>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/unit-tests/target-manager-expected.txt:
     10        * inspector/unit-tests/target-manager.html:
     11        Generalize.
     12
    1132017-11-28  Ryan Haddad  <ryanhaddad@apple.com>
    214
  • trunk/LayoutTests/inspector/unit-tests/target-manager-expected.txt

    r220119 r225244  
    88PASS: Main target should have an ExecutionContext.
    99PASS: Main target should have the global RuntimeAgent.
    10 Target - Main - Page
     10Target - Symbol(page) - Page
    1111
    1212-- Running test case: TargetManager.WorkerTarget.Create
     
    1515PASS: Added Target should have a RuntimeAgent.
    1616PASS: Added Target RuntimeAgent should not be the global RuntimeAgent.
    17 Target - Main - Page
    18 Target - Worker - worker-1.js
     17Target - Symbol(page) - Page
     18Target - Symbol(worker) - worker-1.js
    1919
    2020-- Running test case: TargetManager.WorkerTarget.Remove
    2121PASS: Removed Target should have Worker type.
    22 Target - Main - Page
     22Target - Symbol(page) - Page
    2323
  • trunk/LayoutTests/inspector/unit-tests/target-manager.html

    r223809 r225244  
    1616function test()
    1717{
    18     function typeString(type) {
    19         switch (type) {
    20         case WI.Target.Type.Main:
    21             return "Main";
    22         case WI.Target.Type.Worker:
    23             return "Worker";
    24         default:
    25             return "Unknown";
    26         }
    27     }
    28 
    2918    function dumpTargets() {
    3019        for (let target of WI.targets)
    31             InspectorTest.log(`Target - ${typeString(target.type)} - ${target.displayName}`);
     20            InspectorTest.log(`Target - ${String(target.type)} - ${target.displayName}`);
    3221    }
    33 
    3422
    3523    let suite = InspectorTest.createAsyncSuite("TargetManager");
  • trunk/Source/JavaScriptCore/ChangeLog

    r225243 r225244  
     12017-11-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ServiceWorker Inspector: Frontend changes to support Network tab and sub resources
     4        https://bugs.webkit.org/show_bug.cgi?id=179642
     5        <rdar://problem/35517704>
     6
     7        Reviewed by Brian Burg.
     8
     9        * inspector/protocol/Network.json:
     10        Expose the NetworkAgent for a Service Worker inspector.
     11
    112 2017-11-28  Brian Burg  <bburg@apple.com>
    213
  • trunk/Source/JavaScriptCore/inspector/protocol/Network.json

    r224704 r225244  
    22    "domain": "Network",
    33    "description": "Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.",
    4     "availability": ["web"],
     4    "availability": ["web", "service-worker"],
    55    "types": [
    66        {
  • trunk/Source/WebInspectorUI/ChangeLog

    r225165 r225244  
     12017-11-28  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        ServiceWorker Inspector: Frontend changes to support Network tab and sub resources
     4        https://bugs.webkit.org/show_bug.cgi?id=179642
     5        <rdar://problem/35517704>
     6
     7        Reviewed by Brian Burg.
     8
     9        This patch makes use of the NetworkAgent and ServiceWorker agents in the frontend
     10        for a ServiceWorker inspection target. It also makes changes to ensure that the
     11        subresources requested by a ServiceWorker appear as expected in both the Resources
     12        and Network Tabs.
     13
     14        The backends of ServiceWorkers and DedicatedWorkers for network requests are
     15        different, but we want the presentation to be very similiar. Ultimately we'd like
     16        to move to more similiar backends if possible.
     17
     18        The first (after Inspector.enable) message a ServiceWorker inspector sends to the
     19        backend is ServiceWorker.getInitializationInfo. This parallels a Page inspector
     20        sending Page.getResourceTree. From the response we get enough information to
     21        setup the MainTarget with enough information (targetId, URL) to know what its main
     22        resource URL will be. Like DedicatedWorkers, the target's main resource will be
     23        filled in with the first WI.Script matching the URL. With this initialization
     24        message alone the ServiceWorker Target behaves almost identically to a Worker
     25        target and Network loads associated with the target (by targetId) are added as
     26        sub-resources as expected.
     27
     28        The biggest tension in this patch is within FrameResourceManager. The class, as
     29        its name indicates, assumes page resources with Frames, navigation, and loader
     30        semantics. It takes a few modifications to make it better handle resources not
     31        associated with a Page. A follow-up will rename this to just ResourceManager as
     32        the class' main task is now to associate Resources with Targets.
     33
     34        * UserInterface/Base/Main.js:
     35        (WI.loaded):
     36        There are assumptions in a few places that the main target is a Page. Those
     37        places can now be reached when the main target is a ServiceWorker. Add a
     38        convenience WI.pageTarget that can be used in these places.
     39
     40        * UserInterface/Test/Test.js:
     41        (WI.loaded):
     42        Add pageTarget.
     43
     44        * UserInterface/Controllers/DebuggerManager.js:
     45        (WI.DebuggerManager.prototype.scriptDidParse):
     46        Generalize the condition so the main target can have its main resource populated.
     47        This will be the case when a ServiceWorker is the main target and its main resource
     48        needs to be populated from a Script.
     49
     50        * UserInterface/Controllers/FrameResourceManager.js:
     51        (WI.FrameResourceManager):
     52        (WI.FrameResourceManager.prototype._processServiceWorkerInitializationInfo):
     53        Handle ServiceWorker Resource initialization which is different from Page initialization.
     54
     55        (WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget):
     56        (WI.FrameResourceManager.prototype._addResourceToTarget):
     57        (WI.FrameResourceManager.prototype._addFrameTreeFromFrameResourceTreePayload):
     58        Eliminate PageAgent, which might not be available in some targets.
     59        Use pageTarget instead of mainTarget where appropriate.
     60
     61        * UserInterface/Controllers/TargetManager.js:
     62        (WI.TargetManager.prototype.targetForIdentifier):
     63        A ServiceWorker is the first time that the main target has an identifier,
     64        so let TargetManager find it by target id.
     65
     66        * UserInterface/Models/Resource.js:
     67        (WI.Resource):
     68        (WI.Resource.resolvedType):
     69        (WI.Resource.prototype.updateForResponse):
     70        For Resource.Type.Other resources include a better type inferred from the MIME type.
     71        ServiceWorker loads currently don't have type information and this provides a great
     72        type for such loads. This should also provide nice types for CacheStorage.add*
     73        populated resources which are otherwise type-less fetches.
     74
     75        * UserInterface/Protocol/Connection.js:
     76        Rename the class since this may no longer be a "Page".
     77
     78        * UserInterface/Protocol/MainTarget.js:
     79        (WI.MainTarget):
     80        (WI.MainTarget.mainConnectionInfo):
     81        (WI.MainTarget.prototype.get mainResource):
     82        (WI.MainTarget.prototype.set mainResource):
     83        (WI.MainTarget.prototype.get displayName): Deleted.
     84        * UserInterface/Protocol/Target.js:
     85        (WI.Target.prototype.set identifier):
     86        (WI.Target.prototype.set name):
     87        (WI.Target.prototype.get mainResource):
     88        (WI.Target.prototype.set mainResource):
     89        (WI.Target.prototype.get displayName):
     90        Give richer types for the main target. And allow a few things to be initialized
     91        lazily, which will be necessary from an initialization message.
     92
     93        * UserInterface/Views/NetworkTabContentView.js:
     94        (WI.NetworkTabContentView.isTabAllowed):
     95        Remove a PageAgent requirement for the Network tab. A ServiceWorker will not
     96        have a PageAgent, but it will have a NetworkAgent, which should be good enough.
     97
     98        * UserInterface/Views/NetworkTableContentView.js:
     99        (WI.NetworkTableContentView.prototype._populateWithInitialResourcesIfNeeded):
     100        Initial populate should populate all subresources of all targets.
     101
     102        * UserInterface/Views/ResourceContentView.js:
     103        (WI.ResourceContentView.prototype.contentAvailable):
     104        This was getting used by ResourceType.Other without warning. Make it warn.
     105
     106        * UserInterface/Views/ResourceSidebarPanel.js:
     107        (WI.ResourceSidebarPanel.prototype._addScript):
     108        (WI.ResourceSidebarPanel.prototype._addTargetWithMainResource):
     109        * UserInterface/Views/ScriptTreeElement.js:
     110        (WI.ScriptTreeElement):
     111        Allow WorkerTreeElements for ServiceWorker targets which may also be the main target.
     112        Also when adding such a tree element, promote the resource sidebar to a full tree
     113        outline, and stop hiding disclosure buttons.
     114
    11152017-11-27  Nikita Vasilyev  <nvasilyev@apple.com>
    2116
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r224994 r225244  
    572572localizedStrings["MIME Type:"] = "MIME Type:";
    573573localizedStrings["Main"] = "Main";
    574 localizedStrings["Main Frame"] = "Main Frame";
    575574localizedStrings["Manifest URL"] = "Manifest URL";
    576575localizedStrings["Margin"] = "Margin";
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r224994 r225244  
    9191    // Main backend target.
    9292    WI.mainTarget = new WI.MainTarget;
     93    WI.pageTarget = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.mainTarget : null;
    9394
    9495    // Enable agents.
    95     InspectorAgent.enable();
     96    if (window.InspectorAgent)
     97        InspectorAgent.enable();
    9698
    9799    // Perform one-time tasks.
     
    136138    setTimeout(function() {
    137139        // COMPATIBILITY (iOS 8): Inspector.initialized did not exist yet.
    138         if (InspectorAgent.initialized)
     140        if (window.InspectorAgent && InspectorAgent.initialized)
    139141            InspectorAgent.initialized();
    140142    }, 0);
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js

    r224368 r225244  
    711711        targetData.addScript(script);
    712712
    713         if (target !== WI.mainTarget && !target.mainResource) {
     713        if (!target.mainResource && (target !== WI.mainResource || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker)) {
    714714            // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script
    715715            // We make the main resource of a WorkerTarget the Script instead of the Resource
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js

    r223856 r225244  
    4343        }
    4444
     45        if (window.ServiceWorkerAgent)
     46            ServiceWorkerAgent.getInitializationInfo(this._processServiceWorkerInitializationInfo.bind(this));
     47
    4548        if (window.NetworkAgent)
    4649            NetworkAgent.enable();
     
    505508        let resource = null;
    506509
     510        if (!frameIdentifier && targetId) {
     511            // This is a new resource for a ServiceWorker target.
     512            console.assert(WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker);
     513            console.assert(targetId === WI.mainTarget.identifier);
     514            resource = new WI.Resource(url, null, type, loaderIdentifier, targetId, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, walltime, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp);
     515            resource.target.addResource(resource);
     516            return resource;
     517        }
     518
    507519        let frame = this.frameForIdentifier(frameIdentifier);
    508520        if (frame) {
    509521            // This is a new request for an existing frame, which might be the main resource or a new resource.
    510             if (type === PageAgent.ResourceType.Document && frame.mainResource.url === url && frame.loaderIdentifier === loaderIdentifier)
     522            if (type === "Document" && frame.mainResource.url === url && frame.loaderIdentifier === loaderIdentifier)
    511523                resource = frame.mainResource;
    512             else if (type === PageAgent.ResourceType.Document && frame.provisionalMainResource && frame.provisionalMainResource.url === url && frame.provisionalLoaderIdentifier === loaderIdentifier)
     524            else if (type === "Document" && frame.provisionalMainResource && frame.provisionalMainResource.url === url && frame.provisionalLoaderIdentifier === loaderIdentifier)
    513525                resource = frame.provisionalMainResource;
    514526            else {
    515527                resource = new WI.Resource(url, null, type, loaderIdentifier, targetId, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, walltime, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp);
    516                 if (resource.target === WI.mainTarget)
     528                if (resource.target === WI.pageTarget)
    517529                    this._addResourceToFrame(frame, resource);
    518530                else if (resource.target)
     
    566578    _addResourceToTarget(target, resource)
    567579    {
    568         console.assert(target !== WI.mainTarget);
     580        console.assert(target !== WI.pageTarget);
    569581        console.assert(resource);
    570582
     
    617629    }
    618630
     631    _processServiceWorkerInitializationInfo(error, initializationPayload)
     632    {
     633        console.assert(this._waitingForMainFrameResourceTreePayload);
     634        this._waitingForMainFrameResourceTreePayload = false;
     635
     636        if (error) {
     637            console.error(JSON.stringify(error));
     638            return;
     639        }
     640
     641        console.assert(initializationPayload.targetId.startsWith("serviceworker:"));
     642
     643        WI.mainTarget.identifier = initializationPayload.targetId;
     644        WI.mainTarget.name = initializationPayload.url;
     645    }
     646
    619647    _processMainFrameResourceTreePayload(error, mainFramePayload)
    620648    {
    621649        console.assert(this._waitingForMainFrameResourceTreePayload);
    622         delete this._waitingForMainFrameResourceTreePayload;
     650        this._waitingForMainFrameResourceTreePayload = false;
    623651
    624652        if (error) {
     
    680708            // a main resource when we created the Frame. The resource payload does not include anything
    681709            // didn't already get from the frame payload.
    682             if (resourcePayload.type === PageAgent.ResourceType.Document && resourcePayload.url === payload.frame.url)
     710            if (resourcePayload.type === "Document" && resourcePayload.url === payload.frame.url)
    683711                continue;
    684712
    685713            var resource = this._createResource(resourcePayload, payload);
    686             if (resource.target === WI.mainTarget)
     714            if (resource.target === WI.pageTarget)
    687715                frame.addResource(resource);
    688716            else if (resource.target)
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js

    r220119 r225244  
    4747            return null;
    4848
     49        if (targetId === WI.mainTarget.identifier)
     50            return WI.mainTarget;
     51
    4952        for (let target of this._targets) {
    5053            if (target.identifier === targetId)
  • trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js

    r224357 r225244  
    4040        this._mimeType = mimeType;
    4141        this._mimeTypeComponents = null;
    42         this._type = type || WI.Resource.typeFromMIMEType(mimeType);
     42        this._type = Resource.resolvedType(type, mimeType);
    4343        this._loaderIdentifier = loaderIdentifier || null;
    4444        this._requestIdentifier = requestIdentifier || null;
     
    9595
    9696    // Static
     97
     98    static resolvedType(type, mimeType)
     99    {
     100        if (type && type !== WI.Resource.Type.Other)
     101            return type;
     102
     103        return Resource.typeFromMIMEType(mimeType);
     104    }
    97105
    98106    static typeFromMIMEType(mimeType)
     
    711719
    712720        this._mimeType = mimeType;
    713         this._type = type || WI.Resource.typeFromMIMEType(mimeType);
     721        this._type = Resource.resolvedType(type, mimeType);
    714722        this._statusCode = statusCode;
    715723        this._statusText = statusText;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/Connection.js

    r223308 r225244  
    273273};
    274274
    275 InspectorBackend.MainConnection = class InspectorBackendPageConnection extends InspectorBackend.Connection
     275InspectorBackend.MainConnection = class InspectorBackendMainConnection extends InspectorBackend.Connection
    276276{
    277277    constructor()
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js

    r224368 r225244  
    2828    constructor(connection)
    2929    {
    30         super("main", "", WI.Target.Type.Main, InspectorBackend.mainConnection);
     30        let {type, displayName} = MainTarget.mainConnectionInfo();
    3131
    32         let displayName = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.UIString("Main Frame") : this.displayName;
     32        super("main", displayName, type, InspectorBackend.mainConnection);
     33
    3334        this._executionContext = new WI.ExecutionContext(this, WI.RuntimeManager.TopLevelContextExecutionIdentifier, displayName, true, null);
     35        this._mainResource = null;
     36    }
     37
     38    // Static
     39
     40    static mainConnectionInfo()
     41    {
     42        switch (WI.sharedApp.debuggableType) {
     43        case WI.DebuggableType.JavaScript:
     44            return {
     45                type: WI.Target.Type.JSContext,
     46                displayName: WI.UIString("JavaScript Context"),
     47            };
     48        case WI.DebuggableType.ServiceWorker:
     49            return {
     50                type: WI.Target.Type.ServiceWorker,
     51                displayName: WI.UIString("ServiceWorker"),
     52            };
     53        case WI.DebuggableType.Web:
     54            return {
     55                type: WI.Target.Type.Page,
     56                displayName: WI.UIString("Page"),
     57            };
     58        default:
     59            console.error("Unexpected debuggable type: ", WI.sharedApp.debuggableType);
     60            return {
     61                type: WI.Target.Type.Page,
     62                displayName: WI.UIString("Main"),
     63            };
     64        }
    3465    }
    3566
    3667    // Protected (Target)
    3768
    38     get displayName()
    39     {
    40         switch (WI.sharedApp.debuggableType) {
    41         case WI.DebuggableType.JavaScript:
    42             return WI.UIString("JavaScript Context");
    43         case WI.DebuggableType.ServiceWorker:
    44             return WI.UIString("ServiceWorker");
    45         case WI.DebuggableType.Web:
    46             return WI.UIString("Page");
    47         default:
    48             console.error("Unexpected debuggable type: ", WI.sharedApp.debuggableType);
    49             return WI.UIString("Main");
    50         }
    51     }
    52 
    5369    get mainResource()
    5470    {
     71        if (this._mainResource)
     72            return this._mainResource;
     73
    5574        let mainFrame = WI.frameResourceManager.mainFrame;
    5675        return mainFrame ? mainFrame.mainResource : null;
    5776    }
     77
     78    set mainResource(resource)
     79    {
     80        this._mainResource = resource;
     81    }
    5882};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/Target.js

    r223997 r225244  
    5252
    5353    get identifier() { return this._identifier; }
     54    set identifier(identifier) { this._identifier = identifier; }
     55
    5456    get name() { return this._name; }
     57    set name(name) { this._name = name; }
     58
     59    get mainResource() { return this._mainResource; }
     60    set mainResource(resource) { this._mainResource = resource; }
     61
    5562    get type() { return this._type; }
    5663    get connection() { return this._connection; }
     
    6067    get extraScriptCollection() { return this._extraScriptCollection; }
    6168
    62     get mainResource() { return this._mainResource; }
    63     set mainResource(resource) { this._mainResource = resource; }
     69    get displayName() { return this._name; }
    6470
    6571    addResource(resource)
     
    8692
    8793WI.Target.Type = {
    88     Main: Symbol("main"),
     94    Page: Symbol("page"),
     95    JSContext: Symbol("jscontext"),
     96    ServiceWorker: Symbol("service-worker"),
    8997    Worker: Symbol("worker"),
    9098};
  • trunk/Source/WebInspectorUI/UserInterface/Test/Test.js

    r223428 r225244  
    4646
    4747    WI.mainTarget = new WI.MainTarget;
     48    WI.pageTarget = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.mainTarget : null;
    4849
    4950    // Instantiate controllers used by tests.
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js

    r224508 r225244  
    5959    static isTabAllowed()
    6060    {
    61         return !!window.NetworkAgent && !!window.PageAgent;
     61        return !!window.NetworkAgent;
    6262    }
    6363
  • trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js

    r224994 r225244  
    274274            return;
    275275        }
    276    
     276
    277277        this._table.selectRow(rowIndex);
    278278    }
     
    861861        this._needsInitialPopulate = false;
    862862
    863         console.assert(WI.frameResourceManager.mainFrame);
    864 
    865         let populateFrameResources = (frame) => {
     863        let populateResourcesForFrame = (frame) => {
    866864            if (frame.provisionalMainResource)
    867865                this._pendingInsertions.push(frame.provisionalMainResource);
     
    873871
    874872            for (let childFrame of frame.childFrameCollection.items)
    875                 populateFrameResources(childFrame);
     873                populateResourcesForFrame(childFrame);
    876874        };
    877875
    878         populateFrameResources(WI.frameResourceManager.mainFrame);
     876        let populateResourcesForTarget = (target) => {
     877            if (target.mainResource instanceof WI.Resource)
     878                this._pendingInsertions.push(target.mainResource);
     879            for (let resource of target.resourceCollection.items)
     880                this._pendingInsertions.push(resource);
     881        };
     882
     883        for (let target of WI.targets) {
     884            if (target === WI.pageTarget)
     885                populateResourcesForFrame(WI.frameResourceManager.mainFrame);
     886            else
     887                populateResourcesForTarget(target);
     888        }
    879889
    880890        this.needsLayout();
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js

    r222739 r225244  
    7979    contentAvailable(content, base64Encoded)
    8080    {
    81         // Implemented by subclasses.
     81        throw WI.NotImplementedError.subclassMustOverride();
    8282    }
    8383
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js

    r224905 r225244  
    311311            return;
    312312
    313         // Worker script.
    314         if (script.target !== WI.mainTarget) {
     313        // Target main resource.
     314        if (script.target !== WI.pageTarget) {
    315315            if (script.isMainResource())
    316316                this._addTargetWithMainResource(script.target);
     317            this.contentTreeOutline.disclosureButtons = true;
    317318            return;
    318319        }
     
    432433    _addTargetWithMainResource(target)
    433434    {
    434         console.assert(target.type === WI.Target.Type.Worker);
     435        console.assert(target.type === WI.Target.Type.Worker || target.type === WI.Target.Type.ServiceWorker);
    435436
    436437        let targetTreeElement = new WI.WorkerTreeElement(target);
  • trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTreeElement.js

    r220119 r225244  
    4949
    5050        if (script.isMainResource()) {
    51             console.assert(script.target.type === WI.Target.Type.Worker);
     51            console.assert(script.target.type === WI.Target.Type.Worker || script.target.type === WI.Target.Type.ServiceWorker, script.target.type);
    5252            this.addClassName("worker-icon");
    5353        }
  • trunk/Source/WebInspectorUI/UserInterface/Views/WorkerTreeElement.js

    r220119 r225244  
    3434
    3535        console.assert(target instanceof WI.Target);
    36         console.assert(target.type === WI.Target.Type.Worker);
     36        console.assert(target.type === WI.Target.Type.Worker || target.type === WI.Target.Type.ServiceWorker);
    3737        console.assert(target.mainResource instanceof WI.Script);
    3838
Note: See TracChangeset for help on using the changeset viewer.