diff --git a/device-posture/device-posture-clear.https.html b/device-posture/device-posture-clear.https.html new file mode 100644 index 00000000000000..8ac7693868cfdb --- /dev/null +++ b/device-posture/device-posture-clear.https.html @@ -0,0 +1,19 @@ + + + + + + diff --git a/resources/testdriver.js b/resources/testdriver.js index a8d05eebd95153..5a5c9edf9490c6 100644 --- a/resources/testdriver.js +++ b/resources/testdriver.js @@ -1031,6 +1031,13 @@ set_device_posture: function(posture, context=null) { return window.test_driver_internal.set_device_posture(posture, context); }, + + /** + * Clears the device posture. + */ + clear_device_posture: function(context=null) { + return window.test_driver_internal.clear_device_posture(context); + }, }; window.test_driver_internal = { @@ -1214,6 +1221,10 @@ async set_device_posture(posture, context=null) { throw new Error("set_device_posture() is not implemented by testdriver-vendor.js"); + }, + + async clear_device_posture(context=null) { + throw new Error("clear_device_posture() is not implemented by testdriver-vendor.js"); } }; })(); diff --git a/tools/wptrunner/wptrunner/executors/actions.py b/tools/wptrunner/wptrunner/executors/actions.py index 185c6000a8f20a..457211ca50a0bd 100644 --- a/tools/wptrunner/wptrunner/executors/actions.py +++ b/tools/wptrunner/wptrunner/executors/actions.py @@ -454,6 +454,16 @@ def __call__(self, payload): posture = payload["posture"] return self.protocol.device_posture.set_device_posture(posture) +class ClearDevicePostureAction: + name = "clear_device_posture" + + def __init__(self, logger, protocol): + self.logger = logger + self.protocol = protocol + + def __call__(self, payload): + return self.protocol.device_posture.clear_device_posture() + actions = [ClickAction, DeleteAllCookiesAction, GetAllCookiesAction, @@ -488,4 +498,5 @@ def __call__(self, payload): UpdateVirtualSensorAction, RemoveVirtualSensorAction, GetVirtualSensorInformationAction, - SetDevicePostureAction] + SetDevicePostureAction, + ClearDevicePostureAction] diff --git a/tools/wptrunner/wptrunner/executors/executorwebdriver.py b/tools/wptrunner/wptrunner/executors/executorwebdriver.py index 2d95300c2e0f6b..e2dd1899cd51d1 100644 --- a/tools/wptrunner/wptrunner/executors/executorwebdriver.py +++ b/tools/wptrunner/wptrunner/executors/executorwebdriver.py @@ -440,6 +440,9 @@ def set_device_posture(self, posture): body = {"posture": posture} return self.webdriver.send_session_command("POST", "deviceposture", body) + def clear_device_posture(self): + return self.webdriver.send_session_command("DELETE", "deviceposture") + class WebDriverProtocol(Protocol): implements = [WebDriverBaseProtocolPart, WebDriverTestharnessProtocolPart, diff --git a/tools/wptrunner/wptrunner/executors/protocol.py b/tools/wptrunner/wptrunner/executors/protocol.py index 2aba9f676c7119..3d588738b6e005 100644 --- a/tools/wptrunner/wptrunner/executors/protocol.py +++ b/tools/wptrunner/wptrunner/executors/protocol.py @@ -812,3 +812,7 @@ class DevicePostureProtocolPart(ProtocolPart): @abstractmethod def set_device_posture(self, posture): pass + + @abstractmethod + def clear_device_posture(self): + pass diff --git a/tools/wptrunner/wptrunner/testdriver-extra.js b/tools/wptrunner/wptrunner/testdriver-extra.js index 850028c2b259f4..87d3826bfceb6a 100644 --- a/tools/wptrunner/wptrunner/testdriver-extra.js +++ b/tools/wptrunner/wptrunner/testdriver-extra.js @@ -329,6 +329,10 @@ }; window.test_driver_internal.set_device_posture = function(posture, context=null) { - return create_action("set_device_posture", {posture, context}); + return create_action("set_device_posture", {posture, context}); + }; + + window.test_driver_internal.clear_device_posture = function(context=null) { + return create_action("clear_device_posture", {context}); }; })();