Changeset 225244 in webkit
- Timestamp:
- Nov 28, 2017, 3:45:01 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r225242 r225244 1 2017-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 1 13 2017-11-28 Ryan Haddad <ryanhaddad@apple.com> 2 14 -
trunk/LayoutTests/inspector/unit-tests/target-manager-expected.txt
r220119 r225244 8 8 PASS: Main target should have an ExecutionContext. 9 9 PASS: Main target should have the global RuntimeAgent. 10 Target - Main- Page10 Target - Symbol(page) - Page 11 11 12 12 -- Running test case: TargetManager.WorkerTarget.Create … … 15 15 PASS: Added Target should have a RuntimeAgent. 16 16 PASS: Added Target RuntimeAgent should not be the global RuntimeAgent. 17 Target - Main- Page18 Target - Worker- worker-1.js17 Target - Symbol(page) - Page 18 Target - Symbol(worker) - worker-1.js 19 19 20 20 -- Running test case: TargetManager.WorkerTarget.Remove 21 21 PASS: Removed Target should have Worker type. 22 Target - Main- Page22 Target - Symbol(page) - Page 23 23 -
trunk/LayoutTests/inspector/unit-tests/target-manager.html
r223809 r225244 16 16 function test() 17 17 { 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 29 18 function dumpTargets() { 30 19 for (let target of WI.targets) 31 InspectorTest.log(`Target - ${ typeString(target.type)} - ${target.displayName}`);20 InspectorTest.log(`Target - ${String(target.type)} - ${target.displayName}`); 32 21 } 33 34 22 35 23 let suite = InspectorTest.createAsyncSuite("TargetManager"); -
trunk/Source/JavaScriptCore/ChangeLog
r225243 r225244 1 2017-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 1 12 2017-11-28 Brian Burg <bburg@apple.com> 2 13 -
trunk/Source/JavaScriptCore/inspector/protocol/Network.json
r224704 r225244 2 2 "domain": "Network", 3 3 "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"], 5 5 "types": [ 6 6 { -
trunk/Source/WebInspectorUI/ChangeLog
r225165 r225244 1 2017-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 1 115 2017-11-27 Nikita Vasilyev <nvasilyev@apple.com> 2 116 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r224994 r225244 572 572 localizedStrings["MIME Type:"] = "MIME Type:"; 573 573 localizedStrings["Main"] = "Main"; 574 localizedStrings["Main Frame"] = "Main Frame";575 574 localizedStrings["Manifest URL"] = "Manifest URL"; 576 575 localizedStrings["Margin"] = "Margin"; -
trunk/Source/WebInspectorUI/UserInterface/Base/Main.js
r224994 r225244 91 91 // Main backend target. 92 92 WI.mainTarget = new WI.MainTarget; 93 WI.pageTarget = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.mainTarget : null; 93 94 94 95 // Enable agents. 95 InspectorAgent.enable(); 96 if (window.InspectorAgent) 97 InspectorAgent.enable(); 96 98 97 99 // Perform one-time tasks. … … 136 138 setTimeout(function() { 137 139 // COMPATIBILITY (iOS 8): Inspector.initialized did not exist yet. 138 if ( InspectorAgent.initialized)140 if (window.InspectorAgent && InspectorAgent.initialized) 139 141 InspectorAgent.initialized(); 140 142 }, 0); -
trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
r224368 r225244 711 711 targetData.addScript(script); 712 712 713 if ( target !== WI.mainTarget && !target.mainResource) {713 if (!target.mainResource && (target !== WI.mainResource || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker)) { 714 714 // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script 715 715 // We make the main resource of a WorkerTarget the Script instead of the Resource -
trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js
r223856 r225244 43 43 } 44 44 45 if (window.ServiceWorkerAgent) 46 ServiceWorkerAgent.getInitializationInfo(this._processServiceWorkerInitializationInfo.bind(this)); 47 45 48 if (window.NetworkAgent) 46 49 NetworkAgent.enable(); … … 505 508 let resource = null; 506 509 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 507 519 let frame = this.frameForIdentifier(frameIdentifier); 508 520 if (frame) { 509 521 // 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) 511 523 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) 513 525 resource = frame.provisionalMainResource; 514 526 else { 515 527 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) 517 529 this._addResourceToFrame(frame, resource); 518 530 else if (resource.target) … … 566 578 _addResourceToTarget(target, resource) 567 579 { 568 console.assert(target !== WI. mainTarget);580 console.assert(target !== WI.pageTarget); 569 581 console.assert(resource); 570 582 … … 617 629 } 618 630 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 619 647 _processMainFrameResourceTreePayload(error, mainFramePayload) 620 648 { 621 649 console.assert(this._waitingForMainFrameResourceTreePayload); 622 delete this._waitingForMainFrameResourceTreePayload;650 this._waitingForMainFrameResourceTreePayload = false; 623 651 624 652 if (error) { … … 680 708 // a main resource when we created the Frame. The resource payload does not include anything 681 709 // 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) 683 711 continue; 684 712 685 713 var resource = this._createResource(resourcePayload, payload); 686 if (resource.target === WI. mainTarget)714 if (resource.target === WI.pageTarget) 687 715 frame.addResource(resource); 688 716 else if (resource.target) -
trunk/Source/WebInspectorUI/UserInterface/Controllers/TargetManager.js
r220119 r225244 47 47 return null; 48 48 49 if (targetId === WI.mainTarget.identifier) 50 return WI.mainTarget; 51 49 52 for (let target of this._targets) { 50 53 if (target.identifier === targetId) -
trunk/Source/WebInspectorUI/UserInterface/Models/Resource.js
r224357 r225244 40 40 this._mimeType = mimeType; 41 41 this._mimeTypeComponents = null; 42 this._type = type || WI.Resource.typeFromMIMEType(mimeType);42 this._type = Resource.resolvedType(type, mimeType); 43 43 this._loaderIdentifier = loaderIdentifier || null; 44 44 this._requestIdentifier = requestIdentifier || null; … … 95 95 96 96 // 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 } 97 105 98 106 static typeFromMIMEType(mimeType) … … 711 719 712 720 this._mimeType = mimeType; 713 this._type = type || WI.Resource.typeFromMIMEType(mimeType);721 this._type = Resource.resolvedType(type, mimeType); 714 722 this._statusCode = statusCode; 715 723 this._statusText = statusText; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/Connection.js
r223308 r225244 273 273 }; 274 274 275 InspectorBackend.MainConnection = class InspectorBackend PageConnection extends InspectorBackend.Connection275 InspectorBackend.MainConnection = class InspectorBackendMainConnection extends InspectorBackend.Connection 276 276 { 277 277 constructor() -
trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js
r224368 r225244 28 28 constructor(connection) 29 29 { 30 super("main", "", WI.Target.Type.Main, InspectorBackend.mainConnection);30 let {type, displayName} = MainTarget.mainConnectionInfo(); 31 31 32 let displayName = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.UIString("Main Frame") : this.displayName; 32 super("main", displayName, type, InspectorBackend.mainConnection); 33 33 34 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 } 34 65 } 35 66 36 67 // Protected (Target) 37 68 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 53 69 get mainResource() 54 70 { 71 if (this._mainResource) 72 return this._mainResource; 73 55 74 let mainFrame = WI.frameResourceManager.mainFrame; 56 75 return mainFrame ? mainFrame.mainResource : null; 57 76 } 77 78 set mainResource(resource) 79 { 80 this._mainResource = resource; 81 } 58 82 }; -
trunk/Source/WebInspectorUI/UserInterface/Protocol/Target.js
r223997 r225244 52 52 53 53 get identifier() { return this._identifier; } 54 set identifier(identifier) { this._identifier = identifier; } 55 54 56 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 55 62 get type() { return this._type; } 56 63 get connection() { return this._connection; } … … 60 67 get extraScriptCollection() { return this._extraScriptCollection; } 61 68 62 get mainResource() { return this._mainResource; } 63 set mainResource(resource) { this._mainResource = resource; } 69 get displayName() { return this._name; } 64 70 65 71 addResource(resource) … … 86 92 87 93 WI.Target.Type = { 88 Main: Symbol("main"), 94 Page: Symbol("page"), 95 JSContext: Symbol("jscontext"), 96 ServiceWorker: Symbol("service-worker"), 89 97 Worker: Symbol("worker"), 90 98 }; -
trunk/Source/WebInspectorUI/UserInterface/Test/Test.js
r223428 r225244 46 46 47 47 WI.mainTarget = new WI.MainTarget; 48 WI.pageTarget = WI.sharedApp.debuggableType === WI.DebuggableType.Web ? WI.mainTarget : null; 48 49 49 50 // Instantiate controllers used by tests. -
trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTabContentView.js
r224508 r225244 59 59 static isTabAllowed() 60 60 { 61 return !!window.NetworkAgent && !!window.PageAgent;61 return !!window.NetworkAgent; 62 62 } 63 63 -
trunk/Source/WebInspectorUI/UserInterface/Views/NetworkTableContentView.js
r224994 r225244 274 274 return; 275 275 } 276 276 277 277 this._table.selectRow(rowIndex); 278 278 } … … 861 861 this._needsInitialPopulate = false; 862 862 863 console.assert(WI.frameResourceManager.mainFrame); 864 865 let populateFrameResources = (frame) => { 863 let populateResourcesForFrame = (frame) => { 866 864 if (frame.provisionalMainResource) 867 865 this._pendingInsertions.push(frame.provisionalMainResource); … … 873 871 874 872 for (let childFrame of frame.childFrameCollection.items) 875 populate FrameResources(childFrame);873 populateResourcesForFrame(childFrame); 876 874 }; 877 875 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 } 879 889 880 890 this.needsLayout(); -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js
r222739 r225244 79 79 contentAvailable(content, base64Encoded) 80 80 { 81 // Implemented by subclasses.81 throw WI.NotImplementedError.subclassMustOverride(); 82 82 } 83 83 -
trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js
r224905 r225244 311 311 return; 312 312 313 // Worker script.314 if (script.target !== WI. mainTarget) {313 // Target main resource. 314 if (script.target !== WI.pageTarget) { 315 315 if (script.isMainResource()) 316 316 this._addTargetWithMainResource(script.target); 317 this.contentTreeOutline.disclosureButtons = true; 317 318 return; 318 319 } … … 432 433 _addTargetWithMainResource(target) 433 434 { 434 console.assert(target.type === WI.Target.Type.Worker );435 console.assert(target.type === WI.Target.Type.Worker || target.type === WI.Target.Type.ServiceWorker); 435 436 436 437 let targetTreeElement = new WI.WorkerTreeElement(target); -
trunk/Source/WebInspectorUI/UserInterface/Views/ScriptTreeElement.js
r220119 r225244 49 49 50 50 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); 52 52 this.addClassName("worker-icon"); 53 53 } -
trunk/Source/WebInspectorUI/UserInterface/Views/WorkerTreeElement.js
r220119 r225244 34 34 35 35 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); 37 37 console.assert(target.mainResource instanceof WI.Script); 38 38
Note:
See TracChangeset
for help on using the changeset viewer.