Diff
Modified: trunk/ChangeLog (272483 => 272484)
--- trunk/ChangeLog 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/ChangeLog 2021-02-08 09:47:26 UTC (rev 272484)
@@ -1,3 +1,14 @@
+2021-02-08 Alicia Boya García <[email protected]>
+
+ ConsoleMessage: Don't encode string JSONLogValue's as JSON
+ https://bugs.webkit.org/show_bug.cgi?id=221421
+
+ Reviewed by Eric Carlson.
+
+ Enable _javascript_Core API tests.
+
+ * Source/cmake/WebKitCommon.cmake:
+
2021-02-05 Don Olmstead <[email protected]>
[MSVC] Catalog warnings
Modified: trunk/Source/_javascript_Core/ChangeLog (272483 => 272484)
--- trunk/Source/_javascript_Core/ChangeLog 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-02-08 09:47:26 UTC (rev 272484)
@@ -1,3 +1,24 @@
+2021-02-08 Alicia Boya García <[email protected]>
+
+ ConsoleMessage: Don't encode string JSONLogValue's as JSON
+ https://bugs.webkit.org/show_bug.cgi?id=221421
+
+ Reviewed by Eric Carlson.
+
+ JSONLogValue's have two tagged types: String and JSON. Despite this,
+ the ConsoleMessage constructor was converting the string values to
+ JSON while coalescing them.
+
+ This also added quotes on the return value of message() for
+ ConsoleMessage's created with this constructor, but not with others.
+
+ This patch removes that behavior, keeping strings as strings and using
+ wrapObject() instead of wrapJSONString() for them.
+
+ * inspector/ConsoleMessage.cpp:
+ (Inspector::ConsoleMessage::ConsoleMessage):
+ (Inspector::ConsoleMessage::addToFrontend):
+
2021-02-07 Yusuke Suzuki <[email protected]>
[JSC] Replace toInteger with toIntegerOrInfinity
Modified: trunk/Source/_javascript_Core/inspector/ConsoleMessage.cpp (272483 => 272484)
--- trunk/Source/_javascript_Core/inspector/ConsoleMessage.cpp 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Source/_javascript_Core/inspector/ConsoleMessage.cpp 2021-02-08 09:47:26 UTC (rev 272484)
@@ -135,7 +135,7 @@
break;
case JSONLogValue::Type::JSON:
if (builder.length()) {
- m_jsonLogValues.append({ JSONLogValue::Type::String, JSON::Value::create(builder.toString())->toJSONString() });
+ m_jsonLogValues.append({ JSONLogValue::Type::String, builder.toString() });
builder.resize(0);
}
@@ -145,7 +145,7 @@
}
if (builder.length())
- m_jsonLogValues.append({ JSONLogValue::Type::String, JSON::Value::create(builder.toString())->toJSONString() });
+ m_jsonLogValues.append({ JSONLogValue::Type::String, builder.toString() });
if (m_jsonLogValues.size())
m_message = m_jsonLogValues[0].value;
@@ -280,10 +280,19 @@
}
if (m_jsonLogValues.size()) {
+ JSC::JSLockHolder lock(globalObject()->vm()); // Necessary for safe jsString() instantiation.
for (auto& message : m_jsonLogValues) {
if (message.value.isEmpty())
continue;
- auto inspectorValue = injectedScript.wrapJSONString(message.value, "console"_s, generatePreview);
+ RefPtr<Protocol::Runtime::RemoteObject> inspectorValue;
+ switch (message.type) {
+ case JSONLogValue::Type::JSON:
+ inspectorValue = injectedScript.wrapJSONString(message.value, "console"_s, generatePreview);
+ break;
+ case JSONLogValue::Type::String:
+ inspectorValue = injectedScript.wrapObject(JSC::JSValue(JSC::jsString(globalObject()->vm(), message.value)), "console"_s, generatePreview);
+ break;
+ }
if (!inspectorValue)
continue;
Modified: trunk/Source/_javascript_Core/runtime/InitializeThreading.h (272483 => 272484)
--- trunk/Source/_javascript_Core/runtime/InitializeThreading.h 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Source/_javascript_Core/runtime/InitializeThreading.h 2021-02-08 09:47:26 UTC (rev 272484)
@@ -28,6 +28,8 @@
#pragma once
+#include "JSExportMacros.h"
+
namespace JSC {
JS_EXPORT_PRIVATE void initialize();
Modified: trunk/Source/cmake/WebKitCommon.cmake (272483 => 272484)
--- trunk/Source/cmake/WebKitCommon.cmake 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Source/cmake/WebKitCommon.cmake 2021-02-08 09:47:26 UTC (rev 272484)
@@ -13,6 +13,7 @@
message(STATUS "The CMake build type is: ${CMAKE_BUILD_TYPE}")
endif ()
+ set(ENABLE_JAVASCRIPTCORE ON)
set(ENABLE_WEBCORE ON)
if (NOT DEFINED ENABLE_WEBKIT)
Modified: trunk/Tools/ChangeLog (272483 => 272484)
--- trunk/Tools/ChangeLog 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Tools/ChangeLog 2021-02-08 09:47:26 UTC (rev 272484)
@@ -1,3 +1,21 @@
+2021-02-08 Alicia Boya García <[email protected]>
+
+ ConsoleMessage: Don't encode string JSONLogValue's as JSON
+ https://bugs.webkit.org/show_bug.cgi?id=221421
+
+ Reviewed by Eric Carlson.
+
+ Added API tests to check for the output of message() when constructing
+ ConsoleMessage objects with JSONLogValue's.
+
+ This includes changes contributed by Philippe Normand enabling
+ _javascript_Core tests which were previously disabled in WebKitGTK and
+ making them compile again.
+
+ * TestWebKitAPI/CMakeLists.txt:
+ * TestWebKitAPI/Tests/WebKit/InspectorConsoleMessage.cpp: Added.
+ (TestWebKitAPI::TEST):
+
2021-02-08 Philippe Normand <[email protected]>
Permission request API for MediaKeySystem access support
Modified: trunk/Tools/Scripts/run-gtk-tests (272483 => 272484)
--- trunk/Tools/Scripts/run-gtk-tests 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Tools/Scripts/run-gtk-tests 2021-02-08 09:47:26 UTC (rev 272484)
@@ -34,7 +34,7 @@
from api_test_runner import TestRunner, add_options
class GtkTestRunner(TestRunner):
- TestRunner.TEST_TARGETS = [ "WebKit2Gtk", "TestWebKit", "TestJSC", "TestWTF", "TestWebCore" ]
+ TestRunner.TEST_TARGETS = [ "WebKit2Gtk", "TestWebKit", "TestJSC", "TestWTF", "TestWebCore", "TestJavaScriptCore" ]
def __init__(self, options, tests=[]):
super(GtkTestRunner, self).__init__("gtk", options, tests)
@@ -123,7 +123,7 @@
return os.path.basename(os.path.dirname(test_program)) in ["WebKit2Gtk"] or os.path.basename(test_program) in ["TestJSC"]
def is_google_test(self, test_program):
- return os.path.basename(test_program) in ["TestWebKit", "TestWTF", "TestWebCore"]
+ return os.path.basename(test_program) in ["TestWebKit", "TestWTF", "TestWebCore", "TestJavaScriptCore"]
def is_qt_test(self, test_program):
return False
Modified: trunk/Tools/TestWebKitAPI/CMakeLists.txt (272483 => 272484)
--- trunk/Tools/TestWebKitAPI/CMakeLists.txt 2021-02-08 09:12:48 UTC (rev 272483)
+++ trunk/Tools/TestWebKitAPI/CMakeLists.txt 2021-02-08 09:47:26 UTC (rev 272484)
@@ -137,6 +137,7 @@
WTFStringUtilities.cpp
Tests/_javascript_Core/DisallowVMEntry.cpp
+ Tests/_javascript_Core/InspectorConsoleMessage.cpp
Tests/_javascript_Core/PropertySlot.cpp
)
@@ -145,6 +146,7 @@
)
set(TestJavaScriptCore_FRAMEWORKS
_javascript_Core
+ WTF
)
set(TestJavaScriptCore_PRIVATE_INCLUDE_DIRECTORIES
@@ -151,7 +153,7 @@
${CMAKE_BINARY_DIR}
${TESTWEBKITAPI_DIR}
${THIRDPARTY_DIR}/gtest/include
- ${_javascript_CoreCore_PRIVATE_FRAMEWORK_HEADERS_DIR}
+ ${_javascript_Core_PRIVATE_FRAMEWORK_HEADERS_DIR}
)
WEBKIT_EXECUTABLE_DECLARE(TestJavaScriptCore)
@@ -299,6 +301,7 @@
set(TestWebKit_PRIVATE_INCLUDE_DIRECTORIES
${CMAKE_BINARY_DIR}
+ ${_javascript_Core_PRIVATE_FRAMEWORK_HEADERS_DIR}
${TESTWEBKITAPI_DIR}
${THIRDPARTY_DIR}/gtest/include
${PAL_FRAMEWORK_HEADERS_DIR}
Added: trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/InspectorConsoleMessage.cpp (0 => 272484)
--- trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/InspectorConsoleMessage.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/_javascript_Core/InspectorConsoleMessage.cpp 2021-02-08 09:47:26 UTC (rev 272484)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ * Copyright (C) 2021 Metrological Group B.V.
+ *
+ * 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"
+
+#if WK_HAVE_C_SPI
+
+#include <_javascript_Core/ConsoleMessage.h>
+
+namespace TestWebKitAPI {
+
+TEST(Inspector, ConsoleMessageBasicMessage)
+{
+ Inspector::ConsoleMessage msg(JSC::MessageSource::JS, JSC::MessageType::Log, JSC::MessageLevel::Debug, "Basic error message"_s);
+ EXPECT_STREQ("Basic error message", msg.message().utf8().data());
+}
+
+TEST(Inspector, ConsoleMessageJSONValueBasicMessage)
+{
+ Inspector::ConsoleMessage msg(JSC::MessageSource::JS, JSC::MessageType::Log, JSC::MessageLevel::Debug, {
+ {JSONLogValue::Type::String, "JSONValue basic error message"_s}
+ }, nullptr, 0);
+ EXPECT_STREQ("JSONValue basic error message", msg.message().utf8().data());
+}
+
+TEST(Inspector, ConsoleMessageSeveralJSONValues)
+{
+ Inspector::ConsoleMessage msg(JSC::MessageSource::JS, JSC::MessageType::Log, JSC::MessageLevel::Debug, {
+ {JSONLogValue::Type::String, "foo"_s},
+ {JSONLogValue::Type::JSON, "{\"key\": \"value\"}"_s},
+ {JSONLogValue::Type::String, "bar"_s},
+ }, nullptr, 0);
+ EXPECT_STREQ("foo", msg.message().utf8().data());
+}
+
+} // namespace TestWebKitAPI
+
+#endif // WK_HAVE_C_SPI