RESOLVED FIXED 236518
Redirect shadow realm console output to page's ConsoleClient
https://bugs.webkit.org/show_bug.cgi?id=236518
Summary Redirect shadow realm console output to page's ConsoleClient
Joseph Griego
Reported 2022-02-11 10:30:40 PST
Redirect shadow realm console output to page's ConsoleClient
Attachments
Patch (6.28 KB, patch)
2022-02-11 10:32 PST, Joseph Griego
no flags
Patch (6.83 KB, patch)
2022-02-11 14:01 PST, Joseph Griego
hi: review+
Patch (6.78 KB, patch)
2022-02-14 13:31 PST, Joseph Griego
no flags
Joseph Griego
Comment 1 2022-02-11 10:32:49 PST
Devin Rousso
Comment 2 2022-02-11 11:33:40 PST
Comment on attachment 451723 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451723&action=review Nice fix! Some style comments, but I think the logic is sound :) BTW did you want this to be reviewed? I dont see r? so I wasn't sure 😅 Apologies if that was not the intention/desire. > LayoutTests/inspector/shadow-realm-console.html:6 > + const realm = new ShadowRealm(); Style: this should only be indented four spaces, not five NIT: you can omit `()` if there are no arguments when using `new` > LayoutTests/inspector/shadow-realm-console.html:31 > + WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, function(event) { Rather than having this be global listener, you could have this just be a one-off `awaitEvent` inside each test. As an example, ``` await 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", "The console message should have the text 'hello'."); }, ``` > LayoutTests/inspector/shadow-realm-console.html:41 > + name: "log", please give this a more descriptive name like `name: "ShadowRealm.Console.basic.log"` > LayoutTests/inspector/shadow-realm-console.html:42 > + description: "console.log in shadow realms should send to the incubating realm's console", While this is perhaps true given that you're seeing a console message in the first place, I think we might also want to check that the `target` of the console message matches that of the creating context. As such, I'd add something like this to the end of my example code in my comment on :31 ``` InspectorText.expectEqual(message.target, WI.mainTarget, "The target of the console message should be the main target."); ``` > LayoutTests/inspector/shadow-realm-console.html:46 > + .then(msg => { Style: we always add `(` `)` in arrow functions, even when there's only a single parameter > LayoutTests/inspector/shadow-realm-console.html:47 > + InspectorTest.expectEqual(msg.messageText, "hello", "message text should match"); Style: we normally make these into complete sentences, e.g. "The console message should have the text 'hello'." > LayoutTests/inspector/shadow-realm-console.html:55 > + name: "nested log", ditto (:41) > LayoutTests/inspector/shadow-realm-console.html:60 > + .then(msg => { ditto (:46) > LayoutTests/inspector/shadow-realm-console.html:61 > + InspectorTest.expectEqual(msg.messageText, "hello", "message text should match"); ditto (:47)
Joseph Griego
Comment 3 2022-02-11 11:45:46 PST
Was waiting on EWS before setting r? but yes, thanks for the review :)
Joseph Griego
Comment 4 2022-02-11 14:01:25 PST
Devin Rousso
Comment 5 2022-02-11 14:57:48 PST
Comment on attachment 451743 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=451743&action=review r=mews, thanks for taking my suggestions! =D > LayoutTests/inspector/shadow-realm-console.html:26 > + async test(resolve, reject) { NIT: please remove the `resolve, reject` since those are not provided when using an `async test` :) > LayoutTests/inspector/shadow-realm-console.html:40 > + async test(resolve, reject) { ditto (:26)
Joseph Griego
Comment 6 2022-02-14 13:31:15 PST
EWS
Comment 7 2022-02-15 13:07:37 PST
Committed r289840 (247288@main): <https://commits.webkit.org/247288@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 451938 [details].
Radar WebKit Bug Importer
Comment 8 2022-02-15 13:08:25 PST
Note You need to log in before you can comment on or make changes to this bug.