Skip to content

Commit 1376a29

Browse files
[TODO: REVERT] revert all the changes, keep bidi transport
1 parent 7353ce0 commit 1376a29

File tree

11 files changed

+84
-683
lines changed

11 files changed

+84
-683
lines changed

console/console-log-logged.html

-25
This file was deleted.

resources/testdriver.js

-52
Original file line numberDiff line numberDiff line change
@@ -49,45 +49,6 @@
4949
* @namespace {test_driver}
5050
*/
5151
window.test_driver = {
52-
/**
53-
Represents `WebDriver BiDi <https://w3c.github.io/webdriver-bidi>`_ protocol.
54-
*/
55-
bidi: {
56-
/**
57-
* `log <https://w3c.github.io/webdriver-bidi/#module-log>`_ module.
58-
*/
59-
log: {
60-
/**
61-
* `log.entryAdded <https://w3c.github.io/webdriver-bidi/#event-log-entryAdded>`_ event.
62-
*/
63-
entry_added: {
64-
/**
65-
* Subscribe to the `log.entryAdded` event. This does not add actual listeners. To listen to the
66-
* event, use `on` method.
67-
* @param {{contexts?: null | (string | Window)[]}} props - Parameters for the subscription.
68-
* * `contexts`: an array of window proxies or browsing context ids to listen to the event. If not
69-
* provided, the event subscription is done for the current window's browsing context. `null` for
70-
* the global subscription.
71-
* @return {Promise<void>}
72-
*/
73-
subscribe: async function (props = {}) {
74-
return window.test_driver_internal.bidi.log.entry_added.subscribe(props);
75-
},
76-
/**
77-
* Add an event listener for the `log.entryAdded
78-
* <https://w3c.github.io/webdriver-bidi/#event-log-entryAdded>`_ event. Make sure `subscribe` is
79-
* called before using this method.
80-
*
81-
* @param callback {function(event): void} - The callback to be called when the event is fired.
82-
* @returns {function(): void} - A function to call to remove the event listener.
83-
*/
84-
on: function (callback) {
85-
return window.test_driver_internal.bidi.log.entry_added.on(callback);
86-
},
87-
}
88-
}
89-
},
90-
9152
/**
9253
* Set the context in which testharness.js is loaded
9354
*
@@ -1117,19 +1078,6 @@
11171078
*/
11181079
in_automation: false,
11191080

1120-
bidi: {
1121-
log: {
1122-
entry_added: {
1123-
subscribe: function () {
1124-
throw new Error("bidi.log.entry_added.subscribe is not implemented by testdriver-vendor.js");
1125-
},
1126-
on: function () {
1127-
throw new Error("bidi.log.entry_added.on is not implemented by testdriver-vendor.js");
1128-
}
1129-
}
1130-
}
1131-
},
1132-
11331081
async click(element, coords) {
11341082
if (this.in_automation) {
11351083
throw new Error("click() is not implemented by testdriver-vendor.js");

tools/webdriver/webdriver/bidi/error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self, message: str, stacktrace: Optional[str] = None):
1919

2020
def __repr__(self):
2121
"""Return the object representation in string format."""
22-
return f"{self.__class__.__name__}({self.message}, {self.stacktrace})"
22+
return f"{self.__class__.__name__}({self.error}, {self.message}, {self.stacktrace})"
2323

2424
def __str__(self):
2525
"""Return the string representation of the object."""

tools/webdriver/webdriver/bidi/protocol.py

-101
This file was deleted.

tools/webdriver/webdriver/protocol.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import webdriver
66

7+
78
"""WebDriver wire protocol codecs."""
89

910

@@ -23,11 +24,6 @@ def default(self, obj):
2324
return {webdriver.ShadowRoot.identifier: obj.id}
2425
elif isinstance(obj, webdriver.WebWindow):
2526
return {webdriver.WebWindow.identifier: obj.id}
26-
# Support for arguments received via BiDi.
27-
# https://github.com/web-platform-tests/rfcs/blob/master/rfcs/testdriver_bidi.md
28-
elif isinstance(obj, webdriver.bidi.protocol.BidiValue):
29-
return obj.to_classic_protocol_value()
30-
3127
return super().default(obj)
3228

3329

tools/wptrunner/wptrunner/executors/asyncactions.py

-46
This file was deleted.

tools/wptrunner/wptrunner/executors/base.py

+6-64
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import socket
1111
import sys
1212
from abc import ABCMeta, abstractmethod
13-
from typing import Any, Callable, ClassVar, Dict, List, Literal, Tuple, Type
13+
from typing import Any, Callable, ClassVar, Tuple, Type
1414
from urllib.parse import urljoin, urlsplit, urlunsplit
1515

1616
from . import pytestrunner
1717
from .actions import actions
18-
from .asyncactions import async_actions
1918
from .protocol import Protocol, WdspecProtocol
2019

2120

@@ -725,14 +724,14 @@ def __init__(self, logger, protocol, test_window):
725724
self.protocol = protocol
726725
self.test_window = test_window
727726
self.logger = logger
728-
self.callbacks: Dict[str, Callable[[str, Any], Tuple[bool, Any]]] = {
727+
self.callbacks = {
729728
"action": self.process_action,
730729
"complete": self.process_complete
731730
}
732731

733732
self.actions = {cls.name: cls(self.logger, self.protocol) for cls in actions}
734733

735-
def __call__(self, result: Tuple[str, str, Dict]):
734+
def __call__(self, result):
736735
url, command, payload = result
737736
self.logger.debug("Got async callback: %s" % result[1])
738737
try:
@@ -741,11 +740,11 @@ def __call__(self, result: Tuple[str, str, Dict]):
741740
raise ValueError("Unknown callback type %r" % result[1]) from e
742741
return callback(url, payload)
743742

744-
def process_complete(self, url: str, payload: List) -> Tuple[Literal[True], Any]:
743+
def process_complete(self, url, payload):
745744
rv = [strip_server(url)] + payload
746745
return True, rv
747746

748-
def process_action(self, url: str, payload: Dict) -> Tuple[Literal[False], None]:
747+
def process_action(self, url, payload):
749748
action = payload["action"]
750749
cmd_id = payload["id"]
751750
self.logger.debug(f"Got action: {action}")
@@ -783,67 +782,10 @@ def process_action(self, url: str, payload: Dict) -> Tuple[Literal[False], None]
783782

784783
return False, None
785784

786-
def _send_message(self, cmd_id: int, message_type: str, status: str, message: str = None):
785+
def _send_message(self, cmd_id, message_type, status, message=None):
787786
self.protocol.testdriver.send_message(cmd_id, message_type, status, message=message)
788787

789788

790-
class AsyncCallbackHandler(CallbackHandler):
791-
"""
792-
Handle synchronous and asynchronous actions. Extends `CallbackHandler` with support of async actions.
793-
"""
794-
795-
def __init__(self, logger, protocol, test_window, loop):
796-
super().__init__(logger, protocol, test_window)
797-
self.loop = loop
798-
self.async_actions = {cls.name: cls(self.logger, self.protocol) for cls in async_actions}
799-
800-
def process_action(self, url: str, payload: Dict[str, Any]) -> Tuple[Literal[False], None]:
801-
action = payload["action"]
802-
if action in self.async_actions:
803-
# Schedule async action to be processed in the event loop and return immediately.
804-
self.logger.debug(f"Scheduling async action processing: {action}, {payload}")
805-
self.loop.create_task(self._process_async_action(action, payload))
806-
return False, None
807-
else:
808-
# Fallback to the default action processing, which will fail if the action is not implemented.
809-
self.logger.debug(f"Processing synchronous action: {action}, {payload}")
810-
return super().process_action(url, payload)
811-
812-
async def _process_async_action(self, action: str, payload: Dict[str, Any]):
813-
"""
814-
Process async action and send the result back to the test driver.
815-
816-
This method is analogous to `process_action` but is intended to be used with async actions in a task, so it does
817-
not raise unexpected exceptions. However, the unexpected exceptions are logged and the error message is sent
818-
back to the test driver.
819-
"""
820-
async_action_handler = self.async_actions[action]
821-
cmd_id = payload["id"]
822-
try:
823-
result = await async_action_handler(payload)
824-
except AttributeError as e:
825-
# If we fail to get an attribute from the protocol presumably that's a
826-
# ProtocolPart we don't implement
827-
# AttributeError got an obj property in Python 3.10, for older versions we
828-
# fall back to looking at the error message.
829-
if ((hasattr(e, "obj") and getattr(e, "obj") == self.protocol) or
830-
f"'{self.protocol.__class__.__name__}' object has no attribute" in str(e)):
831-
raise NotImplementedError from e
832-
except self.unimplemented_exc:
833-
self.logger.warning("Action %s not implemented" % action)
834-
self._send_message(cmd_id, "complete", "error", f"Action {action} not implemented")
835-
except self.expected_exc as e:
836-
self.logger.debug(f"Action {action} failed with an expected exception: {e}")
837-
self._send_message(cmd_id, "complete", "error", f"Action {action} failed: {e}")
838-
except Exception as e:
839-
self.logger.warning(f"Action {action} failed with an unexpected exception: {e}")
840-
self._send_message(cmd_id, "complete", "error", f"Unexpected exception: {e}")
841-
else:
842-
self.logger.debug(f"Action {action} completed with result {result}")
843-
return_message = {"result": result}
844-
self._send_message(cmd_id, "complete", "success", json.dumps(return_message))
845-
846-
847789
class ActionContext:
848790
def __init__(self, logger, protocol, context):
849791
self.logger = logger

0 commit comments

Comments
 (0)