Web Inspector: Include ConsoleAgent in Workers - real console.log support
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2016 22:19:33 +0000 (22:19 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Oct 2016 22:19:33 +0000 (22:19 +0000)
commit3c22c8e87eeb520e31dde015c2781793e4262694
tree86407d262dcdfa50295a0c19e817a1c21f73f59b
parent406882fb03ded3df598fae1fd7119ca65f701b48
Web Inspector: Include ConsoleAgent in Workers - real console.log support
https://bugs.webkit.org/show_bug.cgi?id=163844
<rdar://problem/28903328>

Reviewed by Brian Burg.

LayoutTests/imported/w3c:

* web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt:
* web-platform-tests/streams/readable-streams/garbage-collection.https-expected.txt:

Source/JavaScriptCore:

* inspector/protocol/Worker.json:

Source/WebCore:

Test: inspector/worker/console-basic.html

This introduces a real ConsoleAgent in the Worker InspectorController.
We no longer need to pass partial ConsoleMessage objects to be logged
through the Page, we can just send the full ConsoleMessages to a
frontend once it connects to the Worker.

In order to guarantee that the Worker InspectorController is properly
all Workers will start paused if there is an Inspector attached to
the Page. The frontend _must_ call the new Worker.initialized method
after sending its setup commands to the Worker. This ensures we get
handle all initialization commands (like Agent.enable(), and
setting state like breakpoints) before any script executes in the
Worker. This mirrors the Inspector.initialized method that does the
same thing for JSContext auto-attach of the Main target.

In the backend, the wait until initialized state is just running
the WorkerThread's RunLoop in a special debugger mode to only process
debugger commands until we are ready. This will effectively be
the same as pausing so it is generalized into WorkerThread.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* inspector/InspectorAllInOne.cpp:
New files.

* inspector/InspectorWorkerAgent.cpp:
(WebCore::InspectorWorkerAgent::initialized):
(WebCore::InspectorWorkerAgent::shouldWaitForDebuggerOnStart):
* inspector/InspectorWorkerAgent.h:
Add the new initialized method. This just uses the proxy to send
a message to be handled on the Worker Thread and unpause.

* inspector/WorkerConsoleAgent.cpp:
(WebCore::WorkerConsoleAgent::WorkerConsoleAgent):
(WebCore::WorkerConsoleAgent::addInspectedNode):
* inspector/WorkerConsoleAgent.h:
* inspector/WorkerInspectorController.cpp:
(WebCore::WorkerInspectorController::WorkerInspectorController):
Add a ConsoleAgent to WorkerInspectorController.

* workers/WorkerInspectorProxy.h:
* workers/WorkerInspectorProxy.cpp:
(WebCore::WorkerInspectorProxy::workerStartMode):
(WebCore::WorkerInspectorProxy::resumeWorkerIfPaused):
(WebCore::WorkerInspectorProxy::connectToWorkerInspector):
(WebCore::WorkerInspectorProxy::disconnectFromWorkerInspector):
(WebCore::WorkerInspectorProxy::sendMessageToWorkerInspector):
Use the debugger mode when sending messages to the WorkerThread.

* workers/Worker.cpp:
(WebCore::Worker::notifyFinished):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerGlobalScope):
(WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject): Deleted.
* workers/WorkerMessagingProxy.h:
* workers/WorkerReportingProxy.h:
* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::addConsoleMessage):
(WebCore::WorkerGlobalScope::addMessage):
* workers/WorkerGlobalScope.h:
* workers/WorkerGlobalScopeProxy.h:
Remove legacy partial console support.

* workers/WorkerRunLoop.h:
* workers/WorkerRunLoop.cpp:
(WebCore::WorkerRunLoop::debuggerMode):
* workers/WorkerThread.h:
* workers/WorkerThread.cpp:
(WebCore::WorkerThread::workerThread):
(WebCore::WorkerThread::startRunningDebuggerTasks):
(WebCore::WorkerThread::stopRunningDebuggerTasks):
General code for spinning the WorkerThread and only processing debugger
(Inspector) commands. Use this when starting the thread to ensure the
frontend initializes the Worker's Agents before any JavaScript executes.

* page/PageConsoleClient.cpp:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::count):
(WebCore::WorkerConsoleClient::time):
(WebCore::WorkerConsoleClient::timeEnd):
* inspector/InspectorConsoleInstrumentation.h: Removed.
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::startConsoleTimingImpl):
(WebCore::InspectorInstrumentation::stopConsoleTimingImpl):
(WebCore::InspectorInstrumentation::shouldWaitForDebuggerOnStartImpl):
* inspector/InspectorInstrumentation.h:
(WebCore::InspectorInstrumentation::shouldWaitForDebuggerOnStart):
(WebCore::InspectorInstrumentation::addMessageToConsole):
(WebCore::InspectorInstrumentation::consoleCount):
(WebCore::InspectorInstrumentation::takeHeapSnapshot):
(WebCore::InspectorInstrumentation::startConsoleTiming):
(WebCore::InspectorInstrumentation::stopConsoleTiming):
(WebCore::InspectorInstrumentation::consoleTimeStamp):
(WebCore::InspectorInstrumentation::startProfiling):
(WebCore::InspectorInstrumentation::stopProfiling):
Implement a few more basic console APIs that required ConsoleAgent.

Source/WebInspectorUI:

* UserInterface/Protocol/Target.js:
(WebInspector.Target.prototype.get ConsoleAgent):
(WebInspector.Target.prototype._initializeNonMainTarget):
* UserInterface/Protocol/Connection.js:
(InspectorBackend.WorkerConnection):
Add ConsoleAgent.

* UserInterface/Controllers/LogManager.js:
(WebInspector.LogManager.prototype.messageWasAdded):
(WebInspector.LogManager.prototype.requestClearMessages):
Handle ConsoleAgent calls with multiple targets.

* UserInterface/Protocol/ConsoleObserver.js:
(WebInspector.ConsoleObserver.prototype.messageAdded):
Dispatch with the target in case we create Model objects.

* UserInterface/Controllers/WorkerManager.js:
(WebInspector.WorkerManager.prototype.workerCreated):
The frontend must now call "initialized" on Workers after
sending our setup messages (enable, set breakpoints, etc).

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.prototype.get target):
Expose an accessor for tests.

* UserInterface/Protocol/LoggingProtocolTracer.js:
(WebInspector.LoggingProtocolTracer.prototype._processEntry):
Actually output the Exception, useful when debugging failures in tests.

LayoutTests:

* inspector/console/messageAdded-from-worker-expected.txt: Removed.
* inspector/console/messageAdded-from-worker.html: Removed.
* inspector/console/resources/worker-console-log.js: Removed.
Remove the old partial console in Worker test.

* inspector/worker/console-basic-expected.txt: Added.
* inspector/worker/console-basic.html: Added.
* inspector/worker/resources/worker-console.js: Added.
New console in Worker test.

* inspector/worker/worker-create-and-terminate.html:
The frontend must call initialize on Workers, otherwise they
are paused forever.

* http/tests/security/contentSecurityPolicy/worker-blob-inherits-csp-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-blob-inherits-csp-importScripts-block-aborts-all-subsequent-imports-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-connect-src-blocked-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-csp-blocks-xhr-redirect-cross-origin-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-importscripts-blocked-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-multiple-csp-headers-expected.txt:
* http/tests/security/contentSecurityPolicy/worker-set-timeout-blocked-expected.txt:
* http/tests/websocket/tests/hybi/workers/close-expected.txt:
* http/tests/xmlhttprequest/workers/access-control-basic-get-fail-non-simple-expected.txt:
* security/contentSecurityPolicy/worker-inherits-blocks-xhr-expected.txt:
Rebaseline. We no longer send Worker console messages through the Page, and likewise
we don't send them to the WebKit client, so they will no longer appear in test output.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208010 268f45cc-cd09-0410-ab3c-d52691b4dbfc
62 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/security/contentSecurityPolicy/worker-blob-inherits-csp-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-blob-inherits-csp-importScripts-block-aborts-all-subsequent-imports-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-connect-src-blocked-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-csp-blocks-xhr-redirect-cross-origin-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-importscripts-blocked-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-multiple-csp-headers-expected.txt
LayoutTests/http/tests/security/contentSecurityPolicy/worker-set-timeout-blocked-expected.txt
LayoutTests/http/tests/websocket/tests/hybi/workers/close-expected.txt
LayoutTests/http/tests/xmlhttprequest/workers/access-control-basic-get-fail-non-simple-expected.txt
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/fetch/api/policies/csp-blocked-worker-expected.txt
LayoutTests/imported/w3c/web-platform-tests/streams/readable-streams/garbage-collection.https-expected.txt
LayoutTests/inspector/console/messageAdded-from-worker-expected.txt [deleted file]
LayoutTests/inspector/console/messageAdded-from-worker.html [deleted file]
LayoutTests/inspector/console/resources/worker-console-log.js [deleted file]
LayoutTests/inspector/worker/console-basic-expected.txt [new file with mode: 0644]
LayoutTests/inspector/worker/console-basic.html [new file with mode: 0644]
LayoutTests/inspector/worker/resources/worker-console.js [new file with mode: 0644]
LayoutTests/inspector/worker/worker-create-and-terminate.html
LayoutTests/security/contentSecurityPolicy/worker-inherits-blocks-xhr-expected.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Worker.json
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/InspectorAllInOne.cpp
Source/WebCore/inspector/InspectorConsoleInstrumentation.h [deleted file]
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/InspectorWorkerAgent.cpp
Source/WebCore/inspector/InspectorWorkerAgent.h
Source/WebCore/inspector/WorkerConsoleAgent.cpp [new file with mode: 0644]
Source/WebCore/inspector/WorkerConsoleAgent.h [new file with mode: 0644]
Source/WebCore/inspector/WorkerInspectorController.cpp
Source/WebCore/page/PageConsoleClient.cpp
Source/WebCore/workers/Worker.cpp
Source/WebCore/workers/WorkerConsoleClient.cpp
Source/WebCore/workers/WorkerGlobalScope.cpp
Source/WebCore/workers/WorkerGlobalScope.h
Source/WebCore/workers/WorkerGlobalScopeProxy.h
Source/WebCore/workers/WorkerInspectorProxy.cpp
Source/WebCore/workers/WorkerInspectorProxy.h
Source/WebCore/workers/WorkerMessagingProxy.cpp
Source/WebCore/workers/WorkerMessagingProxy.h
Source/WebCore/workers/WorkerReportingProxy.h
Source/WebCore/workers/WorkerRunLoop.cpp
Source/WebCore/workers/WorkerRunLoop.h
Source/WebCore/workers/WorkerThread.cpp
Source/WebCore/workers/WorkerThread.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Controllers/JavaScriptLogViewController.js
Source/WebInspectorUI/UserInterface/Controllers/LogManager.js
Source/WebInspectorUI/UserInterface/Controllers/WorkerManager.js
Source/WebInspectorUI/UserInterface/Models/ConsoleCommandResultMessage.js
Source/WebInspectorUI/UserInterface/Models/ConsoleMessage.js
Source/WebInspectorUI/UserInterface/Protocol/Connection.js
Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js
Source/WebInspectorUI/UserInterface/Protocol/LoggingProtocolTracer.js
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
Source/WebInspectorUI/UserInterface/Protocol/Target.js
Source/WebInspectorUI/UserInterface/Views/ConsoleMessageView.js