Web Inspector: Move InspectorDebuggerAgent into JavaScriptCore
https://bugs.webkit.org/show_bug.cgi?id=127629
Rubber-stamped by Sam Weinig.
Source/JavaScriptCore:
* CMakeLists.txt:
* GNUmakefile.list.am:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj:
* JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters:
* JavaScriptCore.xcodeproj/project.pbxproj:
- Add new files to the build.
- Also, since non REMOTE_INSPECTOR ports cannot yet connect to a
JSGlobalObject for inspection remove those files as they don't
need to be built.
* inspector/EventLoop.cpp: Added.
(Inspector::EventLoop::cycle):
* inspector/EventLoop.h: Added.
(Inspector::EventLoop::EventLoop):
(Inspector::EventLoop::ended):
Add a JavaScriptCore version of EventLoop. This is currently only
used by the Mac port for JSGlobalObject remote inspection. Keep
the WebCore/platform version alive because for the Mac port it does
slightly different things involving AppKit.
* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
Create DebuggerAgent and hook up ScriptDebugServer where needed.
* inspector/JSGlobalObjectScriptDebugServer.cpp: Added.
(Inspector::JSGlobalObjectScriptDebugServer::JSGlobalObjectScriptDebugServer):
(Inspector::JSGlobalObjectScriptDebugServer::addListener):
(Inspector::JSGlobalObjectScriptDebugServer::removeListener):
(Inspector::JSGlobalObjectScriptDebugServer::recompileAllJSFunctions):
(Inspector::JSGlobalObjectScriptDebugServer::runEventLoopWhilePaused):
* inspector/JSGlobalObjectScriptDebugServer.h: Added.
Simple implementation of ScriptDebugServer with a JSGlobalObject.
* inspector/agents/InspectorDebuggerAgent.cpp: Renamed from Source/WebCore/inspector/InspectorDebuggerAgent.cpp.
* inspector/agents/InspectorDebuggerAgent.h: Renamed from Source/WebCore/inspector/InspectorDebuggerAgent.h.
Copied from WebCore. A few methods need to be made virtual so that Web implementations
can override and extend the funcitonality. E.g. sourceMapURLForScript and enable/disable.
* inspector/agents/JSGlobalObjectDebuggerAgent.cpp: Added.
* inspector/agents/JSGlobalObjectDebuggerAgent.h: Added.
(Inspector::JSGlobalObjectDebuggerAgent::JSGlobalObjectDebuggerAgent):
(Inspector::JSGlobalObjectDebuggerAgent::startListeningScriptDebugServer):
(Inspector::JSGlobalObjectDebuggerAgent::stopListeningScriptDebugServer):
(Inspector::JSGlobalObjectDebuggerAgent::injectedScriptForEval):
Simple implementation of DebuggerAGent with a JSGlobalObject.
Source/WebCore:
Test: inspector-protocol/debugger/pause-on-assert.html
* CMakeLists.txt:
* ForwardingHeaders/inspector/agents/InspectorDebuggerAgent.h: Added.
* GNUmakefile.list.am:
* WebCore.vcxproj/WebCore.vcxproj:
* WebCore.vcxproj/WebCore.vcxproj.filters:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
- Remove InspectorDebuggerAgent.
- Add WebDebuggerAgent (shared between Page and Worker).
* inspector/WebDebuggerAgent.h: Added.
(WebCore::WebDebuggerAgent::~WebDebuggerAgent):
* inspector/WebDebuggerAgent.cpp: Added.
(WebCore::WebDebuggerAgent::WebDebuggerAgent):
(WebCore::WebDebuggerAgent::enable):
(WebCore::WebDebuggerAgent::disable):
Shared code for Page and Worker debugger agents.
Instrumenting agents is a concept in WebCore only,
and the Debugger agent is only in the instrumenting
agents list when it is enabled and removed when disabled.
* inspector/InstrumentingAgents.h:
(WebCore::InstrumentingAgents::inspectorDebuggerAgent):
(WebCore::InstrumentingAgents::setInspectorDebuggerAgent):
* inspector/InspectorDOMDebuggerAgent.cpp:
* inspector/InspectorDOMDebuggerAgent.h:
Update namespace for debugger agent.
* inspector/InspectorInstrumentation.cpp:
(WebCore::isConsoleAssertMessage):
(WebCore::InspectorInstrumentation::addMessageToConsoleImpl):
DebuggerAgent in JavaScriptCore does not yet know about console
types. So temporarily handle it here. We need to give JavaScriptCore
some concept of Console messages and types.
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::PageDebuggerAgent):
(WebCore::PageDebuggerAgent::enable):
(WebCore::PageDebuggerAgent::disable):
(WebCore::PageDebuggerAgent::sourceMapURLForScript):
(WebCore::PageDebuggerAgent::injectedScriptForEval):
* inspector/PageDebuggerAgent.h:
* inspector/WorkerDebuggerAgent.cpp:
(WebCore::WorkerDebuggerAgent::WorkerDebuggerAgent):
(WebCore::WorkerDebuggerAgent::injectedScriptForEval):
* inspector/WorkerDebuggerAgent.h:
Modernize the Page and Worker debugger agents.
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/InspectorController.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
New constructors for the debugger agents.
LayoutTests:
Add a test that we pause in the debugger for console.assert failures
when the DebuggerAgent is enabled.
* inspector-protocol/debugger/pause-on-assert-expected.txt: Added.
* inspector-protocol/debugger/pause-on-assert.html: Added.
* inspector-protocol/debugger/resources/assert.js: Added.
(assertTrue):
(assertFalse):
(assertCondition):
(assertConditionWithMessage):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162799 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h
new file mode 100644
index 0000000..2f51aa09
--- /dev/null
+++ b/Source/JavaScriptCore/inspector/JSGlobalObjectScriptDebugServer.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#ifndef JSGlobalObjectScriptDebugServer_h
+#define JSGlobalObjectScriptDebugServer_h
+
+#if ENABLE(INSPECTOR)
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include "ScriptDebugServer.h"
+#include <wtf/Forward.h>
+
+namespace Inspector {
+
+class JSGlobalObjectScriptDebugServer final : public ScriptDebugServer {
+ WTF_MAKE_NONCOPYABLE(JSGlobalObjectScriptDebugServer);
+public:
+ JSGlobalObjectScriptDebugServer(JSC::JSGlobalObject&);
+ virtual ~JSGlobalObjectScriptDebugServer() { }
+
+ void addListener(ScriptDebugListener*);
+ void removeListener(ScriptDebugListener*, bool isBeingDestroyed);
+
+ JSC::JSGlobalObject& globalObject() const { return m_globalObject; }
+
+ virtual void recompileAllJSFunctions() override;
+
+private:
+ virtual ListenerSet* getListenersForGlobalObject(JSC::JSGlobalObject*) override { return &m_listeners; }
+ virtual void didPause(JSC::JSGlobalObject*) override { }
+ virtual void didContinue(JSC::JSGlobalObject*) override { }
+ virtual void runEventLoopWhilePaused() override;
+ virtual bool isContentScript(JSC::ExecState*) const override { return false; }
+
+ // FIXME: JavaScript inspection has no Console yet.
+ virtual void reportException(JSC::ExecState*, JSC::JSValue) const override { }
+
+ ListenerSet m_listeners;
+ JSC::JSGlobalObject& m_globalObject;
+};
+
+} // namespace Inspector
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER)
+#endif // ENABLE(INSPECTOR)
+
+#endif // JSGlobalObjectScriptDebugServer_h