Create dedicated tests for script.evaluate exceptionDetails
diff --git a/webdriver/tests/bidi/script/evaluate/evaluate.py b/webdriver/tests/bidi/script/evaluate/evaluate.py
index 2bbd7d0..984e740 100644
--- a/webdriver/tests/bidi/script/evaluate/evaluate.py
+++ b/webdriver/tests/bidi/script/evaluate/evaluate.py
@@ -1,8 +1,5 @@
import pytest
-from webdriver.bidi.modules.script import ContextTarget, ScriptEvaluateResultException
-
-from ... import any_int, any_string, recursive_compare
-from .. import any_stack_trace
+from webdriver.bidi.modules.script import ContextTarget
@pytest.mark.asyncio
@@ -18,47 +15,6 @@
@pytest.mark.asyncio
-async def test_params_expression_invalid_script(bidi_session, top_context):
- with pytest.raises(ScriptEvaluateResultException) as exception:
- await bidi_session.script.evaluate(
- expression='))) !!@@## some invalid JS script (((',
- target=ContextTarget(top_context["context"]),
- await_promise=True)
- recursive_compare({
- 'realm': any_string,
- 'exceptionDetails': {
- 'columnNumber': any_int,
- 'exception': {
- 'handle': any_string,
- 'type': 'error'},
- 'lineNumber': any_int,
- 'stackTrace': any_stack_trace,
- 'text': any_string}},
- exception.value.result)
-
-
-@pytest.mark.asyncio
-async def test_exception(bidi_session, top_context):
- with pytest.raises(ScriptEvaluateResultException) as exception:
- await bidi_session.script.evaluate(
- expression="throw Error('SOME_ERROR_MESSAGE')",
- target=ContextTarget(top_context["context"]),
- await_promise=True)
-
- recursive_compare({
- 'realm': any_string,
- 'exceptionDetails': {
- 'columnNumber': any_int,
- 'exception': {
- 'handle': any_string,
- 'type': 'error'},
- 'lineNumber': any_int,
- 'stackTrace': any_stack_trace,
- 'text': any_string}},
- exception.value.result)
-
-
-@pytest.mark.asyncio
async def test_interact_with_dom(bidi_session, top_context):
result = await bidi_session.script.evaluate(
expression="'window.location.href: ' + window.location.href",
diff --git a/webdriver/tests/bidi/script/evaluate/exception_details.py b/webdriver/tests/bidi/script/evaluate/exception_details.py
new file mode 100644
index 0000000..655c0aa
--- /dev/null
+++ b/webdriver/tests/bidi/script/evaluate/exception_details.py
@@ -0,0 +1,122 @@
+import pytest
+
+from webdriver.bidi.modules.script import ContextTarget, ScriptEvaluateResultException
+
+from ... import any_int, any_string, recursive_compare
+from .. import any_stack_trace
+
+
+@pytest.mark.asyncio
+async def test_invalid_script(bidi_session, top_context):
+ with pytest.raises(ScriptEvaluateResultException) as exception:
+ await bidi_session.script.evaluate(
+ expression='))) !!@@## some invalid JS script (((',
+ target=ContextTarget(top_context["context"]),
+ await_promise=True)
+ recursive_compare({
+ 'realm': any_string,
+ 'exceptionDetails': {
+ 'columnNumber': any_int,
+ 'exception': {
+ 'handle': any_string,
+ 'type': 'error'},
+ 'lineNumber': any_int,
+ 'stackTrace': any_stack_trace,
+ 'text': any_string}},
+ exception.value.result)
+
+
+@pytest.mark.asyncio
+async def test_reject_complex_value(bidi_session, top_context):
+ with pytest.raises(ScriptEvaluateResultException) as exception:
+ await bidi_session.script.evaluate(
+ expression="Promise.reject(new Set(['SOME_REJECTED_RESULT']))",
+ target=ContextTarget(top_context["context"]),
+ await_promise=True,
+ )
+
+ recursive_compare(
+ {
+ "realm": any_string,
+ "exceptionDetails": {
+ "columnNumber": any_int,
+ "exception": {
+ "type": "set", "value": [
+ {"type": "string", "value": "SOME_REJECTED_RESULT"}
+ ]
+ },
+ "lineNumber": any_int,
+ "stackTrace": any_stack_trace,
+ "text": any_string,
+ },
+ },
+ exception.value.result,
+ )
+
+
+@pytest.mark.asyncio
+async def test_reject_error(bidi_session, top_context):
+ with pytest.raises(ScriptEvaluateResultException) as exception:
+ await bidi_session.script.evaluate(
+ expression="Promise.reject(new Error('SOME_ERROR_MESSAGE'))",
+ target=ContextTarget(top_context["context"]),
+ await_promise=True,
+ )
+
+ recursive_compare(
+ {
+ "realm": any_string,
+ "exceptionDetails": {
+ "columnNumber": any_int,
+ "exception": {
+ "handle": any_string,
+ "type": "error"},
+ "lineNumber": any_int,
+ "stackTrace": any_stack_trace,
+ "text": any_string,
+ },
+ },
+ exception.value.result,
+ )
+
+
+@pytest.mark.asyncio
+async def test_throw_error(bidi_session, top_context):
+ with pytest.raises(ScriptEvaluateResultException) as exception:
+ await bidi_session.script.evaluate(
+ expression="throw Error('SOME_ERROR_MESSAGE')",
+ target=ContextTarget(top_context["context"]),
+ await_promise=True)
+
+ recursive_compare({
+ 'realm': any_string,
+ 'exceptionDetails': {
+ 'columnNumber': any_int,
+ 'exception': {
+ 'handle': any_string,
+ 'type': 'error'},
+ 'lineNumber': any_int,
+ 'stackTrace': any_stack_trace,
+ 'text': any_string}},
+ exception.value.result)
+
+
+@pytest.mark.asyncio
+async def test_throw_string(bidi_session, top_context):
+ with pytest.raises(ScriptEvaluateResultException) as exception:
+ await bidi_session.script.evaluate(
+ expression="throw 'SOME_STRING_ERROR'",
+ target=ContextTarget(top_context["context"]),
+ await_promise=True)
+
+ recursive_compare({
+ 'realm': any_string,
+ 'exceptionDetails': {
+ 'columnNumber': any_int,
+ 'exception': {
+ 'value': 'SOME_STRING_ERROR',
+ 'type': 'string'},
+ 'lineNumber': any_int,
+ 'stackTrace': any_stack_trace,
+ 'text': any_string}},
+ exception.value.result)