devtools: Support sending js objects to firefox devtools from console.log#42296
devtools: Support sending js objects to firefox devtools from console.log#42296simonwuelker merged 5 commits intoservo:mainfrom
Conversation
|
@simonwuelker are you facing any issues running the Devtools test? For me doing We are figuring out how to put Devtools tests on CI without breaking things, until then please :) btw added the running Devtools tests details in servo/book#202 |
eerii
left a comment
There was a problem hiding this comment.
Other than that it looks great, thanks! :)
Regarding the object actor, you are right, at the moment we aren't reusing them or keeping track of them. We are doing some work on the debugger and we are touching on that, so in the future it might be better. But that's something for later
As a heads up, @atbrakhi and I are working on the same files changing how we evaluate JavaScript, but we think it is not conflicting. We have a draft PR at #42306
Running them works fine, but I'm facing some issues with testing the relevant API (: This is my attempt at writing test case that loads a page and waits for a def test_console_log_arguments(self):
self.run_servoshell(url=f"{self.base_urls[0]}/console/log.html")
with Devtools.connect() as devtools:
devtools.watcher.watch_resources([Resources.CONSOLE_MESSAGE])
console = WebConsoleActor(devtools.client, devtools.targets[0]["consoleActor"])
console_result = Future()
async def on_console_api_call(data: dict):
console_result.set_result(data)
# not sure which event type is correct, so use both for now...
devtools.client.add_event_listener(
console.actor_id, Events.WebConsole.CONSOLE_API_CALL, on_console_api_call
)
devtools.client.add_event_listener(
console.actor_id, Events.WebConsole.LOG_MESSAGE, on_console_api_call
)
result = console_result.result(1)
# do something useful with the data here( |
….log Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
fa38ea9 to
96617c3
Compare
|
Update: I've added a working test and it has already caught a couple bugs. I was initially scared off by the need to setup different actors for the test, but it was pretty manageable in the end! |
| preview = result["preview"] | ||
| self.assertEquals(preview["kind"], "Object") | ||
| self.assertEquals(preview["ownPropertiesLength"], 3) | ||
|
|
There was a problem hiding this comment.
Its likely possible to write this as a reusable assert-method for other tests but lets keep it simple for now. This is the first test for console.log.
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
96617c3 to
62e93f3
Compare
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
eerii
left a comment
There was a problem hiding this comment.
The DevTools part looks good to me :)
I'm less familiar with the console_object_from_handle_value code so I can't comment much on that.
atbrakhi
left a comment
There was a problem hiding this comment.
Thank you for adding tests. Looks great <3
| preview["ownProperties"]["baz"], | ||
| # TODO: The boolean value here should not be a string! That's a bug in our | ||
| # devtools implementation. | ||
| {"configurable": False, "enumerable": True, "value": "true", "writable": True}, |
There was a problem hiding this comment.
would you mind filling a bug for this?
There was a problem hiding this comment.
I filed #42503 and marked it as a good first issue since the fix is pretty simple ^^
|
Interesting, I'll look into these failures later today. |
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
In #42296 i made a mistake during the final changes, accidentally inverting a condition. This was not caught by CI because we don't run devtools tests in CI. Testing: `./mach test-devtools` now passes again Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This allows us to
console.logobjects from JS and have a preview of them appear in the console.Interacting with said preview doesn't work yet, because the devtools object actor is a stub.
Testing: This change adds a test