Bug 1764594 Comment 4 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

I had a quick look and the problem here is definitely not related to our serialization to JSON! Whenever [`receiveMessage`](https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/actors/MarionetteCommandsChild.jsm#176-179) in `MarionetteCommandsChild.jsm` calls into `toJSON()` the value is a valid `ShadowRoot` instance in both cases.

The only difference is that in case of `Execute Script` the `ShadowRoot` doesn't have a `containingShadowRoot` meaning it's undefined, and as such the [`isShadowRoot()`](https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/element.js#1307-1320) returns `false`. 

Most likely it's related to the Promise handling code in evaluate.js where we return the result differently:
https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/evaluate.js#176-205
I had a quick look and the problem here is definitely not related to our serialization to JSON! Whenever [`receiveMessage`](https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/actors/MarionetteCommandsChild.jsm#176-179) in `MarionetteCommandsChild.jsm` calls into `toJSON()` the value is a valid `ShadowRoot` instance in both cases.

The only difference is that in case of `Execute Script` the `ShadowRoot` doesn't have a `containingShadowRoot` meaning it's `undefined`, and as such the [`isShadowRoot()`](https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/element.js#1307-1320) returns `false`. 

Most likely it's related to the Promise handling code in evaluate.js where we return the result differently:
https://searchfox.org/mozilla-central/rev/44d99b6b8d84abed2d20386cc2e62cd90da41cc3/remote/marionette/evaluate.js#176-205

Back to Bug 1764594 Comment 4