-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
safaridriver: add new command to change getUserMedia() behavior for m…
…ock devices As part of this feature, we introduce new endpoints to get and set session permissions. For example, it can control whether a getUserMedia() request for a mock media stream will be allowed or denied. Since this is the first Safari-specific endpoint, add a custom RemoteConnection subclass so that extra commands can be added in. Hook it up in the subclass of WebDriver. This adds two commands: driver.get_permission(permission_name) -> True, False, None driver.set_permission(permission_name, True | False) For convenience, supported values of permission_name are enumerated by the Permission object. These commands map, respectively, to the following endpoints and request/response payloads: GET /session/$sessionId/apple/permissions Request payload: None Response payload: { "permissions": { "getUserMedia": true, ... } } Notes: values for all session permissions are returned, whether or not they have previously been set. -- POST /session/$sessionId/apple/permissions Request payload: { "permissions": [ "getUserMedia": true, ... ] } Response payload: None Notes: can update multiple session permissions simultaneously. Any omitted permission names are unaffected.
- Loading branch information
1 parent
be524b6
commit 619a02f
Showing
3 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Licensed to the Software Freedom Conservancy (SFC) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The SFC licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
The Permission implementation. | ||
""" | ||
|
||
|
||
class Permission(object): | ||
""" | ||
Set of supported permissions. | ||
""" | ||
|
||
GET_USER_MEDIA = "getUserMedia" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Licensed to the Software Freedom Conservancy (SFC) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The SFC licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from selenium.webdriver.remote.remote_connection import RemoteConnection | ||
|
||
|
||
class SafariRemoteConnection(RemoteConnection): | ||
def __init__(self, remote_server_addr, keep_alive=True): | ||
RemoteConnection.__init__(self, remote_server_addr, keep_alive) | ||
|
||
self._commands["GET_PERMISSIONS"] = ('GET', '/session/$sessionId/apple/permissions') | ||
self._commands["SET_PERMISSIONS"] = ('POST', '/session/$sessionId/apple/permissions') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters