- Revision
- 289840
- Author
- [email protected]
- Date
- 2022-02-15 13:06:21 -0800 (Tue, 15 Feb 2022)
Log Message
Redirect shadow realm console output to page's ConsoleClient
https://bugs.webkit.org/show_bug.cgi?id=236518
Patch by Joseph Griego <[email protected]> on 2022-02-15
Reviewed by Devin Rousso.
Source/WebCore:
Test: inspector/shadow-realm-console.html
Without this patch, the newly-created shadow realm global object would
not have a console client; we want the console output from the shadow
realm's context to go to the inspector, too.
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::deriveShadowRealmGlobalObject): Copy console client from source JSDOMGlobalObject to new shadow realm's global object.
LayoutTests:
Add tests to verify that (nested) shadow realm contexts still output to
the parent page's inspector; fix one changed test.
* inspector/shadow-realm-console-expected.txt: Added.
* inspector/shadow-realm-console.html: Added.
* js/ShadowRealm-importValue-expected.txt: Added console line that had previously been blackholed
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (289839 => 289840)
--- trunk/LayoutTests/ChangeLog 2022-02-15 20:47:29 UTC (rev 289839)
+++ trunk/LayoutTests/ChangeLog 2022-02-15 21:06:21 UTC (rev 289840)
@@ -1,3 +1,17 @@
+2022-02-15 Joseph Griego <[email protected]>
+
+ Redirect shadow realm console output to page's ConsoleClient
+ https://bugs.webkit.org/show_bug.cgi?id=236518
+
+ Reviewed by Devin Rousso.
+
+ Add tests to verify that (nested) shadow realm contexts still output to
+ the parent page's inspector; fix one changed test.
+
+ * inspector/shadow-realm-console-expected.txt: Added.
+ * inspector/shadow-realm-console.html: Added.
+ * js/ShadowRealm-importValue-expected.txt: Added console line that had previously been blackholed
+
2022-02-15 Antti Koivisto <[email protected]>
[CSS Container Queries] Support all size features
Added: trunk/LayoutTests/inspector/shadow-realm-console-expected.txt (0 => 289840)
--- trunk/LayoutTests/inspector/shadow-realm-console-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/shadow-realm-console-expected.txt 2022-02-15 21:06:21 UTC (rev 289840)
@@ -0,0 +1,13 @@
+CONSOLE MESSAGE: hello
+CONSOLE MESSAGE: hello
+We really just want to test that the shadow realm's console output gets redirected to the appropriate page console and not sent to the default (possibly blackhole) destination
+
+== Running test suite: ShadowRealm.Console.basic
+-- Running test case: ShadowRealm.Console.basic.log
+PASS: message text should be 'hello'
+PASS: message target should be the main page
+
+-- Running test case: ShadowRealm.Console.nested.log
+PASS: message text should be 'hello'
+PASS: message target should be the main page
+
Added: trunk/LayoutTests/inspector/shadow-realm-console.html (0 => 289840)
--- trunk/LayoutTests/inspector/shadow-realm-console.html (rev 0)
+++ trunk/LayoutTests/inspector/shadow-realm-console.html 2022-02-15 21:06:21 UTC (rev 289840)
@@ -0,0 +1,60 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ jscOptions=--useShadowRealm=1 ] -->
+<html>
+<head>
+ <script src=""
+ <script>
+ const realm = new ShadowRealm;
+
+ function realmEvaluate(src) {
+ realm.evaluate(src);
+ }
+
+ function evaluateInNestedRealm(src) {
+ realm.evaluate(`(() => {
+ const r = new ShadowRealm;
+ r.evaluate("${src}");
+ })()`);
+ }
+
+ function test()
+ {
+ const suite = InspectorTest.createAsyncSuite("ShadowRealm.Console.basic");
+
+ suite.addTestCase({
+ name: "ShadowRealm.Console.basic.log",
+ description: "console.log in shadow realms should send to the incubating realm's console",
+ async test() {
+ let [messageAddedEvent] = await Promise.all([
+ WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded),
+ InspectorTest.evaluateInPage(`realmEvaluate("console.log('hello')")`),
+ ]);
+ let {message} = messageAddedEvent.data;
+ InspectorTest.expectEqual(message.messageText, "hello", "message text should be 'hello'");
+ InspectorTest.expectEqual(message.target, WI.mainTarget, "message target should be the main page");
+ }
+ });
+
+ suite.addTestCase({
+ name: "ShadowRealm.Console.nested.log",
+ description: "console.log in shadow realms should send to the incubating realm's console",
+ async test() {
+ let [messageAddedEvent] = await Promise.all([
+ WI.consoleManager.awaitEvent(WI.ConsoleManager.Event.MessageAdded),
+ InspectorTest.evaluateInPage(`evaluateInNestedRealm("console.log('hello')")`),
+ ]);
+ let {message} = messageAddedEvent.data;
+ InspectorTest.expectEqual(message.messageText, "hello", "message text should be 'hello'");
+ InspectorTest.expectEqual(message.target, WI.mainTarget, "message target should be the main page");
+ }
+ });
+
+ suite.runTestCasesAndFinish();
+ }
+ </script>
+</head>
+<body _onLoad_="runTest()">
+ We really just want to test that the shadow realm's console output gets
+ redirected to the appropriate page console and not sent to the default
+ (possibly blackhole) destination
+</body>
+</html>
Modified: trunk/LayoutTests/js/ShadowRealm-importValue-expected.txt (289839 => 289840)
--- trunk/LayoutTests/js/ShadowRealm-importValue-expected.txt 2022-02-15 20:47:29 UTC (rev 289839)
+++ trunk/LayoutTests/js/ShadowRealm-importValue-expected.txt 2022-02-15 21:06:21 UTC (rev 289840)
@@ -1,4 +1,5 @@
CONSOLE MESSAGE: 42
+CONSOLE MESSAGE: 100
Test to ensure correct behaviour of ShadowRealm.prototype.importValue
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
Modified: trunk/Source/WebCore/ChangeLog (289839 => 289840)
--- trunk/Source/WebCore/ChangeLog 2022-02-15 20:47:29 UTC (rev 289839)
+++ trunk/Source/WebCore/ChangeLog 2022-02-15 21:06:21 UTC (rev 289840)
@@ -1,3 +1,19 @@
+2022-02-15 Joseph Griego <[email protected]>
+
+ Redirect shadow realm console output to page's ConsoleClient
+ https://bugs.webkit.org/show_bug.cgi?id=236518
+
+ Reviewed by Devin Rousso.
+
+ Test: inspector/shadow-realm-console.html
+
+ Without this patch, the newly-created shadow realm global object would
+ not have a console client; we want the console output from the shadow
+ realm's context to go to the inspector, too.
+
+ * bindings/js/JSDOMGlobalObject.cpp:
+ (WebCore::JSDOMGlobalObject::deriveShadowRealmGlobalObject): Copy console client from source JSDOMGlobalObject to new shadow realm's global object.
+
2022-02-15 Wenson Hsieh <[email protected]>
Refactor logic for writing selected text in image overlays to the pasteboard
Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (289839 => 289840)
--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2022-02-15 20:47:29 UTC (rev 289839)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp 2022-02-15 21:06:21 UTC (rev 289840)
@@ -621,6 +621,8 @@
wrapper->setPrototypeDirect(vm, wrapper->objectPrototype());
proxy->setTarget(vm, wrapper);
+ wrapper->setConsoleClient(domGlobalObject->consoleClient());
+
return wrapper;
}