Skip to content
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

testdriver.js: Make set_permission() take a PermissionDescriptor, not a name #20674

Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[set_permission.html]
[set_permission.https.html]
expected:
if product != "chrome": ERROR
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

<script>
promise_test(t => {
return test_driver.set_permission("ambient-light-sensor", "granted", true);
return test_driver.set_permission({name: "ambient-light-sensor"}, "granted", true);
}, "Grant Permission for one realm");

promise_test(t => {
return test_driver.set_permission("ambient-light-sensor", "denied");
return test_driver.set_permission({name: "push", userVisibleOnly: true}, "denied");
}, "Deny Permission, omit one realm");
</script>
12 changes: 6 additions & 6 deletions resources/testdriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@
* This function simulates a user setting a permission into a particular state as described
* in {@link https://w3c.github.io/permissions/#set-permission-command}
*
* @param {String} name - the name of the permission
* @param {Object} descriptor - a [PermissionDescriptor]{@link
* https://w3c.github.io/permissions/#dictdef-permissiondescriptor}
* object
* @param {String} state - the state of the permission
* @param {boolean} one_realm - Optional. Whether the permission applies to only one realm
*
Expand All @@ -226,12 +228,10 @@
* @returns {Promise} fulfilled after the permission is set, or rejected if setting the
* permission fails
*/
set_permission: function(name, state, one_realm) {
set_permission: function(descriptor, state, one_realm) {
let permission_params = {
descriptor: {
name: name
},
state: state,
descriptor,
state,
oneRealm: one_realm,
};
return window.test_driver_internal.set_permission(permission_params);
Expand Down
2 changes: 1 addition & 1 deletion tools/wptrunner/wptrunner/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def __call__(self, payload):
state = permission_params["state"]
one_realm = permission_params.get("oneRealm", False)
self.logger.debug("Setting permission %s to %s, oneRealm=%s" % (name, state, one_realm))
self.protocol.set_permission.set_permission(name, state, one_realm)
self.protocol.set_permission.set_permission(descriptor, state, one_realm)

class AddVirtualAuthenticatorAction(object):
def __init__(self, logger, protocol):
Expand Down
6 changes: 2 additions & 4 deletions tools/wptrunner/wptrunner/executors/executorwebdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,9 @@ class WebDriverSetPermissionProtocolPart(SetPermissionProtocolPart):
def setup(self):
self.webdriver = self.parent.webdriver

def set_permission(self, name, state, one_realm):
def set_permission(self, descriptor, state, one_realm):
permission_params_dict = {
"descriptor": {
"name": name
},
"descriptor": descriptor,
"state": state,
}
if one_realm is not None:
Expand Down
4 changes: 2 additions & 2 deletions tools/wptrunner/wptrunner/executors/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ class SetPermissionProtocolPart(ProtocolPart):
name = "set_permission"

@abstractmethod
def set_permission(self, name, state, one_realm=False):
def set_permission(self, descriptor, state, one_realm=False):
"""Set permission state.
:param name: The name of the permission to set.
:param descriptor: A PermissionDescriptor object.
:param state: The state to set the permission to.
:param one_realm: Whether to set the permission for only one realm."""
pass
Expand Down