Changeset 225709 in webkit
- Timestamp:
- Dec 8, 2017, 3:03:58 PM (8 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
- 1 copied
-
JavaScriptCore/ChangeLog (modified) (1 diff)
-
JavaScriptCore/inspector/protocol/ServiceWorker.json (modified) (3 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp (modified) (1 diff)
-
WebCore/inspector/agents/worker/ServiceWorkerAgent.h (modified) (1 diff)
-
WebInspectorUI/ChangeLog (modified) (1 diff)
-
WebInspectorUI/UserInterface/Base/Main.js (modified) (2 diffs)
-
WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (modified) (2 diffs)
-
WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js (modified) (5 diffs)
-
WebInspectorUI/UserInterface/Controllers/SourceMapManager.js (modified) (1 diff)
-
WebInspectorUI/UserInterface/Main.html (modified) (3 diffs)
-
WebInspectorUI/UserInterface/Models/LocalScript.js (copied) (copied from trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.h ) (1 diff)
-
WebInspectorUI/UserInterface/Models/SourceMapResource.js (modified) (1 diff)
-
WebInspectorUI/UserInterface/Models/TextRange.js (modified) (2 diffs)
-
WebInspectorUI/UserInterface/Test.html (modified) (3 diffs)
-
WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r225698 r225709 1 2017-12-08 Joseph Pecoraro <pecoraro@apple.com> 2 3 ServiceWorker Inspector: Various issues inspecting service worker on mobile.twitter.com 4 https://bugs.webkit.org/show_bug.cgi?id=180520 5 <rdar://problem/35900764> 6 7 Reviewed by Brian Burg. 8 9 * inspector/protocol/ServiceWorker.json: 10 Include content script content in the initialization info. 11 1 12 2017-12-08 Konstantin Tokarev <annulen@yandex.ru> 2 13 -
trunk/Source/JavaScriptCore/inspector/protocol/ServiceWorker.json
r224826 r225709 5 5 "types": [ 6 6 { 7 "id": " InitializationInfo",7 "id": "Configuration", 8 8 "type": "object", 9 9 "description": "ServiceWorker metadata and initial state.", … … 11 11 { "name": "targetId", "type": "string" }, 12 12 { "name": "securityOrigin", "type": "string" }, 13 { "name": "url", "type": "string", "description": "ServiceWorker main script URL." } 13 { "name": "url", "type": "string", "description": "ServiceWorker main script URL." }, 14 { "name": "content", "type": "string", "description": "ServiceWorker main script content." } 14 15 ] 15 16 } … … 20 21 "description": "Returns the initialization information for this target.", 21 22 "returns": [ 22 { "name": "info", "$ref": " InitializationInfo" }23 { "name": "info", "$ref": "Configuration" } 23 24 ] 24 25 } -
trunk/Source/WebCore/ChangeLog
r225708 r225709 1 2017-12-08 Joseph Pecoraro <pecoraro@apple.com> 2 3 ServiceWorker Inspector: Various issues inspecting service worker on mobile.twitter.com 4 https://bugs.webkit.org/show_bug.cgi?id=180520 5 <rdar://problem/35900764> 6 7 Reviewed by Brian Burg. 8 9 * inspector/agents/worker/ServiceWorkerAgent.cpp: 10 (WebCore::ServiceWorkerAgent::getInitializationInfo): 11 * inspector/agents/worker/ServiceWorkerAgent.h: 12 Add initial script content to initialization so we always at least have main resource content. 13 1 14 2017-12-08 Joseph Pecoraro <pecoraro@apple.com> 2 15 -
trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.cpp
r224826 r225709 53 53 } 54 54 55 void ServiceWorkerAgent::getInitializationInfo(ErrorString&, RefPtr<Inspector::Protocol::ServiceWorker:: InitializationInfo>& info)55 void ServiceWorkerAgent::getInitializationInfo(ErrorString&, RefPtr<Inspector::Protocol::ServiceWorker::Configuration>& info) 56 56 { 57 info = Inspector::Protocol::ServiceWorker:: InitializationInfo::create()57 info = Inspector::Protocol::ServiceWorker::Configuration::create() 58 58 .setTargetId(m_serviceWorkerGlobalScope.identifier()) 59 59 .setSecurityOrigin(m_serviceWorkerGlobalScope.securityOrigin()->toRawString()) 60 60 .setUrl(m_serviceWorkerGlobalScope.thread().contextData().scriptURL) 61 .setContent(m_serviceWorkerGlobalScope.thread().contextData().script) 61 62 .release(); 62 63 } -
trunk/Source/WebCore/inspector/agents/worker/ServiceWorkerAgent.h
r224826 r225709 48 48 49 49 // ServiceWorkerBackendDispatcherHandler 50 void getInitializationInfo(ErrorString&, RefPtr<Inspector::Protocol::ServiceWorker:: InitializationInfo>&) final;50 void getInitializationInfo(ErrorString&, RefPtr<Inspector::Protocol::ServiceWorker::Configuration>&) final; 51 51 52 52 private: -
trunk/Source/WebInspectorUI/ChangeLog
r225704 r225709 1 2017-12-08 Joseph Pecoraro <pecoraro@apple.com> 2 3 ServiceWorker Inspector: Various issues inspecting service worker on mobile.twitter.com 4 https://bugs.webkit.org/show_bug.cgi?id=180520 5 <rdar://problem/35900764> 6 7 Reviewed by Brian Burg. 8 9 * UserInterface/Main.html: 10 * UserInterface/Test.html: 11 New files. 12 13 * UserInterface/Controllers/SourceMapManager.js: 14 (WI.SourceMapManager.prototype._loadAndParseSourceMap): 15 * UserInterface/Models/SourceMapResource.js: 16 (WI.SourceMapResource.prototype.requestContentFromBackend): 17 A ServiceWorker inspector doesn't have a main frame, fall back to an 18 empty frameIdentifier, it is ignored by the Service Worker network agent. 19 20 * UserInterface/Base/Main.js: 21 Handle a Service Worker inspector where there is no frame. This can 22 search the main resource's resource collection. 23 24 * UserInterface/Controllers/DebuggerManager.js: 25 (WI.DebuggerManager.prototype.scriptDidParse): 26 27 * UserInterface/Controllers/FrameResourceManager.js: 28 (WI.FrameResourceManager.prototype.resourceRequestDidFailLoading): 29 In Service Workers the resources won't have a parent frame. 30 31 (WI.FrameResourceManager.prototype._addNewResourceToFrameOrTarget): 32 (WI.FrameResourceManager.prototype._processServiceWorkerInitializationInfo): 33 In service worker initialization fallback to using the script content 34 as the main resource if we didn't get a Script that actually includes it. 35 36 * UserInterface/Models/LocalScript.js: 37 (WI.LocalScript): 38 (WI.LocalScript.prototype.requestContentFromBackend): 39 A way to create a local Script with content. 40 41 * UserInterface/Views/SourceCodeTextEditor.js: 42 (WI.SourceCodeTextEditor.prototype.get _supportsDebugging): 43 Disallow breakpoints in a LocalScript since we have no way to tell the 44 backend where to set breakpoints. 45 46 * UserInterface/Models/TextRange.js: 47 (WI.TextRange.fromText): 48 Add a way to get a TextRange from static text. 49 1 50 2017-12-08 Michael Catanzaro <mcatanzaro@igalia.com> 2 51 -
trunk/Source/WebInspectorUI/UserInterface/Base/Main.js
r225587 r225709 811 811 } 812 812 813 varsearchChildFrames = false;813 let searchChildFrames = false; 814 814 if (!frame) { 815 815 frame = this.frameResourceManager.mainFrame; … … 817 817 } 818 818 819 console.assert(frame); 820 821 // WI.Frame.resourceForURL does not check the main resource, only sub-resources. So check both. 819 let resource; 822 820 let simplifiedURL = removeURLFragment(url); 823 var resource = frame.url === simplifiedURL ? frame.mainResource : frame.resourceForURL(simplifiedURL, searchChildFrames); 821 if (frame) { 822 // WI.Frame.resourceForURL does not check the main resource, only sub-resources. So check both. 823 resource = frame.url === simplifiedURL ? frame.mainResource : frame.resourceForURL(simplifiedURL, searchChildFrames); 824 } else if (WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) 825 resource = WI.mainTarget.resourceCollection.resourceForURL(removeURLFragment(url)); 826 824 827 if (resource) { 825 828 let positionToReveal = new WI.SourceCodePosition(options.lineNumber, 0); -
trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js
r225244 r225709 711 711 targetData.addScript(script); 712 712 713 if (!target.mainResource && (target !== WI.mainResource || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker)) { 714 // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script 715 // We make the main resource of a WorkerTarget the Script instead of the Resource 716 // because the frontend may not be informed of the Resource. We should guarantee 717 // the frontend is informed of the Resource. 713 // FIXME: <https://webkit.org/b/164427> Web Inspector: WorkerTarget's mainResource should be a Resource not a Script 714 // We make the main resource of a WorkerTarget the Script instead of the Resource 715 // because the frontend may not be informed of the Resource. We should guarantee 716 // the frontend is informed of the Resource. 717 if (WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) { 718 // A ServiceWorker starts with a LocalScript for the main resource but we can replace it during initialization. 719 if (target.mainResource instanceof WI.LocalScript) { 720 if (script.url === target.name) 721 target.mainResource = script; 722 } 723 } else if (!target.mainResource && target !== WI.mainTarget) { 724 // A Worker starts without a main resource and we insert one. 718 725 if (script.url === target.name) { 719 726 target.mainResource = script; … … 735 742 this.dispatchEventToListeners(WI.DebuggerManager.Event.ScriptAdded, {script}); 736 743 737 if ( target !== WI.mainTarget&& !script.isMainResource() && !script.resource)744 if ((target !== WI.mainTarget || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) && !script.isMainResource() && !script.resource) 738 745 target.addScript(script); 739 746 } -
trunk/Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js
r225244 r225709 44 44 45 45 if (window.ServiceWorkerAgent) 46 ServiceWorkerAgent.getInitializationInfo(this._processServiceWorker InitializationInfo.bind(this));46 ServiceWorkerAgent.getInitializationInfo(this._processServiceWorkerConfiguration.bind(this)); 47 47 48 48 if (window.NetworkAgent) … … 459 459 resource.markAsFailed(canceled, elapsedTime, errorText); 460 460 461 if (resource === resource.parentFrame.provisionalMainResource)461 if (resource.parentFrame && resource === resource.parentFrame.provisionalMainResource) 462 462 resource.parentFrame.clearProvisionalLoad(); 463 463 … … 535 535 } else { 536 536 // This is a new request for a new frame, which is always the main resource. 537 console.assert(WI.sharedApp.debuggableType !== WI.DebuggableType.ServiceWorker); 537 538 console.assert(!targetId); 538 539 resource = new WI.Resource(url, null, type, loaderIdentifier, targetId, requestIdentifier, requestMethod, requestHeaders, requestData, elapsedTime, walltime, initiatorSourceCodeLocation, originalRequestWillBeSentTimestamp); … … 629 630 } 630 631 631 _processServiceWorker InitializationInfo(error, initializationPayload)632 _processServiceWorkerConfiguration(error, initializationPayload) 632 633 { 633 634 console.assert(this._waitingForMainFrameResourceTreePayload); … … 643 644 WI.mainTarget.identifier = initializationPayload.targetId; 644 645 WI.mainTarget.name = initializationPayload.url; 646 647 // Create a main resource with this content in case the content never shows up as a WI.Script. 648 const type = WI.Script.SourceType.Program; 649 let script = new WI.LocalScript(WI.mainTarget, initializationPayload.url, type, initializationPayload.content); 650 WI.mainTarget.mainResource = script; 651 652 InspectorBackend.runAfterPendingDispatches(() => { 653 if (WI.mainTarget.mainResource === script) { 654 // We've now received all the scripts, if we don't have a better main resource use this LocalScript. 655 WI.debuggerManager.dataForTarget(WI.mainTarget).addScript(script); 656 WI.debuggerManager.dispatchEventToListeners(WI.DebuggerManager.Event.ScriptAdded, {script}); 657 } 658 }); 645 659 } 646 660 -
trunk/Source/WebInspectorUI/UserInterface/Controllers/SourceMapManager.js
r223308 r225709 137 137 frameIdentifier = originalSourceCode.parentFrame.id; 138 138 139 if (!frameIdentifier )139 if (!frameIdentifier && WI.frameResourceManager.mainFrame) 140 140 frameIdentifier = WI.frameResourceManager.mainFrame.id; 141 else 142 frameIdentifier = ""; 141 143 142 144 NetworkAgent.loadResource(frameIdentifier, sourceMapURL, sourceMapLoaded.bind(this)); -
trunk/Source/WebInspectorUI/UserInterface/Main.html
r225547 r225709 329 329 <script src="Models/TimelineRecord.js"></script> 330 330 331 <script src="Models/Resource.js"></script> 332 <script src="Models/Script.js"></script> 333 <script src="Models/LocalScript.js"></script> 334 331 335 <script src="Models/AnalyzerMessage.js"></script> 332 336 <script src="Models/ApplicationCacheFrame.js"></script> … … 412 416 <script src="Models/RecordingInitialStateAction.js"></script> 413 417 <script src="Models/RenderingFrameTimelineRecord.js"></script> 414 <script src="Models/Resource.js"></script>415 418 <script src="Models/ResourceCollection.js"></script> 416 419 <script src="Models/ResourceQueryMatch.js"></script> … … 420 423 <script src="Models/Revision.js"></script> 421 424 <script src="Models/ScopeChainNode.js"></script> 422 <script src="Models/Script.js"></script>423 425 <script src="Models/ScriptInstrument.js"></script> 424 426 <script src="Models/ScriptSyntaxTree.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Models/LocalScript.js
r225708 r225709 24 24 */ 25 25 26 #pragma once 26 WI.LocalScript = class LocalScript extends WI.Script 27 { 28 constructor(target, url, sourceType, text) 29 { 30 super(target, null, WI.TextRange.fromText(text), url, sourceType); 27 31 28 #if ENABLE(SERVICE_WORKER) 32 this._text = text; 33 } 29 34 30 #include "InspectorWebAgentBase.h" 31 #include <inspector/InspectorBackendDispatchers.h> 35 // Public 32 36 33 namespace WebCore { 34 35 class ServiceWorkerGlobalScope; 36 37 typedef String ErrorString; 38 39 class ServiceWorkerAgent final : public InspectorAgentBase, public Inspector::ServiceWorkerBackendDispatcherHandler { 40 WTF_MAKE_NONCOPYABLE(ServiceWorkerAgent); 41 WTF_MAKE_FAST_ALLOCATED; 42 public: 43 explicit ServiceWorkerAgent(WorkerAgentContext&); 44 virtual ~ServiceWorkerAgent() = default; 45 46 void didCreateFrontendAndBackend(Inspector::FrontendRouter*, Inspector::BackendDispatcher*) final; 47 void willDestroyFrontendAndBackend(Inspector::DisconnectReason) final; 48 49 // ServiceWorkerBackendDispatcherHandler 50 void getInitializationInfo(ErrorString&, RefPtr<Inspector::Protocol::ServiceWorker::InitializationInfo>&) final; 51 52 private: 53 ServiceWorkerGlobalScope& m_serviceWorkerGlobalScope; 54 RefPtr<Inspector::ServiceWorkerBackendDispatcher> m_backendDispatcher; 37 requestContentFromBackend() 38 { 39 return Promise.resolve({scriptSource: this._text}); 40 } 55 41 }; 56 57 } // namespace WebCore58 59 #endif // ENABLE(SERVICE_WORKER) -
trunk/Source/WebInspectorUI/UserInterface/Models/SourceMapResource.js
r221891 r225709 141 141 frameIdentifier = this._sourceMap.originalSourceCode.parentFrame.id; 142 142 143 if (!frameIdentifier )143 if (!frameIdentifier && WI.frameResourceManager.mainFrame) 144 144 frameIdentifier = WI.frameResourceManager.mainFrame.id; 145 else 146 frameIdentifier = ""; 145 147 146 148 return NetworkAgent.loadResource(frameIdentifier, this.url).then(sourceMapResourceLoaded.bind(this)).catch(sourceMapResourceLoadError.bind(this)); -
trunk/Source/WebInspectorUI/UserInterface/Models/TextRange.js
r225568 r225709 50 50 this._endColumn = NaN; 51 51 } 52 } 53 54 // Static 55 56 static fromText(text) 57 { 58 let lines = text.split("\n"); 59 return new WI.TextRange(0, 0, lines.length - 1, lines.lastValue.length); 52 60 } 53 61 … … 153 161 return this.cloneAndModify(-line, deltaStartColumn, -line, deltaEndColumn); 154 162 } 155 156 163 }; -
trunk/Source/WebInspectorUI/UserInterface/Test.html
r224606 r225709 101 101 <script src="Models/TimelineRange.js"></script> 102 102 <script src="Models/TimelineRecord.js"></script> 103 104 <script src="Models/Resource.js"></script> 105 <script src="Models/Script.js"></script> 106 <script src="Models/LocalScript.js"></script> 103 107 104 108 <script src="Models/Breakpoint.js"></script> … … 169 173 <script src="Models/RecordingInitialStateAction.js"></script> 170 174 <script src="Models/RenderingFrameTimelineRecord.js"></script> 171 <script src="Models/Resource.js"></script>172 175 <script src="Models/ResourceCollection.js"></script> 173 176 <script src="Models/ResourceQueryMatch.js"></script> … … 177 180 <script src="Models/Revision.js"></script> 178 181 <script src="Models/ScopeChainNode.js"></script> 179 <script src="Models/Script.js"></script>180 182 <script src="Models/ScriptInstrument.js"></script> 181 183 <script src="Models/ScriptSyntaxTree.js"></script> -
trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js
r220119 r225709 1175 1175 return this._sourceCode.type === WI.Resource.Type.Document || this._sourceCode.type === WI.Resource.Type.Script; 1176 1176 if (this._sourceCode instanceof WI.Script) 1177 return true;1177 return !(this._sourceCode instanceof WI.LocalScript); 1178 1178 return false; 1179 1179 }
Note:
See TracChangeset
for help on using the changeset viewer.