WebDriver: evaluateJavaScriptFunction should return null when return value is undefined
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 06:32:38 +0000 (06:32 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Jan 2018 06:32:38 +0000 (06:32 +0000)
commitbdc8d8ab16aaa33725fad67f02698f84adebab2d
tree98cf10458053f0f5da2d6e64e906d8ca3d63b84d
parent21f1004bedeb81cbac9bc33acaff50334fde2ab0
WebDriver: evaluateJavaScriptFunction should return null when return value is undefined
https://bugs.webkit.org/show_bug.cgi?id=180350

Reviewed by Carlos Alberto Lopez Perez.

Source/WebDriver:

Stop handling the empty string as a special case of evaluateJavaScriptFunction result.

* Session.cpp:
(WebDriver::Session::executeScript):

Source/WebKit:

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

Fixes: imported/w3c/webdriver/tests/state/get_element_property.py::test_element_non_existent

* WebProcess/Automation/WebAutomationSessionProxy.js:
(let.AutomationSessionProxy.prototype._jsonStringify): Return "null" instead of "" when undefined is given.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227773 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebDriver/ChangeLog
Source/WebDriver/Session.cpp
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.js