Skip to content

Instantly share code, notes, and snippets.

@burg

burg/draft.md Secret

Last active July 20, 2018 17:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save burg/17a6f362fedfe6ee91354d197b415736 to your computer and use it in GitHub Desktop.
Save burg/17a6f362fedfe6ee91354d197b415736 to your computer and use it in GitHub Desktop.
WebRTC + WebDriver extensions

WebDriver Extensions for WebRTC

As of STP 41, safaridriver has added new capabilites and extension commands to better support testing WebRTC via WebDriver.

All API described here is considered experimental and is subject to change as we receive early feedback. It is available for testing using safaridriver included with Safari Technology Preview Release 41. More detailed information, with examples, will be disseminated in an upcoming webkit.org blog post.

Extension Capabilities

This is an excerpt from the safaridriver manpage in trunk which reflects support in STP 41.

 webkit:WebRTC
          This capability allows a test to temporarily change Safari's policies for
          WebRTC and Media Capture.  The value of the webkit:WebRTC capability is a dic-
          tionary with the following sub-keys, all of which are optional:

                DisableInsecureMediaCapture
                Normally, Safari refuses to allow media capture over insecure connec-
                tions. This capability suppresses that restriction for testing purposes.
                For example, it would allow a test to exercise media capture code paths
                using a local test web server that is not configured to use HTTPS.

                DisableICECandidateFiltering
                To protect a user's privacy, Safari normally filters out WebRTC ICE can-
                didates that correspond to internal network addresses when capture
                devices are not in use. This capability suppresses ICE candidate filter-
                ing so that both internal and external network addresses are always sent
                as ICE candidates.

Extension Commands

The following is very basic documentation of extension commands for getting/setting user permissions. Bindings support for these commands will be proposed in a pull request soon(tm).

Get Permissions

Endpoint template: GET /session/$sessionId/apple/permissions

JSON arguments: none

JSON result: { “permissions”: { permissionName: true, otherPermission: false, […] } }

  • top level key “permissions” with value of type Object.
  • Known permission names and values are stored and key-value pairs in the “permissions” object. Description: This command returns the names and values of all permissions that have been temporarily set for the session.

Set Permissions

Endpoint template: POST /session/$sessionId/apple/permissions

JSON arguments: { “permissions”: { permissionName: true, otherPermission: false, […] } }

  • top level key “permissions” with value of type Object.
  • Permission names and requested values are stored and key-value pairs in the “permissions” object.

JSON result: none

Description: This command sets the values for the mentioned session permissions. If a permission name is not supported by safaridriver or the particular session, then that permission is ignored and this command has no effect on it.

Supported permissions

  • “GetUserMedia”: this permission controls whether getUserMedia() requests should be accepted or denied automatically. The accepted values are true and false (JS literals, not strings). The default value is to accept these requests, since only mock media capture devices are available to pages associated with an automation session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment