Update Ruby BiDi script structs to match spec (as of 2024-07-08)#14236
Conversation
This updates the structs used by the BiDi `Script` and `LogHandler` classes to match the W3C spec as of 2024-07-08. It also makes the tests slightly more detailed.
PR Reviewer Guide 🔍
|
PR Code Suggestions ✨
|
|
NOTE: This was based on some discussion in Slack with @titusfortner. |
User description
Description
This updates the structs used by the BiDi
ScriptandLogHandlerclasses to represent JS logs and errors so that they match the W3C spec as of 2024-07-08. This is meant to resolve the discussion about the context of JS Logs and errors from #13992.There are a couple open questions here:
These structs include some complex collections that have defined types in the spec, but are represented here as hashes, rather than other structs. Should they be structs instead? (For context, this PR was motivated by a desire to get at the information in
log_entry_instance.source['context'], which would be nicer to get aslog_entry_instance.source.context.)Caveat:
argsandstack_tracealready existed as arrays of hashes and hashes of arrays of hashes respectively, so maybe making nice structs would be too much of a breaking change?The spec now has a
GenericLogEntrytype for things that aren’t JS logs or exceptions (I think this is for various warnings and errors logged by the browser itself, like CORS blocking or content integrity problems). That’s not handled here; should I try to add it? Happy to do that work here or in a separate PR if desired.It’s not currently a problem since
Scriptdoesn’t ever add handlers for other types of messages that would show up this way, but someone could theoretically subscribe to them via an instance ofLogHandlerand that might not work out so well.Motivation and Context
The BiDi spec has added more fields since
LogHandlerwas first implemented, and the current functionality is missing important information, like the ID of the browser context a log entry came from (inentry.source.context). This just updates the structs with the fields currently expected by the spec.Types of changes
Checklist
PR Type
Enhancement, Tests
Description
ConsoleLogEntryandJavaScriptLogEntrystructs inLogHandlerto include thesourcefield, aligning with the W3C spec as of 2024-07-08.method,args, andstack_tracefields toConsoleLogEntrystruct.a_stack_framein the test suite to matchscript.StackFrameobjects.ConsoleLogEntryandJavaScriptLogEntry, including detailed checks forsource,args, andstack_trace.Changes walkthrough 📝
log_handler.rb
Update BiDi log entry structs to match W3C specrb/lib/selenium/webdriver/bidi/log_handler.rb
ConsoleLogEntryandJavaScriptLogEntrystructs to includesource.method,args, andstack_tracetoConsoleLogEntry.script_spec.rb
Enhance BiDi script tests for updated log entry structsrb/spec/integration/selenium/webdriver/bidi/script_spec.rb
a_stack_framefor matchingscript.StackFrameobjects.
ConsoleLogEntryandJavaScriptLogEntry.source,args, andstack_trace.