[Webkit-unassigned] [Bug 236518] Redirect shadow realm console output to page's ConsoleClient

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Feb 11 11:33:40 PST 2022


https://bugs.webkit.org/show_bug.cgi?id=236518

--- Comment #2 from Devin Rousso <drousso at apple.com> ---
Comment on attachment 451723
  --> https://bugs.webkit.org/attachment.cgi?id=451723
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)

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20220211/dfd3fddd/attachment-0001.htm>


More information about the webkit-unassigned mailing list