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),
```
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.
Bug 1780752 Comment 0 Edit History
Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.
When a call to script.evaluate/callFunction encounters an exception, the logic to extract the `text` is really weak:
```javascript
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.
When a call to script.evaluate/callFunction encounters an exception, the logic to extract the `text` is really weak:
```javascript
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.