Diff
Modified: trunk/LayoutTests/ChangeLog (196593 => 196594)
--- trunk/LayoutTests/ChangeLog 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/LayoutTests/ChangeLog 2016-02-15 21:23:23 UTC (rev 196594)
@@ -1,3 +1,14 @@
+2016-02-15 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web Workers have no access to console for debugging
+ https://bugs.webkit.org/show_bug.cgi?id=26237
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/console/messageAdded-from-worker-expected.txt: Added.
+ * inspector/console/messageAdded-from-worker.html: Added.
+ * inspector/console/resources/worker-console-log.js: Added.
+
2016-02-15 Timothy Hatcher <[email protected]>
Web Inspector: CSS variables are not formatted correctly
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (196593 => 196594)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2016-02-15 21:23:23 UTC (rev 196594)
@@ -1,3 +1,13 @@
+2016-02-15 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web Workers have no access to console for debugging
+ https://bugs.webkit.org/show_bug.cgi?id=26237
+
+ Reviewed by Timothy Hatcher.
+
+ * web-platform-tests/streams-api/readable-streams/garbage-collection-expected.txt:
+ Update test results for a console.warn message that the test produces from a Worker.
+
2016-02-14 Chris Dumez <[email protected]>
Window and WorkerGlobalScope should inherit EventTarget
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams-api/readable-streams/garbage-collection-expected.txt (196593 => 196594)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams-api/readable-streams/garbage-collection-expected.txt 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams-api/readable-streams/garbage-collection-expected.txt 2016-02-15 21:23:23 UTC (rev 196594)
@@ -1,3 +1,7 @@
+CONSOLE MESSAGE: line 37: Tests are running without the ability to do manual garbage collection. They will still work, but coverage will be suboptimal.
+CONSOLE MESSAGE: line 37: Tests are running without the ability to do manual garbage collection. They will still work, but coverage will be suboptimal.
+CONSOLE MESSAGE: line 37: Tests are running without the ability to do manual garbage collection. They will still work, but coverage will be suboptimal.
+CONSOLE MESSAGE: line 37: Tests are running without the ability to do manual garbage collection. They will still work, but coverage will be suboptimal.
PASS ReadableStreamController methods should continue working properly when scripts lose their reference to the readable stream
PASS ReadableStream closed promise should fulfill even if the stream and reader JS references are lost
Added: trunk/LayoutTests/inspector/console/messageAdded-from-worker-expected.txt (0 => 196594)
--- trunk/LayoutTests/inspector/console/messageAdded-from-worker-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/console/messageAdded-from-worker-expected.txt 2016-02-15 21:23:23 UTC (rev 196594)
@@ -0,0 +1,10 @@
+CONSOLE MESSAGE: line 1: WORKER STARTED
+CONSOLE MESSAGE: line 7: WORKER RECEIVED MESSAGE
+Console messages should be received from console logs in a Worker.
+
+
+== Running test suite: Console.messageAdded.worker
+-- Running test case: TriggerConsoleMessagesInWorker
+PASS: MessageAdded event should fire for started log.
+PASS: MessageAdded event should fire for received message log.
+
Added: trunk/LayoutTests/inspector/console/messageAdded-from-worker.html (0 => 196594)
--- trunk/LayoutTests/inspector/console/messageAdded-from-worker.html (rev 0)
+++ trunk/LayoutTests/inspector/console/messageAdded-from-worker.html 2016-02-15 21:23:23 UTC (rev 196594)
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerWorkerConsoleLog() {
+ let worker = new Worker("resources/worker-console-log.js");
+ worker.postMessage("log");
+}
+
+function test()
+{
+ let suite = InspectorTest.createAsyncSuite("Console.messageAdded.worker");
+
+ suite.addTestCase({
+ name: "TriggerConsoleMessagesInWorker",
+ description: "Triggered console messages in a Worker should be received.",
+ test: (resolve, reject) => {
+ InspectorTest.evaluateInPage("triggerWorkerConsoleLog()");
+ WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+ InspectorTest.expectThat(event.data.message.messageText === "WORKER STARTED", "MessageAdded event should fire for started log.");
+ WebInspector.logManager.singleFireEventListener(WebInspector.LogManager.Event.MessageAdded, (event) => {
+ InspectorTest.expectThat(event.data.message.messageText === "WORKER RECEIVED MESSAGE", "MessageAdded event should fire for received message log.");
+ resolve();
+ });
+ });
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Console messages should be received from console logs in a Worker.</p>
+</body>
+</html>
Added: trunk/LayoutTests/inspector/console/resources/worker-console-log.js (0 => 196594)
--- trunk/LayoutTests/inspector/console/resources/worker-console-log.js (rev 0)
+++ trunk/LayoutTests/inspector/console/resources/worker-console-log.js 2016-02-15 21:23:23 UTC (rev 196594)
@@ -0,0 +1,9 @@
+console.log("WORKER STARTED");
+
+self.addEventListener("message", (event) => {
+ // FIXME: <https://webkit.org/b/154213> Web Inspector: Improve support for console logging within workers
+ // Currently the arguments to the console.log are lost when crossing thread boundaries. This should be
+ // addressed when adding better worker debugging in general.
+ console.log("WORKER RECEIVED MESSAGE", "argument");
+});
+
Modified: trunk/Source/_javascript_Core/ChangeLog (196593 => 196594)
--- trunk/Source/_javascript_Core/ChangeLog 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-02-15 21:23:23 UTC (rev 196594)
@@ -1,3 +1,13 @@
+2016-02-15 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web Workers have no access to console for debugging
+ https://bugs.webkit.org/show_bug.cgi?id=26237
+
+ Reviewed by Timothy Hatcher.
+
+ * inspector/ConsoleMessage.h:
+ Add accessor for MessageLevel.
+
2016-02-15 Mark Lam <[email protected]>
[ARMv7] stress/op_rshift.js and stress/op_urshift.js are failing.
Modified: trunk/Source/_javascript_Core/inspector/ConsoleMessage.h (196593 => 196594)
--- trunk/Source/_javascript_Core/inspector/ConsoleMessage.h 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/_javascript_Core/inspector/ConsoleMessage.h 2016-02-15 21:23:23 UTC (rev 196594)
@@ -59,13 +59,15 @@
void updateRepeatCountInConsole(ConsoleFrontendDispatcher&);
MessageSource source() const { return m_source; }
+ MessageType type() const { return m_type; }
+ MessageLevel level() const { return m_level; }
const String& message() const { return m_message; }
- MessageType type() const { return m_type; }
- JSC::ExecState* scriptState() const;
const String& url() const { return m_url; }
unsigned line() const { return m_line; }
unsigned column() const { return m_column; }
+ JSC::ExecState* scriptState() const;
+
void incrementCount() { ++m_repeatCount; }
unsigned argumentCount() const;
Modified: trunk/Source/WebCore/CMakeLists.txt (196593 => 196594)
--- trunk/Source/WebCore/CMakeLists.txt 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-02-15 21:23:23 UTC (rev 196594)
@@ -2807,6 +2807,7 @@
workers/DedicatedWorkerGlobalScope.cpp
workers/DedicatedWorkerThread.cpp
workers/Worker.cpp
+ workers/WorkerConsoleClient.cpp
workers/WorkerEventQueue.cpp
workers/WorkerGlobalScope.cpp
workers/WorkerLocation.cpp
Modified: trunk/Source/WebCore/ChangeLog (196593 => 196594)
--- trunk/Source/WebCore/ChangeLog 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/ChangeLog 2016-02-15 21:23:23 UTC (rev 196594)
@@ -1,3 +1,52 @@
+2016-02-15 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Web Workers have no access to console for debugging
+ https://bugs.webkit.org/show_bug.cgi?id=26237
+
+ Reviewed by Timothy Hatcher.
+
+ This adds the most basic console message support to Workers.
+ Messages logged from workers get surfaced through the Page's console.
+ This lacks support for logging and interacting with arguments,
+ which would be addressed when adding more complete Worker
+ debugging tools.
+
+ Test: inspector/console/messageAdded-from-worker.html
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ Add new files.
+
+ * bindings/js/WorkerScriptController.cpp:
+ (WebCore::WorkerScriptController::~WorkerScriptController):
+ (WebCore::WorkerScriptController::initScript):
+ Set the ConsoleClient for the Worker's global object. We route
+ the messages to the Page's console.
+
+ * bindings/js/WorkerScriptController.h:
+ * workers/WorkerConsoleClient.h: Added.
+ * workers/WorkerConsoleClient.cpp: Added.
+ (WebCore::WorkerConsoleClient::WorkerConsoleClient):
+ (WebCore::WorkerConsoleClient::~WorkerConsoleClient):
+ (WebCore::WorkerConsoleClient::profile):
+ (WebCore::WorkerConsoleClient::profileEnd):
+ (WebCore::WorkerConsoleClient::count):
+ (WebCore::WorkerConsoleClient::time):
+ (WebCore::WorkerConsoleClient::timeEnd):
+ (WebCore::WorkerConsoleClient::timeStamp):
+ Stub most console methods in a Worker.
+
+ (WebCore::WorkerConsoleClient::messageWithTypeAndLevel):
+ Send worker log messages to the global scope and on to the main page.
+
+ * workers/WorkerGlobalScope.h:
+ * workers/WorkerGlobalScope.cpp:
+ (WebCore::WorkerGlobalScope::addConsoleMessage):
+ (WebCore::WorkerGlobalScope::addMessageToWorkerConsole):
+ Ideally we want to converge on simple addConsoleMessage
+ APIs that just take a ConsoleMessage, without a barrage
+ of parameters. Add these versions now.
+
2016-02-15 Alex Christensen <[email protected]>
CMake build fix.
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (196593 => 196594)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-15 21:23:23 UTC (rev 196594)
@@ -4190,6 +4190,8 @@
A5416FE618810EF80009FC5F /* YouTubeEmbedShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A5416FE418810EF80009FC5F /* YouTubeEmbedShadowElement.h */; };
A54A82EC15228D2F00C72BA6 /* DOMNodePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A54A82EA15228CA300C72BA6 /* DOMNodePrivate.h */; };
A54A82F115228DF600C72BA6 /* DOMNodePrivate.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = A54A82EA15228CA300C72BA6 /* DOMNodePrivate.h */; };
+ A55639D11C6F09E300806D8E /* WorkerConsoleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A55639D01C6EFD5900806D8E /* WorkerConsoleClient.h */; };
+ A55639D21C6F09E700806D8E /* WorkerConsoleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A55639CF1C6EFD5900806D8E /* WorkerConsoleClient.cpp */; };
A56C5B9A189F34570082D13C /* WebConsoleAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A56C5B98189F34570082D13C /* WebConsoleAgent.cpp */; };
A56C5B9B189F34570082D13C /* WebConsoleAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = A56C5B99189F34570082D13C /* WebConsoleAgent.h */; };
A5732B0A136A161D005C8D7C /* DateComponents.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5732B08136A161D005C8D7C /* DateComponents.cpp */; };
@@ -11848,6 +11850,8 @@
A5416FE318810EF80009FC5F /* YouTubeEmbedShadowElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = YouTubeEmbedShadowElement.cpp; sourceTree = "<group>"; };
A5416FE418810EF80009FC5F /* YouTubeEmbedShadowElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YouTubeEmbedShadowElement.h; sourceTree = "<group>"; };
A54A82EA15228CA300C72BA6 /* DOMNodePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMNodePrivate.h; sourceTree = "<group>"; };
+ A55639CF1C6EFD5900806D8E /* WorkerConsoleClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkerConsoleClient.cpp; sourceTree = "<group>"; };
+ A55639D01C6EFD5900806D8E /* WorkerConsoleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerConsoleClient.h; sourceTree = "<group>"; };
A56C5B98189F34570082D13C /* WebConsoleAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebConsoleAgent.cpp; sourceTree = "<group>"; };
A56C5B99189F34570082D13C /* WebConsoleAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebConsoleAgent.h; sourceTree = "<group>"; };
A5732B08136A161D005C8D7C /* DateComponents.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DateComponents.cpp; sourceTree = "<group>"; };
@@ -16439,6 +16443,8 @@
2E4346330F546A8200B0F1BA /* Worker.cpp */,
2E4346340F546A8200B0F1BA /* Worker.h */,
2E4346350F546A8200B0F1BA /* Worker.idl */,
+ A55639CF1C6EFD5900806D8E /* WorkerConsoleClient.cpp */,
+ A55639D01C6EFD5900806D8E /* WorkerConsoleClient.h */,
A3E2642E14748991005A8588 /* WorkerEventQueue.cpp */,
A3E2642F14748991005A8588 /* WorkerEventQueue.h */,
2E4346360F546A8200B0F1BA /* WorkerGlobalScope.cpp */,
@@ -26686,6 +26692,7 @@
B2FA3D610AB75A6F000E5AC4 /* JSSVGCursorElement.h in Headers */,
B2FA3D630AB75A6F000E5AC4 /* JSSVGDefsElement.h in Headers */,
B2FA3D650AB75A6F000E5AC4 /* JSSVGDescElement.h in Headers */,
+ A55639D11C6F09E300806D8E /* WorkerConsoleClient.h in Headers */,
B2FA3D670AB75A6F000E5AC4 /* JSSVGDocument.h in Headers */,
B222F69D0AB771B80022EFAD /* JSSVGElement.h in Headers */,
8542A7990AE5C94400DF58DF /* JSSVGElementWrapperFactory.h in Headers */,
@@ -29863,6 +29870,7 @@
A77979190D6B9D0C003851B9 /* ImageData.cpp in Sources */,
97205AB51239291000B17380 /* ImageDocument.cpp in Sources */,
F55B3DC11251F12D003EF269 /* ImageInputType.cpp in Sources */,
+ A55639D21C6F09E700806D8E /* WorkerConsoleClient.cpp in Sources */,
089582550E857A7E00F82C83 /* ImageLoader.cpp in Sources */,
B275357B0B053814002CE64F /* ImageMac.mm in Sources */,
2D5A592F152525230036EE51 /* ImageOrientation.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp (196593 => 196594)
--- trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.cpp 2016-02-15 21:23:23 UTC (rev 196594)
@@ -33,6 +33,7 @@
#include "JSEventTarget.h"
#include "ScriptSourceCode.h"
#include "WebCoreJSClientData.h"
+#include "WorkerConsoleClient.h"
#include "WorkerGlobalScope.h"
#include "WorkerObjectProxy.h"
#include "WorkerThread.h"
@@ -40,9 +41,9 @@
#include <heap/StrongInlines.h>
#include <interpreter/Interpreter.h>
#include <runtime/Completion.h>
+#include <runtime/Error.h>
#include <runtime/Exception.h>
#include <runtime/ExceptionHelpers.h>
-#include <runtime/Error.h>
#include <runtime/JSLock.h>
#include <runtime/Watchdog.h>
@@ -63,6 +64,10 @@
WorkerScriptController::~WorkerScriptController()
{
JSLockHolder lock(vm());
+ if (m_workerGlobalScopeWrapper) {
+ m_workerGlobalScopeWrapper->setConsoleClient(nullptr);
+ m_consoleClient = nullptr;
+ }
m_workerGlobalScopeWrapper.clear();
m_vm = nullptr;
}
@@ -95,6 +100,9 @@
}
ASSERT(m_workerGlobalScopeWrapper->globalObject() == m_workerGlobalScopeWrapper);
ASSERT(asObject(m_workerGlobalScopeWrapper->prototype())->globalObject() == m_workerGlobalScopeWrapper);
+
+ m_consoleClient = std::make_unique<WorkerConsoleClient>(*m_workerGlobalScope);
+ m_workerGlobalScopeWrapper->setConsoleClient(m_consoleClient.get());
}
void WorkerScriptController::evaluate(const ScriptSourceCode& sourceCode)
Modified: trunk/Source/WebCore/bindings/js/WorkerScriptController.h (196593 => 196594)
--- trunk/Source/WebCore/bindings/js/WorkerScriptController.h 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/bindings/js/WorkerScriptController.h 2016-02-15 21:23:23 UTC (rev 196594)
@@ -46,6 +46,7 @@
class JSWorkerGlobalScope;
class ScriptSourceCode;
+ class WorkerConsoleClient;
class WorkerGlobalScope;
class WorkerScriptController {
@@ -96,6 +97,7 @@
RefPtr<JSC::VM> m_vm;
WorkerGlobalScope* m_workerGlobalScope;
JSC::Strong<JSWorkerGlobalScope> m_workerGlobalScopeWrapper;
+ std::unique_ptr<WorkerConsoleClient> m_consoleClient;
bool m_executionForbidden;
bool m_isTerminatingExecution { false };
mutable Lock m_scheduledTerminationMutex;
Added: trunk/Source/WebCore/workers/WorkerConsoleClient.cpp (0 => 196594)
--- trunk/Source/WebCore/workers/WorkerConsoleClient.cpp (rev 0)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.cpp 2016-02-15 21:23:23 UTC (rev 196594)
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2016 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 "WorkerConsoleClient.h"
+
+#include <inspector/ConsoleMessage.h>
+#include <inspector/ScriptArguments.h>
+
+using namespace Inspector;
+
+namespace WebCore {
+
+WorkerConsoleClient::WorkerConsoleClient(WorkerGlobalScope& workerGlobalScope)
+ : m_workerGlobalScope(workerGlobalScope)
+{
+}
+
+WorkerConsoleClient::~WorkerConsoleClient()
+{
+}
+
+void WorkerConsoleClient::messageWithTypeAndLevel(MessageType type, MessageLevel level, JSC::ExecState* exec, RefPtr<Inspector::ScriptArguments>&& arguments)
+{
+ String messageText;
+ arguments->getFirstArgumentAsString(messageText);
+ auto message = std::make_unique<Inspector::ConsoleMessage>(MessageSource::ConsoleAPI, type, level, messageText, WTFMove(arguments), exec);
+ m_workerGlobalScope.addConsoleMessage(WTFMove(message));
+}
+
+// FIXME: <https://webkit.org/b/153499> Web Inspector: console.profile should use the new Sampling Profiler
+void WorkerConsoleClient::profile(JSC::ExecState*, const String&) { }
+void WorkerConsoleClient::profileEnd(JSC::ExecState*, const String&) { }
+
+// FIXME: <https://webkit.org/b/127634> Web Inspector: support debugging web workers
+void WorkerConsoleClient::count(JSC::ExecState*, RefPtr<ScriptArguments>&&) { }
+void WorkerConsoleClient::time(JSC::ExecState*, const String&) { }
+void WorkerConsoleClient::timeEnd(JSC::ExecState*, const String&) { }
+void WorkerConsoleClient::timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) { }
+
+} // namespace WebCore
Added: trunk/Source/WebCore/workers/WorkerConsoleClient.h (0 => 196594)
--- trunk/Source/WebCore/workers/WorkerConsoleClient.h (rev 0)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.h 2016-02-15 21:23:23 UTC (rev 196594)
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#ifndef WorkerConsoleClient_h
+#define WorkerConsoleClient_h
+
+#include "WorkerGlobalScope.h"
+#include <runtime/ConsoleClient.h>
+#include <wtf/Forward.h>
+
+namespace JSC {
+class ExecState;
+}
+
+namespace WebCore {
+
+class WorkerConsoleClient final : public JSC::ConsoleClient {
+ WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit WorkerConsoleClient(WorkerGlobalScope&);
+ virtual ~WorkerConsoleClient();
+
+protected:
+ virtual void messageWithTypeAndLevel(MessageType, MessageLevel, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+ virtual void count(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+ virtual void profile(JSC::ExecState*, const String& title) override;
+ virtual void profileEnd(JSC::ExecState*, const String& title) override;
+ virtual void time(JSC::ExecState*, const String& title) override;
+ virtual void timeEnd(JSC::ExecState*, const String& title) override;
+ virtual void timeStamp(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
+
+private:
+ WorkerGlobalScope& m_workerGlobalScope;
+};
+
+} // namespace WebCore
+
+#endif // WorkerConsoleClient_h
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (196593 => 196594)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp 2016-02-15 21:23:23 UTC (rev 196594)
@@ -220,6 +220,17 @@
thread().workerReportingProxy().postExceptionToWorkerObject(errorMessage, lineNumber, columnNumber, sourceURL);
}
+void WorkerGlobalScope::addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage> message)
+{
+ if (!isContextThread()) {
+ postTask(AddConsoleMessageTask(message->source(), message->level(), StringCapture(message->message())));
+ return;
+ }
+
+ thread().workerReportingProxy().postConsoleMessageToWorkerObject(message->source(), message->level(), message->message(), message->line(), message->column(), message->url());
+ addMessageToWorkerConsole(WTFMove(message));
+}
+
void WorkerGlobalScope::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier)
{
if (!isContextThread()) {
@@ -244,8 +255,6 @@
void WorkerGlobalScope::addMessageToWorkerConsole(MessageSource source, MessageLevel level, const String& messageText, const String& suggestedURL, unsigned suggestedLineNumber, unsigned suggestedColumnNumber, RefPtr<ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier)
{
- ASSERT(isContextThread());
-
std::unique_ptr<Inspector::ConsoleMessage> message;
if (callStack)
@@ -253,6 +262,12 @@
else
message = std::make_unique<Inspector::ConsoleMessage>(source, MessageType::Log, level, messageText, suggestedURL, suggestedLineNumber, suggestedColumnNumber, state, requestIdentifier);
+ addMessageToWorkerConsole(WTFMove(message));
+}
+
+void WorkerGlobalScope::addMessageToWorkerConsole(std::unique_ptr<Inspector::ConsoleMessage> message)
+{
+ ASSERT(isContextThread());
InspectorInstrumentation::addMessageToConsole(this, WTFMove(message));
}
Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (196593 => 196594)
--- trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-02-15 21:16:40 UTC (rev 196593)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h 2016-02-15 21:23:23 UTC (rev 196594)
@@ -41,6 +41,10 @@
#include <wtf/TypeCasts.h>
#include <wtf/text/AtomicStringHash.h>
+namespace Inspector {
+class ConsoleMessage;
+}
+
namespace WebCore {
class Blob;
@@ -124,6 +128,7 @@
virtual SecurityOrigin* topOrigin() const override { return m_topOrigin.get(); }
+ void addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage>);
virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) override;
#if ENABLE(SUBTLE_CRYPTO)
@@ -136,6 +141,7 @@
void applyContentSecurityPolicyResponseHeaders(const ContentSecurityPolicyResponseHeaders&);
virtual void logExceptionToConsole(const String& errorMessage, const String& sourceURL, int lineNumber, int columnNumber, RefPtr<Inspector::ScriptCallStack>&&) override;
+ void addMessageToWorkerConsole(std::unique_ptr<Inspector::ConsoleMessage>);
void addMessageToWorkerConsole(MessageSource, MessageLevel, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&&, JSC::ExecState* = 0, unsigned long requestIdentifier = 0);
private: