Closed Bug 1780752 Opened 2 years ago Closed 2 years ago

script callFunction and evaluate fail if the script throws an object which doesn't implement toString()

Categories

(Remote Protocol :: WebDriver BiDi, defect, P1)

defect
Points:
1

Tracking

(firefox104 fixed)

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: jdescottes, Assigned: jdescottes)

References

Details

(Whiteboard: [webdriver:m4], [wptsync upstream])

Attachments

(1 file)

When a call to script.evaluate/callFunction encounters an exception, the logic to extract the text is really weak:

text:
  typeof exception === "object"
    ? exception.toString()
    : String(exception),

https://searchfox.org/mozilla-central/rev/15b656909e77d3048d4652b894f79a8c719b4b86/remote/webdriver-bidi/modules/windowglobal/script.jsm#91-95

First this will fail on null as it is an object but has no toString property. But it would also fail on a random object such as { toString: "not a method" } or any other variant.

For null, the test should be covered by extending our exception_details test cases to cover primitives. For random objects, it might be worth adding a mozilla-specific wdspec test. Or we can extract some of that logic to a dedicated helper and add xpcshell tests.

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Pushed by jdescottes@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2eab01956e47 [bidi] Handle exception objects which don't support toString r=webdriver-reviewers,jgraham
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/34945 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch

Post-adding to M4 given that this work is part of it and the project was only on-hold when the patch got landed.

Severity: -- → S3
Points: --- → 1
Priority: -- → P1
Whiteboard: [webdriver:m4]
Upstream PR was closed without merging
Whiteboard: [webdriver:m4] → [webdriver:m4], [wptsync upstream]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: