Web Inspector: ALTERNATE_DISPATCHERS Let the frontend know about extra agents
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Nov 2014 19:36:14 +0000 (19:36 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 3 Nov 2014 19:36:14 +0000 (19:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138236

Reviewed by Brian Burg.

Source/JavaScriptCore:

Inform the frontend about any extra domains the backend may have
above and beyond the default list of domains for the debuggable type.
This approach means there is almost no cost to normal debugging.
When a JSContext is debugged with extra agents, a message is sent
to the frontend letting it know which domains to then activate,
and perform any initialization work that may be required.

* inspector/InspectorAgentBase.h:
(Inspector::InspectorAgentBase::domainName):
* inspector/InspectorAgentRegistry.cpp:
(Inspector::InspectorAgentRegistry::appendExtraAgent):
* inspector/InspectorAgentRegistry.h:
* inspector/scripts/codegen/generator_templates.py:
Provide a way to get a list of just the extra domains.
To aggregate this list provide a different "append"
specifically for extra agents.

* inspector/JSGlobalObjectInspectorController.h:
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
(Inspector::JSGlobalObjectInspectorController::connectFrontend):
When a frontend connects, inform it of the extra domains.

* inspector/protocol/Inspector.json:
* inspector/agents/InspectorAgent.h:
* inspector/agents/InspectorAgent.cpp:
(Inspector::InspectorAgent::enable):
(Inspector::InspectorAgent::activateExtraDomains):
Send an event with the extra domains to activate.

Source/WebInspectorUI:

* UserInterface/Protocol/InspectorBackend.js:
(InspectorBackendClass.prototype.activateDomain):
* UserInterface/Protocol/InspectorObserver.js:
(WebInspector.InspectorObserver.prototype.activateExtraDomains):
* UserInterface/Base/Object.js:
* UserInterface/Base/Test.js:
* UserInterface/Base/Main.js:
(WebInspector.activateExtraDomains):
Default state is that there are no extra domains. When extra domains
are activated, some agents need to be re-initialized. Dispatch a
model event so views also know to re-initialize.

* UserInterface/Controllers/ApplicationCacheManager.js:
(WebInspector.ApplicationCacheManager.prototype._mainResourceDidChange):
* UserInterface/Controllers/DOMTreeManager.js:
Be more careful about direct agent use during main resource changes.
That can happen with a JSContext extended with a Page agent.

* UserInterface/Controllers/FrameResourceManager.js:
(WebInspector.FrameResourceManager):
(WebInspector.FrameResourceManager.prototype._mainFrameDidChange):
(WebInspector.FrameResourceManager.prototype._extraDomainsActivated):
* UserInterface/Controllers/StorageManager.js:
(WebInspector.StorageManager):
(WebInspector.StorageManager.prototype._databaseForIdentifier):
(WebInspector.StorageManager.prototype._extraDomainsActivated):
It is possible new window.FooAgent's are available. Perform expected
initialization re-checking if the agents are now available.

* UserInterface/Models/CSSCompletions.js:
Avoid re-initialization if we already did it. This should never
happen but this is just to be safe.

* UserInterface/Views/ResourceSidebarPanel.js:
(WebInspector.ResourceSidebarPanel):
(WebInspector.ResourceSidebarPanel.prototype._extraDomainsActivated):
Don't disallow expandable tree elements if this is a JSContext with
extra domains. If that JSContext has resources, we would have been
unable to see child resources.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175478 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InspectorAgentBase.h
Source/JavaScriptCore/inspector/InspectorAgentRegistry.cpp
Source/JavaScriptCore/inspector/InspectorAgentRegistry.h
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.h
Source/JavaScriptCore/inspector/agents/InspectorAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorAgent.h
Source/JavaScriptCore/inspector/protocol/Inspector.json
Source/JavaScriptCore/inspector/scripts/codegen/generate_objective_c.py
Source/JavaScriptCore/inspector/scripts/codegen/generator_templates.py
Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-async-attribute.json-result
Source/JavaScriptCore/inspector/scripts/tests/expected/commands-with-optional-call-return-parameters.json-result
Source/JavaScriptCore/inspector/scripts/tests/expected/domains-with-varying-command-sizes.json-result
Source/JavaScriptCore/inspector/scripts/tests/expected/generate-domains-with-feature-guards.json-result
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Base/Object.js
Source/WebInspectorUI/UserInterface/Base/Test.js
Source/WebInspectorUI/UserInterface/Controllers/ApplicationCacheManager.js
Source/WebInspectorUI/UserInterface/Controllers/DOMTreeManager.js
Source/WebInspectorUI/UserInterface/Controllers/FrameResourceManager.js
Source/WebInspectorUI/UserInterface/Controllers/StorageManager.js
Source/WebInspectorUI/UserInterface/Models/CSSCompletions.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js
Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js
Source/WebInspectorUI/UserInterface/Views/ResourceSidebarPanel.js

index 0dac27d..ebc36c5 100644 (file)
@@ -1,3 +1,40 @@
+2014-11-03  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: ALTERNATE_DISPATCHERS Let the frontend know about extra agents
+        https://bugs.webkit.org/show_bug.cgi?id=138236
+
+        Reviewed by Brian Burg.
+
+        Inform the frontend about any extra domains the backend may have
+        above and beyond the default list of domains for the debuggable type.
+        This approach means there is almost no cost to normal debugging.
+        When a JSContext is debugged with extra agents, a message is sent
+        to the frontend letting it know which domains to then activate,
+        and perform any initialization work that may be required.
+
+        * inspector/InspectorAgentBase.h:
+        (Inspector::InspectorAgentBase::domainName):
+        * inspector/InspectorAgentRegistry.cpp:
+        (Inspector::InspectorAgentRegistry::appendExtraAgent):
+        * inspector/InspectorAgentRegistry.h:
+        * inspector/scripts/codegen/generator_templates.py:
+        Provide a way to get a list of just the extra domains.
+        To aggregate this list provide a different "append"
+        specifically for extra agents.
+
+        * inspector/JSGlobalObjectInspectorController.h:
+        * inspector/JSGlobalObjectInspectorController.cpp:
+        (Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
+        (Inspector::JSGlobalObjectInspectorController::connectFrontend):
+        When a frontend connects, inform it of the extra domains.
+
+        * inspector/protocol/Inspector.json:
+        * inspector/agents/InspectorAgent.h:
+        * inspector/agents/InspectorAgent.cpp:
+        (Inspector::InspectorAgent::enable):
+        (Inspector::InspectorAgent::activateExtraDomains):
+        Send an event with the extra domains to activate.
+
 2014-11-01  Michael Saboff  <msaboff@apple.com>
 
         Add scope operand to op_resolve_scope
index f6b6c55..639d048 100644 (file)
@@ -43,6 +43,8 @@ class InspectorAgentBase {
 public:
     virtual ~InspectorAgentBase() { }
 
+    String domainName() const { return m_name; }
+
     virtual void didCreateFrontendAndBackend(InspectorFrontendChannel*, InspectorBackendDispatcher*) = 0;
     virtual void willDestroyFrontendAndBackend(InspectorDisconnectReason reason) = 0;
     virtual void discardAgent() { }
index 4124cfe..e438cf1 100644 (file)
@@ -42,6 +42,15 @@ void InspectorAgentRegistry::append(std::unique_ptr<InspectorAgentBase> agent)
     m_agents.append(WTF::move(agent));
 }
 
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+void InspectorAgentRegistry::appendExtraAgent(std::unique_ptr<InspectorAgentBase> agent)
+{
+    m_extraDomains.append(agent->domainName());
+
+    append(WTF::move(agent));
+}
+#endif
+
 void InspectorAgentRegistry::didCreateFrontendAndBackend(InspectorFrontendChannel* frontendChannel, InspectorBackendDispatcher* backendDispatcher)
 {
     for (size_t i = 0; i < m_agents.size(); i++)
index 17d65e7..8b7757f 100644 (file)
@@ -28,6 +28,7 @@
 #define InspectorAgentRegistry_h
 
 #include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
 
 namespace Inspector {
 
@@ -46,6 +47,11 @@ public:
     void willDestroyFrontendAndBackend(InspectorDisconnectReason reason);
     void discardAgents();
 
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    void appendExtraAgent(std::unique_ptr<InspectorAgentBase>);
+    Vector<String> extraDomains() const { return m_extraDomains; }
+#endif
+
 private:
     // These are declared here to avoid MSVC from trying to create default iplementations which would
     // involve generating a copy constructor and copy assignment operator for the Vector of std::unique_ptrs.
@@ -53,6 +59,9 @@ private:
     InspectorAgentRegistry& operator=(const InspectorAgentRegistry&) = delete;
 
     Vector<std::unique_ptr<InspectorAgentBase>> m_agents;
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    Vector<String> m_extraDomains;
+#endif
 };
 
 } // namespace Inspector
index 48d3fb9..77ae464 100644 (file)
@@ -68,17 +68,19 @@ JSGlobalObjectInspectorController::JSGlobalObjectInspectorController(JSGlobalObj
     , m_augmentingClient(nullptr)
 #endif
 {
+    auto inspectorAgent = std::make_unique<InspectorAgent>(*this);
     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(m_injectedScriptManager.get(), m_globalObject);
     auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(m_injectedScriptManager.get());
     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(m_injectedScriptManager.get(), m_globalObject, consoleAgent.get());
 
+    m_inspectorAgent = inspectorAgent.get();
     m_debuggerAgent = debuggerAgent.get();
     m_consoleAgent = consoleAgent.get();
     m_consoleClient = std::make_unique<JSGlobalObjectConsoleClient>(m_consoleAgent);
 
     runtimeAgent->setScriptDebugServer(&debuggerAgent->scriptDebugServer());
 
-    m_agents.append(std::make_unique<InspectorAgent>(*this));
+    m_agents.append(WTF::move(inspectorAgent));
     m_agents.append(WTF::move(runtimeAgent));
     m_agents.append(WTF::move(consoleAgent));
     m_agents.append(WTF::move(debuggerAgent));
@@ -111,6 +113,8 @@ void JSGlobalObjectInspectorController::connectFrontend(InspectorFrontendChannel
     m_agents.didCreateFrontendAndBackend(frontendChannel, m_inspectorBackendDispatcher.get());
 
 #if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    m_inspectorAgent->activateExtraDomains(m_agents.extraDomains());
+
     if (m_augmentingClient)
         m_augmentingClient->inspectorConnected();
 #endif
index 184c614..d6b8c02 100644 (file)
@@ -53,7 +53,7 @@ class JSValue;
 namespace Inspector {
 
 class InjectedScriptManager;
-class InspectorConsoleAgent;
+class InspectorAgent;
 class InspectorBackendDispatcher;
 class InspectorConsoleAgent;
 class InspectorDebuggerAgent;
@@ -110,6 +110,7 @@ private:
     JSC::JSGlobalObject& m_globalObject;
     std::unique_ptr<InjectedScriptManager> m_injectedScriptManager;
     std::unique_ptr<JSGlobalObjectConsoleClient> m_consoleClient;
+    InspectorAgent* m_inspectorAgent;
     InspectorConsoleAgent* m_consoleAgent;
     InspectorDebuggerAgent* m_debuggerAgent;
     InspectorAgentRegistry m_agents;
index 9f46f58..31d7f3c 100644 (file)
@@ -74,6 +74,11 @@ void InspectorAgent::enable(ErrorString&)
     if (m_pendingInspectData.first)
         inspect(m_pendingInspectData.first, m_pendingInspectData.second);
 
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    if (m_pendingExtraDomainsData)
+        m_frontendDispatcher->activateExtraDomains(m_pendingExtraDomainsData);
+#endif
+
     for (auto& testCommand : m_pendingEvaluateTestCommands) {
         if (!m_frontendDispatcher)
             break;
@@ -115,6 +120,23 @@ void InspectorAgent::evaluateForTestInFrontend(const String& script)
         m_pendingEvaluateTestCommands.append(script);
 }
 
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+void InspectorAgent::activateExtraDomains(const Vector<String>& extraDomains)
+{
+    if (extraDomains.isEmpty())
+        return;
+
+    RefPtr<Inspector::Protocol::Array<String>> domainNames = Inspector::Protocol::Array<String>::create();
+    for (auto domainName : extraDomains)
+        domainNames->addItem(domainName);
+
+    if (!m_enabled)
+        m_pendingExtraDomainsData = domainNames.release();
+    else
+        m_frontendDispatcher->activateExtraDomains(domainNames.release());
+}
+#endif
+
 } // namespace Inspector
 
 #endif // ENABLE(INSPECTOR)
index 1c13609..bc40327 100644 (file)
@@ -64,12 +64,19 @@ public:
     void inspect(PassRefPtr<Protocol::Runtime::RemoteObject> objectToInspect, PassRefPtr<InspectorObject> hints);
     void evaluateForTestInFrontend(const String& script);
 
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    void activateExtraDomains(const Vector<String>&);
+#endif
+
 private:
     InspectorEnvironment& m_environment;
     std::unique_ptr<InspectorInspectorFrontendDispatcher> m_frontendDispatcher;
     RefPtr<InspectorInspectorBackendDispatcher> m_backendDispatcher;
     Vector<String> m_pendingEvaluateTestCommands;
     std::pair<RefPtr<Protocol::Runtime::RemoteObject>, RefPtr<InspectorObject>> m_pendingInspectData;
+#if ENABLE(INSPECTOR_ALTERNATE_DISPATCHERS)
+    RefPtr<Inspector::Protocol::Array<String>> m_pendingExtraDomainsData;
+#endif
     bool m_enabled;
 };
 
index 05690c2..0420ebd 100644 (file)
             ]
         },
         {
+            "name": "activateExtraDomains",
+            "description": "Fired when the backend has alternate domains that need to be activated.",
+            "parameters": [
+                { "name": "domains", "type": "array", "items": { "type": "string" }, "description": "Domain names that need activation" }
+            ]
+        },
+        {
             "name": "targetCrashed",
             "description": "Fired when debugging target has crashed"
         }
index 0a80392..e520869 100755 (executable)
@@ -342,7 +342,7 @@ class ObjCGenerator:
         if category is ObjCTypeCategory.Array:
             protocol_type = ObjCGenerator.protocol_type_for_type(var_type.element_type)
             objc_class = ObjCGenerator.objc_class_for_type(var_type.element_type)
-            if protocol_type is 'Inspector::Protocol::Array<String>':
+            if protocol_type == 'Inspector::Protocol::Array<String>':
                 return 'inspectorStringArrayArray(%s)' % var_name
             if protocol_type is 'String' and objc_class is 'NSString':
                 return 'inspectorStringArray(%s)' % var_name
index fe8ed59..2561637 100755 (executable)
@@ -415,7 +415,7 @@ ${invocation}
 
     auto alternateDispatcher = std::make_unique<ObjCInspector${domainName}BackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<Inspector${domainName}BackendDispatcher, AlternateInspector${domainName}BackendDispatcher>>(ASCIILiteral("${domainName}"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<${objcPrefix}${domainName}DomainHandler>)${variableNamePrefix}Handler
index 4fbd1d1..783f2d9 100644 (file)
@@ -963,7 +963,7 @@ using namespace Inspector;
 
     auto alternateDispatcher = std::make_unique<ObjCInspectorDatabaseBackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<InspectorDatabaseBackendDispatcher, AlternateInspectorDatabaseBackendDispatcher>>(ASCIILiteral("Database"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<RWIProtocolDatabaseDomainHandler>)databaseHandler
index 4e9dd19..00f32f1 100644 (file)
@@ -852,7 +852,7 @@ using namespace Inspector;
 
     auto alternateDispatcher = std::make_unique<ObjCInspectorDatabaseBackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<InspectorDatabaseBackendDispatcher, AlternateInspectorDatabaseBackendDispatcher>>(ASCIILiteral("Database"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<RWIProtocolDatabaseDomainHandler>)databaseHandler
index 927d9e7..1bff693 100644 (file)
@@ -869,7 +869,7 @@ using namespace Inspector;
 
     auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork1BackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<InspectorNetwork1BackendDispatcher, AlternateInspectorNetwork1BackendDispatcher>>(ASCIILiteral("Network1"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<RWIProtocolNetwork1DomainHandler>)network1Handler
@@ -887,7 +887,7 @@ using namespace Inspector;
 
     auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork3BackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<InspectorNetwork3BackendDispatcher, AlternateInspectorNetwork3BackendDispatcher>>(ASCIILiteral("Network3"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<RWIProtocolNetwork3DomainHandler>)network3Handler
index c3509cf..ce023c4 100644 (file)
@@ -750,7 +750,7 @@ using namespace Inspector;
 
     auto alternateDispatcher = std::make_unique<ObjCInspectorNetwork1BackendDispatcher>(handler);
     auto alternateAgent = std::make_unique<AlternateDispatchableAgent<InspectorNetwork1BackendDispatcher, AlternateInspectorNetwork1BackendDispatcher>>(ASCIILiteral("Network1"), WTF::move(alternateDispatcher));
-    _controller->agentRegistry().append(WTF::move(alternateAgent));
+    _controller->agentRegistry().appendExtraAgent(WTF::move(alternateAgent));
 }
 
 - (id<RWIProtocolNetwork1DomainHandler>)network1Handler
index 8dd3026..97659fc 100644 (file)
@@ -1,3 +1,50 @@
+2014-11-03  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: ALTERNATE_DISPATCHERS Let the frontend know about extra agents
+        https://bugs.webkit.org/show_bug.cgi?id=138236
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/InspectorBackend.js:
+        (InspectorBackendClass.prototype.activateDomain):
+        * UserInterface/Protocol/InspectorObserver.js:
+        (WebInspector.InspectorObserver.prototype.activateExtraDomains):
+        * UserInterface/Base/Object.js:
+        * UserInterface/Base/Test.js:
+        * UserInterface/Base/Main.js:
+        (WebInspector.activateExtraDomains):
+        Default state is that there are no extra domains. When extra domains
+        are activated, some agents need to be re-initialized. Dispatch a
+        model event so views also know to re-initialize.
+
+        * UserInterface/Controllers/ApplicationCacheManager.js:
+        (WebInspector.ApplicationCacheManager.prototype._mainResourceDidChange):
+        * UserInterface/Controllers/DOMTreeManager.js:
+        Be more careful about direct agent use during main resource changes.
+        That can happen with a JSContext extended with a Page agent.
+
+        * UserInterface/Controllers/FrameResourceManager.js:
+        (WebInspector.FrameResourceManager):
+        (WebInspector.FrameResourceManager.prototype._mainFrameDidChange):
+        (WebInspector.FrameResourceManager.prototype._extraDomainsActivated):
+        * UserInterface/Controllers/StorageManager.js:
+        (WebInspector.StorageManager):
+        (WebInspector.StorageManager.prototype._databaseForIdentifier):
+        (WebInspector.StorageManager.prototype._extraDomainsActivated):
+        It is possible new window.FooAgent's are available. Perform expected
+        initialization re-checking if the agents are now available.
+
+        * UserInterface/Models/CSSCompletions.js:
+        Avoid re-initialization if we already did it. This should never
+        happen but this is just to be safe.
+
+        * UserInterface/Views/ResourceSidebarPanel.js:
+        (WebInspector.ResourceSidebarPanel):
+        (WebInspector.ResourceSidebarPanel.prototype._extraDomainsActivated):
+        Don't disallow expandable tree elements if this is a JSContext with
+        extra domains. If that JSContext has resources, we would have been
+        unable to see child resources.
+
 2014-10-30  Dana Burkart  <dburkart@apple.com>
 
         <rdar://problem/18821260> Prepare for the mysterious future
index 2b52a70..cc9f2c5 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.Notification = {
-    GlobalModifierKeysDidChange: "global-modifiers-did-change",
-    PageArchiveStarted: "page-archive-started",
-    PageArchiveEnded: "page-archive-ended"
-};
-
 WebInspector.ContentViewCookieType = {
     ApplicationCache: "application-cache",
     CookieStorage: "cookie-storage",
@@ -53,6 +47,7 @@ WebInspector.loaded = function()
     this._initializeWebSocketIfNeeded();
 
     this.debuggableType = InspectorFrontendHost.debuggableType() === "web" ? WebInspector.DebuggableType.Web : WebInspector.DebuggableType.JavaScript;
+    this.hasExtraDomains = false;
 
     // Register observers for events from the InspectorBackend.
     if (InspectorBackend.registerInspectorDispatcher)
@@ -359,6 +354,22 @@ WebInspector.contentLoaded = function()
     this._contentLoaded = true;
 }
 
+WebInspector.activateExtraDomains = function(domains)
+{
+    console.assert(!this.hasExtraDomains);
+    this.hasExtraDomains = true;
+
+    for (var domain of domains) {
+        var agent = InspectorBackend.activateDomain(domain);
+        if (agent.enable)
+            agent.enable();
+    }
+
+    this.notifications.dispatchEventToListeners(WebInspector.Notification.ExtraDomainsActivated);
+
+    WebInspector.CSSCompletions.requestCSSNameCompletions();
+}
+
 WebInspector.sidebarPanelForCurrentContentView = function()
 {
     var currentContentView = this.contentBrowser.currentContentView;
index 9e51c3c..62b7dd3 100644 (file)
@@ -189,3 +189,10 @@ WebInspector.Event.prototype = {
 };
 
 WebInspector.notifications = new WebInspector.Object;
+
+WebInspector.Notification = {
+    GlobalModifierKeysDidChange: "global-modifiers-did-change",
+    PageArchiveStarted: "page-archive-started",
+    PageArchiveEnded: "page-archive-ended",
+    ExtraDomainsActivated: "extra-domains-activated",
+};
index 380ea67..a548ed2 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+WebInspector.DebuggableType = {
+    Web: "web",
+    JavaScript: "javascript"
+};
+
 WebInspector.loaded = function()
 {
+    this.debuggableType = WebInspector.DebuggableType.Web;
+    this.hasExtraDomains = false;
+
     // Register observers for events from the InspectorBackend.
     // The initialization order should match the same in Main.js.
     InspectorBackend.registerInspectorDispatcher(new WebInspector.InspectorObserver);
index 523d851..88dc9cb 100644 (file)
@@ -119,7 +119,8 @@ WebInspector.ApplicationCacheManager.prototype = {
             return;
         }
 
-        ApplicationCacheAgent.getManifestForFrame(event.target.id, this._manifestForFrameLoaded.bind(this, event.target.id));
+        if (window.ApplicationCacheAgent)
+            ApplicationCacheAgent.getManifestForFrame(event.target.id, this._manifestForFrameLoaded.bind(this, event.target.id));
     },
 
     _childFrameWasRemoved: function(event)
index 5897797..08ed48e 100644 (file)
@@ -471,7 +471,7 @@ WebInspector.DOMTreeManager.prototype = {
             this.dispatchEventToListeners(WebInspector.DOMTreeManager.Event.ContentFlowListWasUpdated, {documentNodeIdentifier: documentNodeIdentifier, flows: contentFlows});
         }
 
-        if (CSSAgent.getNamedFlowCollection)
+        if (window.CSSAgent && CSSAgent.getNamedFlowCollection)
             CSSAgent.getNamedFlowCollection(documentNodeIdentifier, onNamedFlowCollectionAvailable.bind(this));
     },
 
index 8f3fa1d..ecb797a 100644 (file)
@@ -32,6 +32,8 @@ WebInspector.FrameResourceManager = function()
     if (window.NetworkAgent)
         NetworkAgent.enable();
 
+    WebInspector.notifications.addEventListener(WebInspector.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this);
+
     this.initialize();
 };
 
@@ -583,6 +585,12 @@ WebInspector.FrameResourceManager.prototype = {
         if (this._mainFrame)
             this._mainFrame.markAsMainFrame();
         this.dispatchEventToListeners(WebInspector.FrameResourceManager.Event.MainFrameDidChange, {oldMainFrame: oldMainFrame});
+    },
+
+    _extraDomainsActivated: function()
+    {
+        if (window.PageAgent)
+            PageAgent.getResourceTree(this._processMainFrameResourceTreePayload.bind(this));
     }
 };
 
index bae92d7..504634c 100644 (file)
@@ -37,6 +37,8 @@ WebInspector.StorageManager = function()
 
     WebInspector.Frame.addEventListener(WebInspector.Frame.Event.MainResourceDidChange, this._mainResourceDidChange, this);
 
+    WebInspector.notifications.addEventListener(WebInspector.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this);
+
     // COMPATIBILITY (iOS 6): DOMStorage was discovered via a DOMStorageObserver event. Now DOM Storage
     // is added whenever a new securityOrigin is discovered. Check for DOMStorageAgent.getDOMStorageItems,
     // which was renamed at the same time the change to start using securityOrigin was made.
@@ -304,5 +306,11 @@ WebInspector.StorageManager.prototype = {
         }
 
         return null;
+    },
+
+    _extraDomainsActivated: function()
+    {
+        if (window.DOMStorageAgent && DOMStorageAgent.getDOMStorageItems)
+            WebInspector.Frame.addEventListener(WebInspector.Frame.Event.SecurityOriginDidChange, this._securityOriginDidChange, this);
     }
 };
index 3fe7c3f..85924ec 100644 (file)
@@ -76,6 +76,9 @@ WebInspector.CSSCompletions.cssNameCompletions = null;
 
 WebInspector.CSSCompletions.requestCSSNameCompletions = function()
 {
+    if (WebInspector.CSSCompletions.cssNameCompletions)
+        return;
+
     function propertyNamesCallback(error, names)
     {
         if (error)
index 52b6dbd..18690ea 100644 (file)
@@ -101,8 +101,13 @@ InspectorBackendClass.prototype = {
 
     activateDomain: function(domainName, activationDebuggableType)
     {
-        if (!activationDebuggableType || InspectorFrontendHost.debuggableType() === activationDebuggableType)
-            this._agents[domainName].activate();
+        if (!activationDebuggableType || InspectorFrontendHost.debuggableType() === activationDebuggableType) {
+            var agent = this._agents[domainName];
+            agent.activate();
+            return agent;
+        }
+
+        return null;
     },
 
     // Private
index 0e55e7f..7d54af4 100644 (file)
@@ -65,6 +65,11 @@ WebInspector.InspectorObserver.prototype = {
     detached: function(reason)
     {
         // FIXME: Not implemented.
+    },
+
+    activateExtraDomains: function(domains)
+    {
+        WebInspector.activateExtraDomains(domains);
     }
 };
 
index b43c02c..6bbc0d6 100644 (file)
@@ -83,6 +83,8 @@ WebInspector.ResourceSidebarPanel = function() {
     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptAdded, this._scriptWasAdded, this);
     WebInspector.debuggerManager.addEventListener(WebInspector.DebuggerManager.Event.ScriptsCleared, this._scriptsCleared, this);
 
+    WebInspector.notifications.addEventListener(WebInspector.Notification.ExtraDomainsActivated, this._extraDomainsActivated, this);
+
     this._resourcesContentTreeOutline = this.contentTreeOutline;
     this._searchContentTreeOutline = this.createContentTreeOutline();
 
@@ -623,7 +625,7 @@ WebInspector.ResourceSidebarPanel.prototype = {
                 this._extensionScriptsFolderTreeElement = new WebInspector.FolderTreeElement(WebInspector.UIString("Extension Scripts"));
             var parentFolderTreeElement = this._extensionScriptsFolderTreeElement;
         } else {
-            if (WebInspector.debuggableType === WebInspector.DebuggableType.JavaScript)
+            if (WebInspector.debuggableType === WebInspector.DebuggableType.JavaScript && !WebInspector.hasExtraDomains)
                 insertIntoTopLevel = true;
             else {
                 if (!this._extraScriptsFolderTreeElement)
@@ -864,6 +866,12 @@ WebInspector.ResourceSidebarPanel.prototype = {
         this._cookieStorageRootTreeElement = null;
         this._applicationCacheRootTreeElement = null;
         this._applicationCacheURLTreeElementMap = {};
+    },
+
+    _extraDomainsActivated: function()
+    {
+        if (WebInspector.debuggableType === WebInspector.DebuggableType.JavaScript)
+            this._resourcesContentTreeOutline.element.classList.remove(WebInspector.NavigationSidebarPanel.HideDisclosureButtonsStyleClassName);
     }
 };