Bug 180350

Summary: WebDriver: evaluateJavaScriptFunction should return null when return value is undefined
Product: WebKit Reporter: Carlos Garcia Campos <cgarcia>
Component: WebDriverAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: bburg, clopez, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch clopez: review+

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 BJ 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>