Commit cb2ef70f authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] Make ExecuteScript() and ExecuteAsyncScript() return JavaScriptError

Bug: chromedriver:2744
Change-Id: I246a3797793f0e498601f5cdb68f417618349a25
Reviewed-on: https://chromium-review.googlesource.com/c/1431192
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625772}
parent 4903ce53
......@@ -8,7 +8,7 @@
*/
var StatusCode = {
STALE_ELEMENT_REFERENCE: 10,
UNKNOWN_ERROR: 13,
JAVA_SCRIPT_ERROR: 17,
};
/**
......@@ -361,7 +361,7 @@ function callFunction(shadowHostIds, func, args, w3c, opt_unwrappedReturn) {
try {
var returnValue = wrap(func.apply(null, unwrap(args, cache)));
} catch (error) {
status = error.code || StatusCode.UNKNOWN_ERROR;
status = error.code || StatusCode.JAVA_SCRIPT_ERROR;
var returnValue = error.message;
}
return {
......
......@@ -43,7 +43,7 @@ function testCallFunctionThrows() {
var result = callFunction(null, function() { throw new Error('fake error'); },
[]);
assertEquals(StatusCode.UNKNOWN_ERROR, result.status);
assertEquals(StatusCode.JAVA_SCRIPT_ERROR, result.status);
assertEquals('fake error', result.value);
result = callFunction(null, function() {
......
......@@ -1010,7 +1010,8 @@ HttpHandler::PrepareStandardResponse(
response.reset(new net::HttpServerResponseInfo(net::HTTP_BAD_REQUEST));
break;
case kJavaScriptError:
response.reset(new net::HttpServerResponseInfo(net::HTTP_BAD_REQUEST));
response.reset(
new net::HttpServerResponseInfo(net::HTTP_INTERNAL_SERVER_ERROR));
break;
case kMoveTargetOutOfBounds:
response.reset(
......
......@@ -1793,7 +1793,7 @@ class ChromeDriverTest(ChromeDriverBaseTestWithWebServer):
def testThrowErrorWithExecuteScript(self):
self.assertRaisesRegexp(
chromedriver.UnknownError, "some error",
chromedriver.JavaScriptError, "some error",
self._driver.ExecuteScript, 'throw new Error("some error")')
def testDoesntCrashWhenScriptLogsUndefinedValue(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment