Skip to content

Add estimate parameter to update_virtual_pressure_source #51194

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions resources/testdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,7 @@
* Causes a virtual pressure source to report a new reading.
*
* Matches the `Update virtual pressure source
* <https://w3c.github.io/compute-pressure/#update-virtual-pressure-source>`_
* <https://w3c.github.io/compute-pressure/?experimental=1#update-virtual-pressure-source>`_
* WebDriver command.
*
* @param {String} source_type - A `virtual pressure source type
Expand All @@ -1437,6 +1437,9 @@
* @param {String} sample - A `virtual pressure state
* <https://w3c.github.io/compute-pressure/#dom-pressurestate>`_
* such as "critical".
* @param {number} estimate - Optional, A `virtual own contribution estimate`
* <https://w3c.github.io/compute-pressure/?experimental=1#the-owncontributionestimate-attribute>`_

* @param {WindowProxy} [context=null] - Browsing context in which to
* run the call, or null for the
* current browsing context.
Expand All @@ -1447,8 +1450,8 @@
* virtual pressure source of the given type does not
* exist).
*/
update_virtual_pressure_source: function(source_type, sample, context=null) {
return window.test_driver_internal.update_virtual_pressure_source(source_type, sample, context);
update_virtual_pressure_source: function(source_type, sample, estimate, context=null) {
return window.test_driver_internal.update_virtual_pressure_source(source_type, sample, estimate, context);
},

/**
Expand Down Expand Up @@ -1723,7 +1726,7 @@
throw new Error("create_virtual_pressure_source() is not implemented by testdriver-vendor.js");
},

async update_virtual_pressure_source(source_type, sample, context=null) {
async update_virtual_pressure_source(source_type, sample, estimate, context=null) {
throw new Error("update_virtual_pressure_source() is not implemented by testdriver-vendor.js");
},

Expand Down
3 changes: 2 additions & 1 deletion tools/wptrunner/wptrunner/executors/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ def __init__(self, logger, protocol):
def __call__(self, payload):
source_type = payload["source_type"]
sample = payload["sample"]
return self.protocol.pressure.update_virtual_pressure_source(source_type, sample)
estimate = payload["estimate"]
return self.protocol.pressure.update_virtual_pressure_source(source_type, sample, estimate)

class RemoveVirtualPressureSourceAction:
name = "remove_virtual_pressure_source"
Expand Down
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/executors/executormarionette.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ def setup(self):
def create_virtual_pressure_source(self, source_type, metadata):
raise NotImplementedError("create_virtual_pressure_source not yet implemented")

def update_virtual_pressure_source(self, source_type, sample):
def update_virtual_pressure_source(self, source_type, sample, estimate):
raise NotImplementedError("update_virtual_pressure_source not yet implemented")

def remove_virtual_pressure_source(self, source_type):
Expand Down
4 changes: 2 additions & 2 deletions tools/wptrunner/wptrunner/executors/executorwebdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ def create_virtual_pressure_source(self, source_type, metadata):
body.update(metadata)
return self.webdriver.send_session_command("POST", "pressuresource", body)

def update_virtual_pressure_source(self, source_type, sample):
body = {"sample": sample}
def update_virtual_pressure_source(self, source_type, sample, estimate):
body = {"sample": sample, "estimate": estimate}
return self.webdriver.send_session_command("POST", "pressuresource/%s" % source_type, body)

def remove_virtual_pressure_source(self, source_type):
Expand Down
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/executors/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,7 +1009,7 @@ def create_virtual_pressure_source(self, source_type, metadata):
pass

@abstractmethod
def update_virtual_pressure_source(self, source_type, sample):
def update_virtual_pressure_source(self, source_type, sample, estimate):
pass

@abstractmethod
Expand Down
4 changes: 2 additions & 2 deletions tools/wptrunner/wptrunner/testdriver-extra.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@
return create_context_action("create_virtual_pressure_source", context, {source_type, metadata});
};

window.test_driver_internal.update_virtual_pressure_source = function(source_type, sample, context=null) {
return create_context_action("update_virtual_pressure_source", context, {source_type, sample});
window.test_driver_internal.update_virtual_pressure_source = function(source_type, sample, estimate = -1.0, context=null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is -1.0 the right default value here? I couldn't tell from the spec why that would be the case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree! I removed it and checked it still works when rolling out in chromium.

Thanks

return create_context_action("update_virtual_pressure_source", context, {source_type, sample, estimate});
};

window.test_driver_internal.remove_virtual_pressure_source = function(source_type, context=null) {
Expand Down
Loading