Skip to content

Commit

Permalink
Merge branch 'master' into bug/RD-37835_ws_recv_hangs
Browse files Browse the repository at this point in the history
# Conflicts:
#	browserdebuggertools/exceptions.py
#	browserdebuggertools/wssessionmanager.py
#	setup.py
#	tests/unittests/test_sockethandler.py
  • Loading branch information
Mathew Seymour committed Mar 27, 2020
2 parents 2ce6348 + 85c86d1 commit d6e060b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions browserdebuggertools/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ class UnknownError(ProtocolError):

class MessagingThreadIsDeadError(DevToolsException):
pass


class InvalidParametersError(ProtocolError):
pass
5 changes: 4 additions & 1 deletion browserdebuggertools/wssessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from browserdebuggertools.exceptions import (
DevToolsException, ResultNotFoundError, TabNotFoundError, MaxRetriesException,
DevToolsTimeoutException, DomainNotEnabledError,
MethodNotFoundError, UnknownError, ResourceNotFoundError, MessagingThreadIsDeadError
MethodNotFoundError, UnknownError, ResourceNotFoundError, MessagingThreadIsDeadError,
InvalidParametersError
)


Expand Down Expand Up @@ -329,6 +330,8 @@ def execute(self, domain_name, method_name, params=None):
raise ResourceNotFoundError(message)
if code == -32601:
raise MethodNotFoundError(message)
if code == -32602:
raise InvalidParametersError(message)
raise UnknownError("DevTools Protocol error code %s: %s" % (code, message))
return result

Expand Down
14 changes: 12 additions & 2 deletions tests/unittests/test_wssessionmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from browserdebuggertools.exceptions import (
DevToolsException, ResultNotFoundError, TabNotFoundError,
DomainNotEnabledError, DevToolsTimeoutException, MethodNotFoundError
)
DomainNotEnabledError, DevToolsTimeoutException, MethodNotFoundError,
InvalidParametersError)
from browserdebuggertools.wssessionmanager import WSSessionManager, _WSMessagingThread

MODULE_PATH = "browserdebuggertools.wssessionmanager."
Expand Down Expand Up @@ -275,6 +275,16 @@ def test(self):
"method": "%s.%s" % (domain, method), "params": {}
})

@patch(MODULE_PATH + "WSSessionManager._execute", new=MagicMock())
def test_error(self):

self.session_manager._wait_for_result = MagicMock(
return_value={"error": {"code": -32602, "message": "Invalid interceptionId"}}
)

with self.assertRaises(InvalidParametersError):
self.session_manager.execute(MagicMock(), MagicMock(), None)


class Test_WSSessionManager_add_domain(SessionManagerTest):

Expand Down

0 comments on commit d6e060b

Please sign in to comment.