The [Remote Playback API] poses a challenge to test authors, as fully exercising those interfaces requires remote playback devices
that respond in predictable ways. To address this challenge this document defines a number of extension commands
to the [WebDriver] specification for controlling fake remote playback devices
on the host that the user agent is running on. With these extension commands
, devices with particular properties can be created and their responses to requests are well defined.
A fake remote playback device
simulates the behavior of a remote playback device
in controlled ways. Each fake remote playback device
has a unique identifier name.
Note: A fake remote playback device
is initially available, no fake remote playback device
is added means the list of available remote playback devices
is empty.
A fake remote playback device
have associated fake remote playback state
, which should be in sync with the media element state when fake remote playback device
is connected.
Note: The fake remote playback device
defined in this specification is not intended be used by non-testing-related web content. The user agent MAY choose to expose fake remote playback device
interface only when a runtime or compile-time flag has been set.
When a user agent chooses to expose fake remote playback device
interface, it MUST reconfigure its internal implementation of the RemotePlayback
object in the current global object so that it MUST detect availability of, connect to and control playback on fake remote playback devices
in following ways:
- Once a
fake remote playback device
is added, it SHOULD be added to thelist of available remote playback devices
. - The
list of available remote playback devices
SHOULD only containsfake remote playback devices
. - When invoke
watchAvailability()
method, the UA MUST monitor thelist of available remote playback devices
. - When invoke
prompt()
method, no UI will be prompted, the UA MUST connect to the selectedfake remote playback device
. - If a
fake remote playback device
is added withselected state
set totrue
, that it will become the selectedfake remote playback device
for the next request toestablish a connection with the remote playback device
. - If multiple
fake remote playback devices
are added withselected state
set totrue
, then the implementation acts as if nofake remote playback device
has been selected (i.e., theprompt()
Promise will remain unresolved). - If no
fake remote playback device
hasselected state
set totrue
, the UA will behave as if the user has denied permission to use anyfake remote playback device
. - When the
state
of aRemotePlayback
object isconnected
, the UA SHOULD satisfy conditions relate thelocal playback state
, themedia element state
, and thefake remote playback state
described inMedia commands and media playback state
.
The FakeRemotePlayback
dictionary provides information about a fake remote playback device
.
dictionary FakeRemotePlayback {
DOMString name;
boolean selected;
FakeRemotePlaybackState state;
}
- name: a string representing a
fake remote playback device
's name. - selected: a boolean that indicates a
fake remote playback device
'sselected state
. When set to true, thisfake remote playback device
is a selectedfake remote playback device
. - state: A
FakeRemotePlaybackState
representing afake remote playback device
'sfake remote playback state
.
A serialized fake remote playback device
is a JSON Object
where a fake remote playback
's fields listed in the FakeRemotePlayback
dictionary are mapped using the JSON Key and the associated field's value from the fake remote playback devices
in the current browsing context
.
The FakeRemotePlaybackInit
dictionary is used to initialize a fake remote playback device
.
dictionary FakeRemotePlaybackInit {
required DOMString name;
boolean selected = true;
FakeRemotePlaybackState state;
}
- name: a string that is used to set a
fake remote playback device
's name. - selected: a boolean that is used to set a
fake remote playback device
'sselected state
. - state: a
FakeRemotePlaybackState
that is used to set afake remote playback device
'sfake remote playback state
.
A FakeRemotePlaybackState
enumeration represents the fake remote playback state
.
enum FakeRemotePlaybackState {
"playing"
"paused"
"end"?
…
}
HTTP Method | URI Template |
---|---|
POST | /session/{session id}/fakeremoteplayback/ |
The add fake remote playback device
extension command
adds a new fake remote playback device
.
The remote end steps
are:
- Let init be the init parameter,
converted to an IDL value
of typeFakeRemotePlaybackInit
. If this throws an exception, return aWebDriver error
withWebDriver error code
invalid argument
. - Let name be the init.
name
. If thecurrent browsing context
already has this name offake remote playback device
, return aWebDriver error
withWebDriver error code
fake remote playback device already exists
. - If the
current browsing context
isno longer open
, return aWebDriver error
withWebDriver error code
no such window
. Handle any user prompts
, and return its value if it is aWebDriver error
.- Run these sub-steps
in parallel
to add afake remote playback device
inthe current browsing context
:- Let fakeDevice be a new
fake remote playback device
. - Set fakeDevice's
fake remote playback device name
to name. - If init.
selected
istrue
, set this fakeDeviceselected state
to true. - If init.
state
is present, set fakeDevice'sfake remote playback state
to init.state
. - Otherwise, set fakeDevice's
fake remote playback state
tonull
.
- Let fakeDevice be a new
- Return
success
withdata
null.
Example:
To add a
selected fake remote playback device
named "ChromeCast" in thecurrent browsing context
of the session with ID 12, thelocal end
would POST to/session/12/fakeremoteplayback
with the body:{ "name": "ChromeCast", "selected": true, "state": "playing" }
HTTP Method | URI Template |
---|---|
GET | /session/{session id}/fakeremoteplayback/{name} |
The get fake remote playback device
extension command
retrieves information about a given name of fake remote playback device
.
The remote end steps
are:
- If
the current browsing context
isno longer open
, return aWebDriver error
withWebDriver error code
no such window
. Handle any user prompts
, and return its value if it is aWebDriver error
.- If the
url variable
name is not equal to afake remote playback device
's name amongst all associatedfake remote playback devices
ofthe current browsing context
, return aWebDriver error
withWebDriver error code
no such fake remote playback device
. - Return
success
with theserialized fake remote playback device
as data.
// e.g. To change the selected attribute to test disconnection, change fake remote playback state to test reflection on local playback state.
HTTP Method | URI Template |
---|---|
POST | /session/{session id}/fakeremoteplayback/ |
The update fake remote playback device
extension command
updates properties about a given name of fake remote playback device
.
The remote end steps
are:
- Let init be the init parameter,
converted to an IDL value
of typeFakeRemotePlaybackInit
. If this throws an exception, return aWebDriver error
withWebDriver error code
invalid argument
. - If the init.
name
is not equal to afake remote playback device
's name amongst all associatedfake remote playback devices
ofthe current browsing context
, return aWebDriver error
withWebDriver error code
no such fake remote playback device
. - Otherwise, let fakeDevice be the
fake remote playback device
with name init.name
. - If the
current browsing context
isno longer open
, return aWebDriver error
withWebDriver error code
no such window
. Handle any user prompts
, and return its value if it is aWebDriver error
.- Set fakeDevice's
selected state
to init.selected
. - If init.
state
is present, set fakeDevice'sfake remote playback state
to init.state
. - Return
success
with data null.
HTTP Method | URI Template |
---|---|
DELETE | /session/{session id}/fakeremoteplayback/{name} |
The remove fake remote playback device
extension command
removes a given name of fake remote playback device
.
The remote end steps
are:
- Let name be a
url variable
. - If the
current browsing context
isno longer open
, return aWebDriver error
withWebDriver error code
no such window
. Handle any user prompts
, and return its value if it is aWebDriver error
.- If name is not equal to a
fake remote playback device
's name amongst all associatedfake remote playback devices
ofthe current browsing context
, return aWebDriver error
withWebDriver error code
no such fake remote playback device
. - Delete name of
fake remote playback device
in thecurrent browsing context
. - Return
success
with data null.
HTTP Method | URI Template |
---|---|
DELETE | /session/{session id}/fakeremoteplayback/ |
The remove all fake remote playback devices
extension command
removes all existing fake remote playback devices
.
The remote end steps
are:
- If the
current browsing context
isno longer open
, return aWebDriver error
withWebDriver error code
no such window
. Handle any user prompts
, and return its value if it is aWebDriver error
.- Delete all
fake remote playback devices
in thecurrent browsing context
. - Return
success
with data null.
This section extends the Errors
and defines extended WebDriver error codes
specific for fake remote playback device
in following table.
Error Code | HTTP Status | JSON Error Code | Description |
---|---|---|---|
no such fake remote playback device | 404 | no such fake remote playback device |
no fake remote playback device matching the given name was found. |
fake remote playback already exists | 500 | fake remote playback device already exists |
A command to add a fake remote playback device could not be satisfied because the given name of fake remote playback device is already existed. |
- Media element has a couple of playback state, which should be tested in remote playback?
// playback state
attribute double currentTime;
readonly attribute unrestricted double duration;
readonly attribute boolean paused;
attribute double defaultPlaybackRate;
attribute double playbackRate;
readonly attribute TimeRanges played;
readonly attribute TimeRanges seekable;
readonly attribute boolean ended;
[CEReactions] attribute boolean autoplay;
[CEReactions] attribute boolean loop;