Bug 180350 - WebDriver: evaluateJavaScriptFunction should return null when return value is undefined
Summary: WebDriver: evaluateJavaScriptFunction should return null when return value is...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebDriver (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-12-04 04:21 PST by Carlos Garcia Campos
Modified: 2018-01-29 22:33 PST (History)
3 users (show)

See Also:


Attachments
Patch (3.49 KB, patch)
2017-12-04 04:27 PST, Carlos Garcia Campos
clopez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carlos Garcia Campos 2017-12-04 04:21:12 PST
undefined can't be converted to JSON string, in which case JSON.stringify() returns undefined and we handle that case to return an empty string. We currently handle this case for execute script commands, but not in all other cases where we use evaluateJavaScriptFunction. It would be simpler if evaluateJavaScriptFunction returned null, because in that case we wouldn't need to handle it as a special case.

15.2 Executing Script
https://w3c.github.io/webdriver/webdriver-spec.html#dfn-json-clone
Comment 1 Carlos Garcia Campos 2017-12-04 04:27:50 PST
Created attachment 328341 [details]
Patch
Comment 2 Carlos Garcia Campos 2018-01-16 22:41:00 PST
Brian, could you check if this affects safari driver? Maybe you need to adapt the driver implementation, like I did.
Comment 3 Blaze Burg 2018-01-29 15:40:02 PST
Comment on attachment 328341 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=328341&action=review

This does not seem to regress any safaridriver tests, feel free to land as you please.

> Source/WebDriver/ChangeLog:8
> +        Stop handling the empty string a as a special case of evaluateJavaScriptFunction result.

Nit: 'a as a'
Comment 4 Carlos Garcia Campos 2018-01-29 22:31:40 PST
(In reply to Brian Burg from comment #3)
> Comment on attachment 328341 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=328341&action=review
> 
> This does not seem to regress any safaridriver tests, feel free to land as
> you please.

Cool, thanks!

> > Source/WebDriver/ChangeLog:8
> > +        Stop handling the empty string a as a special case of evaluateJavaScriptFunction result.
> 
> Nit: 'a as a'
Comment 5 Carlos Garcia Campos 2018-01-29 22:32:46 PST
Committed r227773: <https://trac.webkit.org/changeset/227773>
Comment 6 Radar WebKit Bug Importer 2018-01-29 22:33:42 PST
<rdar://problem/37016996>