<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[224368] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/224368">224368</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2017-11-02 18:30:01 -0700 (Thu, 02 Nov 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make ServiceWorker a Remote Inspector debuggable target
https://bugs.webkit.org/show_bug.cgi?id=179043
<rdar://problem/34126008>

Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/remote/RemoteControllableTarget.h:
* inspector/remote/RemoteInspectionTarget.h:
* inspector/remote/RemoteInspectorConstants.h:
Include a new ServiceWorker remote inspector target type.

* inspector/remote/cocoa/RemoteInspectorCocoa.mm:
(Inspector::RemoteInspector::listingForInspectionTarget const):
Implement listing for a ServiceWorker to include a URL like a page.

* inspector/remote/glib/RemoteInspectorGlib.cpp:
(Inspector::RemoteInspector::listingForInspectionTarget const):
Bail for ServiceWorker support in glib. They will need to implement their support.

Source/WebCore:

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
New files.

* workers/service/context/ServiceWorkerDebuggable.h: Added.
* workers/service/context/ServiceWorkerDebuggable.cpp: Added.
(WebCore::ServiceWorkerDebuggable::ServiceWorkerDebuggable):
(WebCore::ServiceWorkerDebuggable::connect):
(WebCore::ServiceWorkerDebuggable::disconnect):
(WebCore::ServiceWorkerDebuggable::dispatchMessageFromRemote):
ServiceWorker remote inspector target, exposes the script url to debuggers.
Pass the channel on to the inspector proxy to hook it up to the worker.

* workers/service/context/ServiceWorkerInspectorProxy.h:
* workers/service/context/ServiceWorkerInspectorProxy.cpp: Added.
(WebCore::ServiceWorkerInspectorProxy::ServiceWorkerInspectorProxy):
(WebCore::ServiceWorkerInspectorProxy::~ServiceWorkerInspectorProxy):
(WebCore::ServiceWorkerInspectorProxy::serviceWorkerTerminated):
Handle interesting events throughout a Service Worker life cycle.

(WebCore::ServiceWorkerInspectorProxy::connectToWorker):
(WebCore::ServiceWorkerInspectorProxy::disconnectFromWorker):
(WebCore::ServiceWorkerInspectorProxy::sendMessageToWorker):
(WebCore::ServiceWorkerInspectorProxy::sendMessageFromWorkerToFrontend):
Implement existing worker debugger hooks for connection setup and sending messages.
Inspector protocol messages come in on the MainThread and hop over to the
WorkerThread to be handled on the expected context thread. Likewise outgoing
messages hop back to be sent through the InspectorFrontend channel on MainThread.

* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::ServiceWorkerThread):
* workers/service/context/ServiceWorkerThread.h:
* workers/service/context/ServiceWorkerThreadProxy.h:
* workers/service/context/ServiceWorkerThreadProxy.cpp:
(WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
(WebCore::ServiceWorkerThreadProxy::postMessageToDebugger):
Construct the new inspector proxy and debuggable registration.
Call lifecycle events and debugger hooks when appropriate.

Source/WebInspectorUI:

Customize the Web Inspector frontend for a ServiceWorker target.
Currently this just behaves like a JavaScript Context target because
we haven't yet added support for Networking capabilities.

* UserInterface/Controllers/DebuggerManager.js:
(WI.DebuggerManager.prototype.get knownNonResourceScripts):
Drive-by fix a bug where lazily initializing the Resources / Debugger tabs
would show Console evaluation scripts. We should ignore them, like we
do in other places.

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Controllers/AppController.js:
(WI.AppController):
(WI.AppController.debuggableTypeFromHost):
* UserInterface/Controllers/AppControllerBase.js:
* UserInterface/Controllers/TimelineManager.js:
(WI.TimelineManager.defaultTimelineTypes):
(WI.TimelineManager.availableTimelineTypes):
* UserInterface/Models/TimelineRecording.js:
(WI.TimelineRecording.sourceCodeTimelinesSupported):
* UserInterface/Protocol/MainTarget.js:
(WI.MainTarget.prototype.get displayName):
* UserInterface/Test/TestAppController.js:
* UserInterface/Views/DashboardContainerView.css:
(body:not(.web) .toolbar .dashboard-container):
(body.javascript .toolbar .dashboard-container): Deleted.
* UserInterface/Views/DefaultDashboardView.css:
(body:not(.web) .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time)):
(body.javascript .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time)): Deleted.
* UserInterface/Views/ResourceSidebarPanel.js:
(WI.ResourceSidebarPanel):
(WI.ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel):
(WI.ResourceSidebarPanel.prototype.initialLayout):
(WI.ResourceSidebarPanel.prototype._addScript):
(WI.ResourceSidebarPanel.prototype._extraDomainsActivated):
* UserInterface/Views/Toolbar.js:

Source/WebKit:

* UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h:
* UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
(debuggableTypeString):
Provide a way to start a Remote Web Inspector frontend for a ServiceWorker target type.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteControllableTargeth">trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectionTargeth">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorConstantsh">trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremotecocoaRemoteInspectorCocoamm">trunk/Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm</a></li>
<li><a href="#trunkSourceJavaScriptCoreinspectorremoteglibRemoteInspectorGlibcpp">trunk/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreSourcestxt">trunk/Source/WebCore/Sources.txt</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerThreadcpp">trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerThreadh">trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerThreadProxycpp">trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerThreadProxyh">trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h</a></li>
<li><a href="#trunkSourceWebInspectorUIChangeLog">trunk/Source/WebInspectorUI/ChangeLog</a></li>
<li><a href="#trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs">trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersAppControllerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/AppController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersAppControllerBasejs">trunk/Source/WebInspectorUI/UserInterface/Controllers/AppControllerBase.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceControllersTimelineManagerjs">trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceModelsTimelineRecordingjs">trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceProtocolMainTargetjs">trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceTestTestAppControllerjs">trunk/Source/WebInspectorUI/UserInterface/Test/TestAppController.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDashboardContainerViewcss">trunk/Source/WebInspectorUI/UserInterface/Views/DashboardContainerView.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsDefaultDashboardViewcss">trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.css</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs">trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js</a></li>
<li><a href="#trunkSourceWebInspectorUIUserInterfaceViewsToolbarjs">trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js</a></li>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKRemoteWebInspectorViewControllerh">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessAPICocoa_WKRemoteWebInspectorViewControllermm">trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerDebuggablecpp">trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerDebuggableh">trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.h</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerInspectorProxycpp">trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.cpp</a></li>
<li><a href="#trunkSourceWebCoreworkersservicecontextServiceWorkerInspectorProxyh">trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/ChangeLog       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Make ServiceWorker a Remote Inspector debuggable target
+        https://bugs.webkit.org/show_bug.cgi?id=179043
+        <rdar://problem/34126008>
+
+        Reviewed by Brian Burg.
+
+        * inspector/remote/RemoteControllableTarget.h:
+        * inspector/remote/RemoteInspectionTarget.h:
+        * inspector/remote/RemoteInspectorConstants.h:
+        Include a new ServiceWorker remote inspector target type.
+
+        * inspector/remote/cocoa/RemoteInspectorCocoa.mm:
+        (Inspector::RemoteInspector::listingForInspectionTarget const):
+        Implement listing for a ServiceWorker to include a URL like a page.
+
+        * inspector/remote/glib/RemoteInspectorGlib.cpp:
+        (Inspector::RemoteInspector::listingForInspectionTarget const):
+        Bail for ServiceWorker support in glib. They will need to implement their support.
+
</ins><span class="cx"> 2017-11-02  Michael Saboff  <msaboff@apple.com>
</span><span class="cx"> 
</span><span class="cx">         DFG needs to handle code motion of code in for..in loop bodies
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteControllableTargeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h  2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteControllableTarget.h     2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx">     unsigned targetIdentifier() const { return m_identifier; }
</span><span class="cx">     void setTargetIdentifier(unsigned identifier) { m_identifier = identifier; }
</span><span class="cx"> 
</span><del>-    enum class Type { JavaScript, Web, Automation };
</del><ins>+    enum class Type { JavaScript, ServiceWorker, Web, Automation };
</ins><span class="cx">     virtual Type type() const = 0;
</span><span class="cx">     virtual bool remoteControlAllowed() const = 0;
</span><span class="cx">     virtual void dispatchMessageFromRemote(const String& message) = 0;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectionTargeth"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.h    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectionTarget.h       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -71,6 +71,7 @@
</span><span class="cx">     static bool isType(const Inspector::RemoteControllableTarget& target) \
</span><span class="cx">     { \
</span><span class="cx">         return target.type() == Inspector::RemoteControllableTarget::Type::JavaScript \
</span><ins>+            || target.type() == Inspector::RemoteControllableTarget::Type::ServiceWorker \
</ins><span class="cx">             || target.type() == Inspector::RemoteControllableTarget::Type::Web; \
</span><span class="cx">     }
</span><span class="cx"> SPECIALIZE_TYPE_TRAITS_END()
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteRemoteInspectorConstantsh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h  2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/inspector/remote/RemoteInspectorConstants.h     2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -72,6 +72,7 @@
</span><span class="cx"> #define WIRConnectionDiedMessage                @"WIRConnectionDiedMessage"
</span><span class="cx"> #define WIRTypeKey                              @"WIRTypeKey"
</span><span class="cx"> #define WIRTypeJavaScript                       @"WIRTypeJavaScript"
</span><ins>+#define WIRTypeServiceWorker                    @"WIRTypeServiceWorker"
</ins><span class="cx"> #define WIRTypeWeb                              @"WIRTypeWeb"
</span><span class="cx"> #define WIRTypeAutomation                       @"WIRTypeAutomation"
</span><span class="cx"> #define WIRAutomaticallyPause                   @"WIRAutomaticallyPause"
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremotecocoaRemoteInspectorCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm       2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/inspector/remote/cocoa/RemoteInspectorCocoa.mm  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -392,6 +392,11 @@
</span><span class="cx">         [listing setObject:target.name() forKey:WIRTitleKey];
</span><span class="cx">         [listing setObject:WIRTypeJavaScript forKey:WIRTypeKey];
</span><span class="cx">         break;
</span><ins>+    case RemoteInspectionTarget::Type::ServiceWorker:
+        [listing setObject:target.url() forKey:WIRURLKey];
+        [listing setObject:target.name() forKey:WIRTitleKey];
+        [listing setObject:WIRTypeServiceWorker forKey:WIRTypeKey];
+        break;
</ins><span class="cx">     case RemoteInspectionTarget::Type::Web:
</span><span class="cx">         [listing setObject:target.url() forKey:WIRURLKey];
</span><span class="cx">         [listing setObject:target.name() forKey:WIRTitleKey];
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreinspectorremoteglibRemoteInspectorGlibcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp        2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/JavaScriptCore/inspector/remote/glib/RemoteInspectorGlib.cpp   2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -186,6 +186,10 @@
</span><span class="cx">     if (!target.remoteDebuggingAllowed())
</span><span class="cx">         return nullptr;
</span><span class="cx"> 
</span><ins>+    // FIXME: Support remote debugging of a ServiceWorker.
+    if (target.type() == RemoteInspectionTarget::Type::ServiceWorker)
+        return nullptr;
+
</ins><span class="cx">     ASSERT(target.type() == RemoteInspectionTarget::Type::Web || target.type() == RemoteInspectionTarget::Type::JavaScript);
</span><span class="cx">     return g_variant_new("(tsssb)", static_cast<guint64>(target.targetIdentifier()),
</span><span class="cx">         target.type() == RemoteInspectionTarget::Type::Web ? "Web" : "JavaScript",
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/ChangeLog      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Make ServiceWorker a Remote Inspector debuggable target
+        https://bugs.webkit.org/show_bug.cgi?id=179043
+        <rdar://problem/34126008>
+
+        Reviewed by Brian Burg.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        New files.
+
+        * workers/service/context/ServiceWorkerDebuggable.h: Added.
+        * workers/service/context/ServiceWorkerDebuggable.cpp: Added.
+        (WebCore::ServiceWorkerDebuggable::ServiceWorkerDebuggable):
+        (WebCore::ServiceWorkerDebuggable::connect):
+        (WebCore::ServiceWorkerDebuggable::disconnect):
+        (WebCore::ServiceWorkerDebuggable::dispatchMessageFromRemote):
+        ServiceWorker remote inspector target, exposes the script url to debuggers.
+        Pass the channel on to the inspector proxy to hook it up to the worker.
+
+        * workers/service/context/ServiceWorkerInspectorProxy.h:
+        * workers/service/context/ServiceWorkerInspectorProxy.cpp: Added.
+        (WebCore::ServiceWorkerInspectorProxy::ServiceWorkerInspectorProxy):
+        (WebCore::ServiceWorkerInspectorProxy::~ServiceWorkerInspectorProxy):
+        (WebCore::ServiceWorkerInspectorProxy::serviceWorkerTerminated):
+        Handle interesting events throughout a Service Worker life cycle.
+
+        (WebCore::ServiceWorkerInspectorProxy::connectToWorker):
+        (WebCore::ServiceWorkerInspectorProxy::disconnectFromWorker):
+        (WebCore::ServiceWorkerInspectorProxy::sendMessageToWorker):
+        (WebCore::ServiceWorkerInspectorProxy::sendMessageFromWorkerToFrontend):
+        Implement existing worker debugger hooks for connection setup and sending messages.
+        Inspector protocol messages come in on the MainThread and hop over to the
+        WorkerThread to be handled on the expected context thread. Likewise outgoing
+        messages hop back to be sent through the InspectorFrontend channel on MainThread.
+
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::ServiceWorkerThread):
+        * workers/service/context/ServiceWorkerThread.h:
+        * workers/service/context/ServiceWorkerThreadProxy.h:
+        * workers/service/context/ServiceWorkerThreadProxy.cpp:
+        (WebCore::ServiceWorkerThreadProxy::ServiceWorkerThreadProxy):
+        (WebCore::ServiceWorkerThreadProxy::postMessageToDebugger):
+        Construct the new inspector proxy and debuggable registration.
+        Call lifecycle events and debugger hooks when appropriate.
+
</ins><span class="cx"> 2017-11-02  Antti Koivisto  <antti@apple.com>
</span><span class="cx"> 
</span><span class="cx">         display:contents should work with dynamic table mutations
</span></span></pre></div>
<a id="trunkSourceWebCoreSourcestxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Sources.txt (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Sources.txt 2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/Sources.txt    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -2170,7 +2170,9 @@
</span><span class="cx"> workers/service/ServiceWorkerRegistrationOptions.cpp
</span><span class="cx"> workers/service/ServiceWorkerWindowClient.cpp
</span><span class="cx"> 
</span><ins>+workers/service/context/ServiceWorkerDebuggable.cpp
</ins><span class="cx"> workers/service/context/ServiceWorkerFetch.cpp
</span><ins>+workers/service/context/ServiceWorkerInspectorProxy.cpp
</ins><span class="cx"> workers/service/context/ServiceWorkerThread.cpp
</span><span class="cx"> workers/service/context/ServiceWorkerThreadProxy.cpp
</span><span class="cx"> workers/service/context/SWContextManager.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj   2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -2818,7 +2818,9 @@
</span><span class="cx">          A5071E871C56D0E1009951BE /* ResourceUsageThread.h in Headers */ = {isa = PBXBuildFile; fileRef = A5071E841C56D079009951BE /* ResourceUsageThread.h */; };
</span><span class="cx">          A513B3D7114B1666001C429B /* KeyEventCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */; };
</span><span class="cx">          A516E8B7136E04DB0076C3C0 /* LocalizedDateCache.h in Headers */ = {isa = PBXBuildFile; fileRef = A516E8B4136E04DB0076C3C0 /* LocalizedDateCache.h */; };
</span><del>-               A52B349E1FA41703008B6246 /* WorkerDebuggerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A52B349C1FA416F8008B6246 /* WorkerDebuggerProxy.h */; };
</del><ins>+                A52B348F1FA3BDA6008B6246 /* ServiceWorkerDebuggable.h in Headers */ = {isa = PBXBuildFile; fileRef = A52B348C1FA3BD79008B6246 /* ServiceWorkerDebuggable.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A52B34961FA3E290008B6246 /* ServiceWorkerInspectorProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A52B34931FA3E286008B6246 /* ServiceWorkerInspectorProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               A52B349E1FA41703008B6246 /* WorkerDebuggerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A52B349C1FA416F8008B6246 /* WorkerDebuggerProxy.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">           A5416FE618810EF80009FC5F /* YouTubeEmbedShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A5416FE418810EF80009FC5F /* YouTubeEmbedShadowElement.h */; };
</span><span class="cx">          A54A0C621DB7F8C10017A90B /* WorkerInspectorController.h in Headers */ = {isa = PBXBuildFile; fileRef = A54A0C601DB7F8B70017A90B /* WorkerInspectorController.h */; };
</span><span class="cx">          A54A0C661DB805360017A90B /* WorkerScriptDebugServer.h in Headers */ = {isa = PBXBuildFile; fileRef = A54A0C641DB805320017A90B /* WorkerScriptDebugServer.h */; };
</span><span class="lines">@@ -10677,6 +10679,10 @@
</span><span class="cx">          A516E8B5136E04DB0076C3C0 /* LocalizedDateCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LocalizedDateCache.mm; sourceTree = "<group>"; };
</span><span class="cx">          A518225417E2A0D400A9BA1D /* InspectorOverlayPage.css */ = {isa = PBXFileReference; lastKnownFileType = text.css; path = InspectorOverlayPage.css; sourceTree = "<group>"; };
</span><span class="cx">          A518225517E2A0D400A9BA1D /* InspectorOverlayPage.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = InspectorOverlayPage.js; sourceTree = "<group>"; };
</span><ins>+               A52B348C1FA3BD79008B6246 /* ServiceWorkerDebuggable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerDebuggable.h; sourceTree = "<group>"; };
+               A52B348E1FA3BD79008B6246 /* ServiceWorkerDebuggable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerDebuggable.cpp; sourceTree = "<group>"; };
+               A52B34931FA3E286008B6246 /* ServiceWorkerInspectorProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerInspectorProxy.h; sourceTree = "<group>"; };
+               A52B34951FA3E286008B6246 /* ServiceWorkerInspectorProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerInspectorProxy.cpp; sourceTree = "<group>"; };
</ins><span class="cx">           A52B349C1FA416F8008B6246 /* WorkerDebuggerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerDebuggerProxy.h; sourceTree = "<group>"; };
</span><span class="cx">          A5416FE318810EF80009FC5F /* YouTubeEmbedShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YouTubeEmbedShadowElement.cpp; sourceTree = "<group>"; };
</span><span class="cx">          A5416FE418810EF80009FC5F /* YouTubeEmbedShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YouTubeEmbedShadowElement.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -17100,8 +17106,12 @@
</span><span class="cx">          517C87071F8E8FF200EB8076 /* context */ = {
</span><span class="cx">                  isa = PBXGroup;
</span><span class="cx">                  children = (
</span><ins>+                               A52B348E1FA3BD79008B6246 /* ServiceWorkerDebuggable.cpp */,
+                               A52B348C1FA3BD79008B6246 /* ServiceWorkerDebuggable.h */,
</ins><span class="cx">                           419ACF901F97E7D6009F1A83 /* ServiceWorkerFetch.cpp */,
</span><span class="cx">                          419ACF8E1F97E7D5009F1A83 /* ServiceWorkerFetch.h */,
</span><ins>+                               A52B34951FA3E286008B6246 /* ServiceWorkerInspectorProxy.cpp */,
+                               A52B34931FA3E286008B6246 /* ServiceWorkerInspectorProxy.h */,
</ins><span class="cx">                           517C87111F8EE72F00EB8076 /* ServiceWorkerThread.cpp */,
</span><span class="cx">                          517C87101F8EE72E00EB8076 /* ServiceWorkerThread.h */,
</span><span class="cx">                          4112B5411F9F9C9C00E67875 /* ServiceWorkerThreadProxy.cpp */,
</span><span class="lines">@@ -28880,9 +28890,11 @@
</span><span class="cx">                          8369FDFC1FA102E300C1FF1F /* ServiceWorkerClientType.h in Headers */,
</span><span class="cx">                          51F1755F1F3EBC8300C74950 /* ServiceWorkerContainer.h in Headers */,
</span><span class="cx">                          51CA7EE91F883390003D3131 /* ServiceWorkerContextData.h in Headers */,
</span><ins>+                               A52B348F1FA3BDA6008B6246 /* ServiceWorkerDebuggable.h in Headers */,
</ins><span class="cx">                           419ACF921F97E7DA009F1A83 /* ServiceWorkerFetch.h in Headers */,
</span><span class="cx">                          517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
</span><span class="cx">                          51F175611F3EBC8300C74950 /* ServiceWorkerGlobalScope.h in Headers */,
</span><ins>+                               A52B34961FA3E290008B6246 /* ServiceWorkerInspectorProxy.h in Headers */,
</ins><span class="cx">                           51F175631F3EBC8300C74950 /* ServiceWorkerJob.h in Headers */,
</span><span class="cx">                          51F175641F3EBC8300C74950 /* ServiceWorkerJobClient.h in Headers */,
</span><span class="cx">                          51F645691F4539B900B54DED /* ServiceWorkerJobData.h in Headers */,
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerDebuggablecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.cpp (0 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.cpp                         (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.cpp    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -0,0 +1,63 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ServiceWorkerDebuggable.h"
+
+#if ENABLE(REMOTE_INSPECTOR)
+#if ENABLE(SERVICE_WORKER)
+
+#include "ServiceWorkerInspectorProxy.h"
+#include "ServiceWorkerThreadProxy.h"
+
+namespace WebCore {
+
+using namespace Inspector;
+
+ServiceWorkerDebuggable::ServiceWorkerDebuggable(ServiceWorkerThreadProxy& serviceWorkerThreadProxy, const ServiceWorkerContextData& data)
+    : m_serviceWorkerThreadProxy(serviceWorkerThreadProxy)
+    , m_scriptURL(data.scriptURL)
+{
+}
+
+void ServiceWorkerDebuggable::connect(Inspector::FrontendChannel* channel, bool, bool)
+{
+    m_serviceWorkerThreadProxy.inspectorProxy().connectToWorker(channel);
+}
+
+void ServiceWorkerDebuggable::disconnect(Inspector::FrontendChannel* channel)
+{
+    m_serviceWorkerThreadProxy.inspectorProxy().disconnectFromWorker(channel);
+}
+
+void ServiceWorkerDebuggable::dispatchMessageFromRemote(const String& message)
+{
+    m_serviceWorkerThreadProxy.inspectorProxy().sendMessageToWorker(message);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
+#endif // ENABLE(REMOTE_INSPECTOR)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerDebuggableh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.h (0 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.h                           (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerDebuggable.h      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -0,0 +1,66 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(REMOTE_INSPECTOR)
+#if ENABLE(SERVICE_WORKER)
+
+#include "ServiceWorkerContextData.h"
+#include <JavaScriptCore/RemoteInspectionTarget.h>
+#include <wtf/Noncopyable.h>
+
+namespace WebCore {
+
+class ServiceWorkerThreadProxy;
+
+class ServiceWorkerDebuggable final : public Inspector::RemoteInspectionTarget {
+    WTF_MAKE_FAST_ALLOCATED;
+    WTF_MAKE_NONCOPYABLE(ServiceWorkerDebuggable);
+public:
+    ServiceWorkerDebuggable(ServiceWorkerThreadProxy&, const ServiceWorkerContextData&);
+    ~ServiceWorkerDebuggable() = default;
+
+    Inspector::RemoteControllableTarget::Type type() const override { return Inspector::RemoteControllableTarget::Type::ServiceWorker; }
+
+    String name() const override { return ASCIILiteral("ServiceWorker"); }
+    String url() const override { return m_scriptURL; }
+    bool hasLocalDebugger() const override { return false; }
+
+    void connect(Inspector::FrontendChannel*, bool isAutomaticConnection = false, bool immediatelyPause = false) override;
+    void disconnect(Inspector::FrontendChannel*) override;
+    void dispatchMessageFromRemote(const String& message) override;
+
+private:
+    ServiceWorkerThreadProxy& m_serviceWorkerThreadProxy;
+    String m_scriptURL;
+};
+
+} // namespace WebCore
+
+SPECIALIZE_TYPE_TRAITS_CONTROLLABLE_TARGET(WebCore::ServiceWorkerDebuggable, ServiceWorker);
+
+#endif // ENABLE(SERVICE_WORKER)
+#endif // ENABLE(REMOTE_INSPECTOR)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerInspectorProxycpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.cpp (0 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.cpp                             (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.cpp        2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -0,0 +1,100 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "ServiceWorkerInspectorProxy.h"
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ScriptExecutionContext.h"
+#include "ServiceWorkerGlobalScope.h"
+#include "ServiceWorkerThreadProxy.h"
+#include "WorkerInspectorController.h"
+#include "WorkerRunLoop.h"
+#include <inspector/InspectorAgentBase.h>
+#include <inspector/InspectorFrontendChannel.h>
+
+namespace WebCore {
+
+using namespace Inspector;
+
+ServiceWorkerInspectorProxy::ServiceWorkerInspectorProxy(ServiceWorkerThreadProxy& serviceWorkerThreadProxy)
+    : m_serviceWorkerThreadProxy(serviceWorkerThreadProxy)
+{
+    ASSERT(isMainThread());
+}
+
+ServiceWorkerInspectorProxy::~ServiceWorkerInspectorProxy()
+{
+    ASSERT(isMainThread());
+    ASSERT(!m_channel);
+}
+
+void ServiceWorkerInspectorProxy::serviceWorkerTerminated()
+{
+    m_channel = nullptr;
+}
+
+void ServiceWorkerInspectorProxy::connectToWorker(FrontendChannel* channel)
+{
+    m_channel = channel;
+
+    m_serviceWorkerThreadProxy.thread().runLoop().postTaskForMode([] (ScriptExecutionContext& context) {
+        downcast<WorkerGlobalScope>(context).inspectorController().connectFrontend();
+    }, WorkerRunLoop::debuggerMode());
+}
+
+void ServiceWorkerInspectorProxy::disconnectFromWorker(FrontendChannel* channel)
+{
+    ASSERT_UNUSED(channel, channel == m_channel);
+    m_channel = nullptr;
+
+    m_serviceWorkerThreadProxy.thread().runLoop().postTaskForMode([] (ScriptExecutionContext& context) {
+        downcast<WorkerGlobalScope>(context).inspectorController().disconnectFrontend(DisconnectReason::InspectorDestroyed);
+
+        // In case the worker is paused running debugger tasks, ensure we break out of
+        // the pause since this will be the last debugger task we send to the worker.
+        downcast<WorkerGlobalScope>(context).thread().stopRunningDebuggerTasks();
+    }, WorkerRunLoop::debuggerMode());
+}
+
+void ServiceWorkerInspectorProxy::sendMessageToWorker(const String& message)
+{
+    m_serviceWorkerThreadProxy.thread().runLoop().postTaskForMode([message = message.isolatedCopy()] (ScriptExecutionContext& context) {
+        downcast<WorkerGlobalScope>(context).inspectorController().dispatchMessageFromFrontend(message);
+    }, WorkerRunLoop::debuggerMode());
+}
+
+void ServiceWorkerInspectorProxy::sendMessageFromWorkerToFrontend(const String& message)
+{
+    if (!m_channel)
+        return;
+
+    m_channel->sendMessageToFrontend(message);
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerInspectorProxyhfromrev224367trunkSourceWebInspectorUIUserInterfaceControllersAppControllerjs"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.h (from rev 224367, trunk/Source/WebInspectorUI/UserInterface/Controllers/AppController.js) (0 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.h                               (rev 0)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerInspectorProxy.h  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -0,0 +1,64 @@
</span><ins>+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include <wtf/Forward.h>
+
+// All of these methods should be called on the Main Thread.
+// Used to send messages to the WorkerInspector on the WorkerThread.
+
+namespace Inspector {
+class FrontendChannel;
+}
+
+namespace WebCore {
+
+class ServiceWorkerThreadProxy;
+
+class ServiceWorkerInspectorProxy {
+    WTF_MAKE_NONCOPYABLE(ServiceWorkerInspectorProxy);
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    explicit ServiceWorkerInspectorProxy(ServiceWorkerThreadProxy&);
+    ~ServiceWorkerInspectorProxy();
+
+    void serviceWorkerTerminated();
+
+    void connectToWorker(Inspector::FrontendChannel*);
+    void disconnectFromWorker(Inspector::FrontendChannel*);
+    void sendMessageToWorker(const String&);
+    void sendMessageFromWorkerToFrontend(const String&);
+
+private:
+    ServiceWorkerThreadProxy& m_serviceWorkerThreadProxy;
+    Inspector::FrontendChannel* m_channel { nullptr };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)
</ins></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerThreadcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp     2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp        2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-class DummyServiceWorkerThreadProxy : public WorkerObjectProxy, public WorkerDebuggerProxy {
</del><ins>+class DummyServiceWorkerThreadProxy : public WorkerObjectProxy {
</ins><span class="cx"> public:
</span><span class="cx">     static DummyServiceWorkerThreadProxy& shared()
</span><span class="cx">     {
</span><span class="lines">@@ -56,7 +56,6 @@
</span><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     void postExceptionToWorkerObject(const String&, int, int, const String&) final { };
</span><del>-    void postMessageToDebugger(const String&) final { }
</del><span class="cx">     void workerGlobalScopeDestroyed() final { };
</span><span class="cx">     void postMessageToWorkerObject(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&) final { };
</span><span class="cx">     void confirmMessageFromWorkerObject(bool) final { };
</span><span class="lines">@@ -64,7 +63,6 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // FIXME: Use a valid WorkerReportingProxy
</span><del>-// FIXME: Use a valid WorkerDebuggerProxy
</del><span class="cx"> // FIXME: Use a valid WorkerObjectProxy
</span><span class="cx"> // FIXME: Use a valid IDBConnection
</span><span class="cx"> // FIXME: Use a valid SocketProvider
</span><span class="lines">@@ -72,8 +70,8 @@
</span><span class="cx"> // FIXME: Use a valid isOnline flag
</span><span class="cx"> // FIXME: Use valid runtime flags
</span><span class="cx"> 
</span><del>-ServiceWorkerThread::ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID, WorkerLoaderProxy& loaderProxy)
-    : WorkerThread(data.scriptURL, data.workerID, ASCIILiteral("WorkerUserAgent"), /* isOnline */ false, data.script, loaderProxy, DummyServiceWorkerThreadProxy::shared(), DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, ContentSecurityPolicyResponseHeaders { }, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), nullptr, nullptr, JSC::RuntimeFlags::createAllEnabled(), SessionID::defaultSessionID())
</del><ins>+ServiceWorkerThread::ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID, WorkerLoaderProxy& loaderProxy, WorkerDebuggerProxy& debuggerProxy)
+    : WorkerThread(data.scriptURL, data.workerID, ASCIILiteral("WorkerUserAgent"), /* isOnline */ false, data.script, loaderProxy, debuggerProxy, DummyServiceWorkerThreadProxy::shared(), WorkerThreadStartMode::Normal, ContentSecurityPolicyResponseHeaders { }, false, SecurityOrigin::create(data.scriptURL).get(), MonotonicTime::now(), nullptr, nullptr, JSC::RuntimeFlags::createAllEnabled(), SessionID::defaultSessionID())
</ins><span class="cx">     , m_serverConnectionIdentifier(serverConnectionIdentifier)
</span><span class="cx">     , m_data(data.isolatedCopy())
</span><span class="cx">     , m_workerObjectProxy(DummyServiceWorkerThreadProxy::shared())
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerThreadh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h       2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -65,7 +65,7 @@
</span><span class="cx">     void runEventLoop() override;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    WEBCORE_EXPORT ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, WorkerLoaderProxy&);
</del><ins>+    WEBCORE_EXPORT ServiceWorkerThread(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, WorkerLoaderProxy&, WorkerDebuggerProxy&);
</ins><span class="cx"> 
</span><span class="cx">     uint64_t m_serverConnectionIdentifier;
</span><span class="cx">     ServiceWorkerContextData m_data;
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerThreadProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp        2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.cpp   2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -55,10 +55,16 @@
</span><span class="cx"> ServiceWorkerThreadProxy::ServiceWorkerThreadProxy(PageConfiguration&& pageConfiguration, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData& data, PAL::SessionID sessionID, CacheStorageProvider& cacheStorageProvider)
</span><span class="cx">     : m_page(createPageForServiceWorker(WTFMove(pageConfiguration), data.scriptURL))
</span><span class="cx">     , m_document(*m_page->mainFrame().document())
</span><del>-    , m_serviceWorkerThread(ServiceWorkerThread::create(serverConnectionIdentifier, data, sessionID, *this))
</del><ins>+    , m_serviceWorkerThread(ServiceWorkerThread::create(serverConnectionIdentifier, data, sessionID, *this, *this))
</ins><span class="cx">     , m_cacheStorageProvider(cacheStorageProvider)
</span><span class="cx">     , m_sessionID(sessionID)
</span><ins>+    , m_inspectorProxy(*this)
</ins><span class="cx"> {
</span><ins>+#if ENABLE(REMOTE_INSPECTOR)
+    m_remoteDebuggable = std::make_unique<ServiceWorkerDebuggable>(*this, data);
+    m_remoteDebuggable->setRemoteDebuggingAllowed(true);
+    m_remoteDebuggable->init();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool ServiceWorkerThreadProxy::postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&& task, const String& mode)
</span><span class="lines">@@ -75,6 +81,14 @@
</span><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ServiceWorkerThreadProxy::postMessageToDebugger(const String& message)
+{
+    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] {
+        // FIXME: Handle terminated case.
+        m_inspectorProxy.sendMessageFromWorkerToFrontend(message);
+    });
+}
+
</ins><span class="cx"> Ref<CacheStorageConnection> ServiceWorkerThreadProxy::createCacheStorageConnection()
</span><span class="cx"> {
</span><span class="cx">     ASSERT(isMainThread());
</span></span></pre></div>
<a id="trunkSourceWebCoreworkersservicecontextServiceWorkerThreadProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h  2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThreadProxy.h     2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -30,28 +30,39 @@
</span><span class="cx"> #include "CacheStorageConnection.h"
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "Page.h"
</span><ins>+#include "ServiceWorkerDebuggable.h"
+#include "ServiceWorkerInspectorProxy.h"
</ins><span class="cx"> #include "ServiceWorkerThread.h"
</span><ins>+#include "WorkerDebuggerProxy.h"
</ins><span class="cx"> #include "WorkerLoaderProxy.h"
</span><span class="cx"> #include <wtf/HashMap.h>
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+
</ins><span class="cx"> class CacheStorageProvider;
</span><span class="cx"> class PageConfiguration;
</span><ins>+class ServiceWorkerInspectorProxy;
</ins><span class="cx"> struct ServiceWorkerContextData;
</span><span class="cx"> 
</span><del>-class ServiceWorkerThreadProxy final : public ThreadSafeRefCounted<ServiceWorkerThreadProxy>, public WorkerLoaderProxy {
</del><ins>+class ServiceWorkerThreadProxy final : public ThreadSafeRefCounted<ServiceWorkerThreadProxy>, public WorkerLoaderProxy, public WorkerDebuggerProxy {
</ins><span class="cx"> public:
</span><span class="cx">     WEBCORE_EXPORT static Ref<ServiceWorkerThreadProxy> create(PageConfiguration&&, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&);
</span><span class="cx"> 
</span><span class="cx">     uint64_t identifier() const { return m_serviceWorkerThread->identifier(); }
</span><span class="cx">     ServiceWorkerThread& thread() { return m_serviceWorkerThread.get(); }
</span><ins>+    ServiceWorkerInspectorProxy& inspectorProxy() { return m_inspectorProxy; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     ServiceWorkerThreadProxy(PageConfiguration&&, uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, PAL::SessionID, CacheStorageProvider&);
</span><ins>+
+    // WorkerLoaderProxy
</ins><span class="cx">     bool postTaskForModeToWorkerGlobalScope(ScriptExecutionContext::Task&&, const String& mode) final;
</span><span class="cx">     void postTaskToLoader(ScriptExecutionContext::Task&&) final;
</span><span class="cx">     Ref<CacheStorageConnection> createCacheStorageConnection() final;
</span><span class="cx"> 
</span><ins>+    // WorkerDebuggerProxy
+    void postMessageToDebugger(const String&) final;
+
</ins><span class="cx">     UniqueRef<Page> m_page;
</span><span class="cx">     Ref<Document> m_document;
</span><span class="cx">     Ref<ServiceWorkerThread> m_serviceWorkerThread;
</span><span class="lines">@@ -58,6 +69,10 @@
</span><span class="cx">     CacheStorageProvider& m_cacheStorageProvider;
</span><span class="cx">     RefPtr<CacheStorageConnection> m_cacheStorageConnection;
</span><span class="cx">     PAL::SessionID m_sessionID;
</span><ins>+    ServiceWorkerInspectorProxy m_inspectorProxy;
+#if ENABLE(REMOTE_INSPECTOR)
+    std::unique_ptr<ServiceWorkerDebuggable> m_remoteDebuggable;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/ChangeLog (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/ChangeLog    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/ChangeLog       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -1,3 +1,48 @@
</span><ins>+2017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Make ServiceWorker a Remote Inspector debuggable target
+        https://bugs.webkit.org/show_bug.cgi?id=179043
+        <rdar://problem/34126008>
+
+        Reviewed by Brian Burg.
+
+        Customize the Web Inspector frontend for a ServiceWorker target.
+        Currently this just behaves like a JavaScript Context target because
+        we haven't yet added support for Networking capabilities.
+
+        * UserInterface/Controllers/DebuggerManager.js:
+        (WI.DebuggerManager.prototype.get knownNonResourceScripts):
+        Drive-by fix a bug where lazily initializing the Resources / Debugger tabs
+        would show Console evaluation scripts. We should ignore them, like we
+        do in other places.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Controllers/AppController.js:
+        (WI.AppController):
+        (WI.AppController.debuggableTypeFromHost):
+        * UserInterface/Controllers/AppControllerBase.js:
+        * UserInterface/Controllers/TimelineManager.js:
+        (WI.TimelineManager.defaultTimelineTypes):
+        (WI.TimelineManager.availableTimelineTypes):
+        * UserInterface/Models/TimelineRecording.js:
+        (WI.TimelineRecording.sourceCodeTimelinesSupported):
+        * UserInterface/Protocol/MainTarget.js:
+        (WI.MainTarget.prototype.get displayName):
+        * UserInterface/Test/TestAppController.js:
+        * UserInterface/Views/DashboardContainerView.css:
+        (body:not(.web) .toolbar .dashboard-container):
+        (body.javascript .toolbar .dashboard-container): Deleted.
+        * UserInterface/Views/DefaultDashboardView.css:
+        (body:not(.web) .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time)):
+        (body.javascript .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time)): Deleted.
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WI.ResourceSidebarPanel):
+        (WI.ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel):
+        (WI.ResourceSidebarPanel.prototype.initialLayout):
+        (WI.ResourceSidebarPanel.prototype._addScript):
+        (WI.ResourceSidebarPanel.prototype._extraDomainsActivated):
+        * UserInterface/Views/Toolbar.js:
+
</ins><span class="cx"> 2017-11-02  Devin Rousso  <webkit@devinrousso.com>
</span><span class="cx"> 
</span><span class="cx">         Web Inspector: Canvas: recording parameters that include an Image should show an InlineSwatch (2D canvas)
</span></span></pre></div>
<a id="trunkSourceWebInspectorUILocalizationsenlprojlocalizedStringsjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js   2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -818,6 +818,7 @@
</span><span class="cx"> localizedStrings["Self Time"] = "Self Time";
</span><span class="cx"> localizedStrings["Semantic Issue"] = "Semantic Issue";
</span><span class="cx"> localizedStrings["Service Worker"] = "Service Worker";
</span><ins>+localizedStrings["ServiceWorker"] = "ServiceWorker";
</ins><span class="cx"> localizedStrings["Session"] = "Session";
</span><span class="cx"> localizedStrings["Session Storage"] = "Session Storage";
</span><span class="cx"> localizedStrings["Set to Automatically Continue"] = "Set to Automatically Continue";
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersAppControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/AppController.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/AppController.js   2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/AppController.js      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -30,9 +30,27 @@
</span><span class="cx">         super();
</span><span class="cx"> 
</span><span class="cx">         this._hasExtraDomains = false;
</span><del>-        this._debuggableType = InspectorFrontendHost.debuggableType() === "web" ? WI.DebuggableType.Web : WI.DebuggableType.JavaScript;
</del><ins>+        this._debuggableType = AppController.debuggableTypeFromHost();
</ins><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Static
+
+    static debuggableTypeFromHost()
+    {
+        let type = InspectorFrontendHost.debuggableType();
+        switch (type) {
+        case "javascript":
+            return WI.DebuggableType.JavaScript;
+        case "service-worker":
+            return WI.DebuggableType.ServiceWorker;
+        case "web":
+            return WI.DebuggableType.Web;
+        default:
+            console.assert(false, "Unexpected debuggable type", type);
+            return WI.DebuggableType.JavaScript;
+        }
+    }
+
</ins><span class="cx">     // Properties.
</span><span class="cx"> 
</span><span class="cx">     get hasExtraDomains() { return this._hasExtraDomains; }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersAppControllerBasejs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/AppControllerBase.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/AppControllerBase.js       2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/AppControllerBase.js  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -24,8 +24,9 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> WI.DebuggableType = {
</span><ins>+    JavaScript: "javascript",
+    ServiceWorker: "service-worker",
</ins><span class="cx">     Web: "web",
</span><del>-    JavaScript: "javascript"
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> WI.NotImplementedError = class NotImplementedError extends Error
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersDebuggerManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js 2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/DebuggerManager.js    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -285,6 +285,8 @@
</span><span class="cx">             for (let script of targetData.scripts) {
</span><span class="cx">                 if (script.resource)
</span><span class="cx">                     continue;
</span><ins>+                if (isWebInspectorConsoleEvaluationScript(script.sourceURL))
+                    continue;
</ins><span class="cx">                 if (!WI.isDebugUIEnabled() && isWebKitInternalScript(script.sourceURL))
</span><span class="cx">                     continue;
</span><span class="cx">                 knownScripts.push(script);
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceControllersTimelineManagerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js 2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TimelineManager.js    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -73,6 +73,14 @@
</span><span class="cx">             return defaultTypes;
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        if (WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker) {
+            // FIXME: Support Network Timeline in ServiceWorker.
+            let defaultTypes = [WI.TimelineRecord.Type.Script];
+            if (WI.HeapAllocationsInstrument.supported())
+                defaultTypes.push(WI.TimelineRecord.Type.HeapAllocations);
+            return defaultTypes;
+        }
+
</ins><span class="cx">         let defaultTypes = [
</span><span class="cx">             WI.TimelineRecord.Type.Network,
</span><span class="cx">             WI.TimelineRecord.Type.Layout,
</span><span class="lines">@@ -88,7 +96,7 @@
</span><span class="cx">     static availableTimelineTypes()
</span><span class="cx">     {
</span><span class="cx">         let types = WI.TimelineManager.defaultTimelineTypes();
</span><del>-        if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript)
</del><ins>+        if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker)
</ins><span class="cx">             return types;
</span><span class="cx"> 
</span><span class="cx">         if (WI.MemoryInstrument.supported())
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceModelsTimelineRecordingjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/TimelineRecording.js       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx"> 
</span><span class="cx">     static sourceCodeTimelinesSupported()
</span><span class="cx">     {
</span><ins>+        // FIXME: Support Network Timeline in ServiceWorker.
</ins><span class="cx">         return WI.sharedApp.debuggableType === WI.DebuggableType.Web;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceProtocolMainTargetjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js 2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/MainTarget.js    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -38,10 +38,12 @@
</span><span class="cx">     get displayName()
</span><span class="cx">     {
</span><span class="cx">         switch (WI.sharedApp.debuggableType) {
</span><ins>+        case WI.DebuggableType.JavaScript:
+            return WI.UIString("JavaScript Context");
+        case WI.DebuggableType.ServiceWorker:
+            return WI.UIString("ServiceWorker");
</ins><span class="cx">         case WI.DebuggableType.Web:
</span><span class="cx">             return WI.UIString("Page");
</span><del>-        case WI.DebuggableType.JavaScript:
-            return WI.UIString("JavaScript Context");
</del><span class="cx">         default:
</span><span class="cx">             console.error("Unexpected debuggable type: ", WI.sharedApp.debuggableType);
</span><span class="cx">             return WI.UIString("Main");
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceTestTestAppControllerjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Test/TestAppController.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Test/TestAppController.js      2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/TestAppController.js 2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -25,11 +25,6 @@
</span><span class="cx"> 
</span><span class="cx"> WI.TestAppController = class TestAppController extends WI.AppControllerBase
</span><span class="cx"> {
</span><del>-    constructor()
-    {
-        super();
-    }
-
</del><span class="cx">     get hasExtraDomains() { return false; }
</span><span class="cx">     get debuggableType() { return WI.DebuggableType.Web; }
</span><span class="cx"> };
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDashboardContainerViewcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DashboardContainerView.css (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/DashboardContainerView.css       2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DashboardContainerView.css  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">     min-width: 350px;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-body.javascript .toolbar .dashboard-container {
</del><ins>+body:not(.web) .toolbar .dashboard-container {
</ins><span class="cx">     width: 25vw;
</span><span class="cx">     min-width: 175px;
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsDefaultDashboardViewcss"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.css (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.css 2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DefaultDashboardView.css    2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx">     display: none;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-body.javascript .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time) {
</del><ins>+body:not(.web) .toolbar .dashboard.default > :matches(.resourcesCount, .resourcesSize, .time) {
</ins><span class="cx">     display: none;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsResourceSidebarPaneljs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js  2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js     2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -70,12 +70,20 @@
</span><span class="cx">         this.contentTreeOutline.addEventListener(WI.TreeOutline.Event.SelectionDidChange, this._treeSelectionDidChange, this);
</span><span class="cx">         this.contentTreeOutline.includeSourceMapResourceChildren = true;
</span><span class="cx"> 
</span><del>-        if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript) {
</del><ins>+        if (ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel()) {
</ins><span class="cx">             this.contentTreeOutline.disclosureButtons = false;
</span><span class="cx">             WI.SourceCode.addEventListener(WI.SourceCode.Event.SourceMapAdded, () => { this.contentTreeOutline.disclosureButtons = true; }, this);
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    // Static
+
+    static shouldPlaceResourcesAtTopLevel()
+    {
+        return (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript && !WI.sharedApp.hasExtraDomains)
+            || WI.sharedApp.debuggableType === WI.DebuggableType.ServiceWorker;
+    }
+
</ins><span class="cx">     // Public
</span><span class="cx"> 
</span><span class="cx">     get minimumWidth()
</span><span class="lines">@@ -197,7 +205,7 @@
</span><span class="cx">         for (let script of WI.debuggerManager.knownNonResourceScripts) {
</span><span class="cx">             this._addScript(script);
</span><span class="cx"> 
</span><del>-            if (script.sourceMaps.length && WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript)
</del><ins>+            if (script.sourceMaps.length && ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel())
</ins><span class="cx">                 this.contentTreeOutline.disclosureButtons = true;
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="lines">@@ -326,7 +334,7 @@
</span><span class="cx"> 
</span><span class="cx">             parentFolderTreeElement = this._extensionScriptsFolderTreeElement;
</span><span class="cx">         } else {
</span><del>-            if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript && !WI.sharedApp.hasExtraDomains)
</del><ins>+            if (ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel())
</ins><span class="cx">                 insertIntoTopLevel = true;
</span><span class="cx">             else {
</span><span class="cx">                 if (!this._extraScriptsFolderTreeElement) {
</span><span class="lines">@@ -484,7 +492,7 @@
</span><span class="cx"> 
</span><span class="cx">     _extraDomainsActivated()
</span><span class="cx">     {
</span><del>-        if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript)
</del><ins>+        if (ResourceSidebarPanel.shouldPlaceResourcesAtTopLevel())
</ins><span class="cx">             this.contentTreeOutline.disclosureButtons = true;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebInspectorUIUserInterfaceViewsToolbarjs"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js       2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/Toolbar.js  2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -100,8 +100,8 @@
</span><span class="cx">         if (!this._leftSectionElement || !this._centerSectionElement || !this._rightSectionElement)
</span><span class="cx">             return;
</span><span class="cx"> 
</span><del>-        // Force collapsed style for JavaScript debuggables.
-        if (WI.sharedApp.debuggableType === WI.DebuggableType.JavaScript) {
</del><ins>+        // Force collapsed style for non-Web debuggables.
+        if (WI.sharedApp.debuggableType !== WI.DebuggableType.Web) {
</ins><span class="cx">             this.element.classList.add(WI.NavigationBar.CollapsedStyleClassName);
</span><span class="cx">             return;
</span><span class="cx">         }
</span></span></pre></div>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebKit/ChangeLog       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2017-11-02  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Make ServiceWorker a Remote Inspector debuggable target
+        https://bugs.webkit.org/show_bug.cgi?id=179043
+        <rdar://problem/34126008>
+
+        Reviewed by Brian Burg.
+
+        * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h:
+        * UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm:
+        (debuggableTypeString):
+        Provide a way to start a Remote Web Inspector frontend for a ServiceWorker target type.
+
</ins><span class="cx"> 2017-11-02  Ryan Haddad  <ryanhaddad@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, rolling out r224353.
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKRemoteWebInspectorViewControllerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h    2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.h       2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> 
</span><span class="cx"> typedef NS_ENUM(NSInteger, WKRemoteWebInspectorDebuggableType) {
</span><span class="cx">     WKRemoteWebInspectorDebuggableTypeJavaScript,
</span><ins>+    WKRemoteWebInspectorDebuggableTypeServiceWorker WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)),
</ins><span class="cx">     WKRemoteWebInspectorDebuggableTypeWeb,
</span><span class="cx"> } WK_API_AVAILABLE(macosx(10.12.3), ios(10.3));
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessAPICocoa_WKRemoteWebInspectorViewControllermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm (224367 => 224368)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm   2017-11-03 00:54:35 UTC (rev 224367)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKRemoteWebInspectorViewController.mm      2017-11-03 01:30:01 UTC (rev 224368)
</span><span class="lines">@@ -99,6 +99,8 @@
</span><span class="cx">     switch (debuggableType) {
</span><span class="cx">     case WKRemoteWebInspectorDebuggableTypeJavaScript:
</span><span class="cx">         return ASCIILiteral("javascript");
</span><ins>+    case WKRemoteWebInspectorDebuggableTypeServiceWorker:
+        return ASCIILiteral("service-worker");
</ins><span class="cx">     case WKRemoteWebInspectorDebuggableTypeWeb:
</span><span class="cx">         return ASCIILiteral("web");
</span><span class="cx">     }
</span></span></pre>
</div>
</div>

</body>
</html>