Skip to content

Commit

Permalink
[remote-playback] Editorial improvements to text and code (#41852)
Browse files Browse the repository at this point in the history
  • Loading branch information
markafoltz authored and OrKoN committed Sep 18, 2023
1 parent 5f31090 commit 119e077
Show file tree
Hide file tree
Showing 19 changed files with 77 additions and 76 deletions.
14 changes: 10 additions & 4 deletions remote-playback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ File an issue: https://github.com/w3c/remote-playback/issues/new

## Hardware/network dependency

The Remote Playback API requires to communicate with a device over the network.
Some behavior would require a real devices to be implemented. In order to keep
these tests automated, only behaviors that can be run without user gesture or
specific configurations are available here.
The Remote Playback API requires communication with a device over the network.
Tests that end in `-manual.html` require a compatible device available on the
local area network to run the tests; these tests must be run manually.

Known browser/device combinations that can be used to run manual tests:

| Browser | Device |
| ------- | ------ |
| Chrome for Android | [Chromecast](https://store.google.com/product/chromecast_google_tv?pli=1&hl=en-US) |
| Safari | Apple TV |
20 changes: 10 additions & 10 deletions remote-playback/cancel-watch-availability.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<!DOCTYPE html>
<html>
<title>Tests various ways to call cancelWatchAvailability()</title>
<title>Tests cancelWatchAvailability()</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<script>
async_test((t) => {
async_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

v.remote
.watchAvailability(() => {})
.then(
t.step_func((id) => {
t.step_func(id => {
v.remote.cancelWatchAvailability(id).then(
t.step_func(() => {
v.remote.cancelWatchAvailability(id).then(
t.unreached_func(),
t.step_func_done((e) => {
t.step_func_done(e => {
assert_equals(e.name, "NotFoundError");
})
);
Expand All @@ -27,26 +27,26 @@
}),
t.unreached_func()
);
}, "Test that calling cancelWatchAvailability() with an id does remove the callback.");
}, "Test that calling cancelWatchAvailability() with an id does remove the callback, and calling cancelWatchAvailability with a removed id throws NotFoundError.");

async_test((t) => {
async_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

Promise.all([
v.remote.watchAvailability(() => {}),
v.remote.watchAvailability(() => {}),
]).then(
t.step_func((ids) =>
t.step_func(ids =>
v.remote.cancelWatchAvailability().then(
t.step_func(() =>
v.remote.cancelWatchAvailability(ids[0]).then(
t.unreached_func(),
t.step_func((e) => {
t.step_func(e => {
assert_equals(e.name, "NotFoundError");
v.remote.cancelWatchAvailability(ids[1]).then(
t.unreached_func(),
t.step_func_done((e) =>
t.step_func_done(e =>
assert_equals(e.name, "NotFoundError")
)
);
Expand All @@ -58,6 +58,6 @@
),
t.unreached_func()
);
}, "Test that calling cancelWatchAvailability() without an id removes all the callbacks.");
}, "Test that calling cancelWatchAvailability() without an id removes all the callbacks, and calling cancelWatchAvailability() with a removed id throws NotFoundError.");
</script>
</html>
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
<!DOCTYPE html>
<html>
<title>
Test that calling cancelWatchAvailability() when disableRemotePlayback
attribute is set throws an exception
Test that calling cancelWatchAvailability() when disableRemotePlayback attribute is set throws InvalidStateError
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<script>
async_test((t) => {
async_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

v.remote
.watchAvailability(() => {})
.then((id) => {
.then(id => {
v.disableRemotePlayback = true;
v.remote.cancelWatchAvailability(id).then(
t.unreached_func(),
t.step_func((e) => {
t.step_func(e => {
assert_equals(e.name, "InvalidStateError");
v.remote.cancelWatchAvailability().then(
t.unreached_func(),
t.step_func_done((e) => {
t.step_func_done(e => {
assert_equals(e.name, "InvalidStateError");
})
);
})
);
}, t.unreached_func());
}, "Test that calling cancelWatchAvailability() when disableRemotePlayback attribute is set throws an exception.");
}, "Test that calling cancelWatchAvailability() when disableRemotePlayback attribute is set throws InvalidStateError.");
</script>
</html>
5 changes: 2 additions & 3 deletions remote-playback/disable-remote-playback-prompt-throws.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<!DOCTYPE html>
<html>
<title>
Test that calling prompt() when disableRemotePlayback attribute is set
throws an exception
Test that calling prompt() when disableRemotePlayback attribute is set throws an exception
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<script>
promise_test((t) => {
promise_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");
v.disableRemotePlayback = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<!DOCTYPE html>
<html>
<title>
Test that calling watchAvailability() when disableRemotePlayback attribute
is set throws an exception
Test that calling watchAvailability() when disableRemotePlayback attribute is set throws an exception
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
<script>
promise_test((t) => {
promise_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");
v.disableRemotePlayback = true;
Expand Down
8 changes: 5 additions & 3 deletions remote-playback/event-handlers-manual.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<!DOCTYPE html>
<html>
<title>Test that all event handlers are called.</title>
<title>
Test that all event handlers are called when a remote playback device is connected
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
Expand Down Expand Up @@ -30,7 +32,7 @@
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

async_test((t) => {
async_test(t => {
let onConnectingCalled = false;
let onConnectCalled = false;
let onDisconnectCalled = false;
Expand All @@ -55,6 +57,6 @@
assert_true(onDisconnectCalled, "ondisconnect was called");
})
);
}, "Test that all event handlers are called.");
}, "Test that all event handlers are called when a remote playback device is connected.");
</script>
</html>
6 changes: 2 additions & 4 deletions remote-playback/prepare-device.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
var startButton = document.getElementById("start-button");
startButton.onclick = function () {
document.getElementById("start-button").onclick = () => {
document.getElementById("prep").style.display = "none";
document.getElementById("pick-device").style.display = "block";
};
var promptPrepButton = document.getElementById("prompt-button-prep");
promptPrepButton.onclick = function () {
document.getElementById("prompt-button-prep").onclick = () => {
v.remote
.prompt()
.then(() => {})
Expand Down
8 changes: 4 additions & 4 deletions remote-playback/prompt-and-cancel-selection-manual.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<title>
Test that promise is rejected when user cancels device selection.
Test that the Promise returned by prompt() is rejected when user cancels device selection
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -17,7 +17,7 @@
<button id="prompt-button">Pick device</button>
</body>
<script>
async_test((t) => {
async_test(t => {
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

Expand All @@ -27,11 +27,11 @@
.prompt()
.then(t.unreached_func())
.catch(
t.step_func_done((error) =>
t.step_func_done(error =>
assert_equals(error.name, "NotAllowedError")
)
)
);
}, "Test that promise is rejected when user cancels device selection.");
}, "Test that the Promise returned by prompt() is rejected when user cancels device selection.");
</script>
</html>
6 changes: 3 additions & 3 deletions remote-playback/prompt-and-select-device-manual.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<title>Test that promise is resolved when user selects a device.</title>
<title>Test that the Promise returned by prompt() is resolved when user selects a device</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
Expand All @@ -26,13 +26,13 @@
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

async_test((t) => {
async_test(t => {
let button = document.getElementById("prompt-button");
button.onclick = t.step_func_done(() => {
promise_test(() => {
return v.remote.prompt();
}, "Prompt resolves");
});
}, "Test that promise is resolved when user selects a device.");
}, "Test that the Promise returned by prompt() is resolved when user selects a device.");
</script>
</html>
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<!DOCTYPE html>
<html>
<title>
Test that watchAvailability returned false when there is no device for the
user to select.
Test that watchAvailability() runs the callback with false when there is no device for the user to select
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -29,12 +28,12 @@
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

async_test((t) => {
async_test(t => {
let deviceAvailable = false;
let button = document.getElementById("prompt-button");
button.onclick = function () {
v.remote
.watchAvailability(t.step_func((avail) => (deviceAvailable = avail)))
.watchAvailability(t.step_func(avail => (deviceAvailable = avail)))
.then(
t.step_func(() => {
promise_rejects_js(t, NotFoundError, v.remote.prompt());
Expand All @@ -43,6 +42,6 @@
t.unreached_func()
);
};
}, "Test that watchAvailability returned false when there is no device for the user to select.");
}, "Test that watchAvailability() runs the callback with false when there is no device for the user to select.");
</script>
</html>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<title>
Test that watchAvailability returned true when user selects device.
Test that watchAvailability() runs the callback with true when user selects a device
</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -28,12 +28,12 @@
let v = document.createElement("video");
v.src = getVideoURI("/media/movie_5");

async_test((t) => {
async_test(t => {
let deviceAvailable = false;
let button = document.getElementById("prompt-button");
button.onclick = () => {
v.remote
.watchAvailability(t.step_func((avail) => (deviceAvailable = avail)))
.watchAvailability(t.step_func(avail => (deviceAvailable = avail)))
.then(
t.step_func(() => {
v.remote
Expand All @@ -51,6 +51,6 @@
t.unreached_func()
);
};
}, "Test that watchAvailability returned true when user selects device.");
}, "Test that watchAvailability() runs the callback with true when user selects a device.");
</script>
</html>
8 changes: 4 additions & 4 deletions remote-playback/remote-video-control-pausing-manual.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="styles.css" />
<title>Test that pause() on the local video is reflected on the remote device.</title>
<title>Test that pause() on the local video is reflected on the remote device</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
Expand Down Expand Up @@ -36,7 +36,7 @@
<script>
let v = document.getElementById("video");

async_test((t) => {
async_test(t => {
let button = document.getElementById("prompt-button");
button.onclick = t.step_func(() => {
promise_test(() => {
Expand All @@ -58,7 +58,7 @@
}
};

let evaluate = (success) =>
let evaluate = success =>
assert_true(success, "Video paused and has correct play position.");

document.getElementById("yes").onclick = t.step_func_done(() =>
Expand All @@ -67,6 +67,6 @@
document.getElementById("no").onclick = t.step_func_done(() =>
evaluate(false)
);
}, "Test if video is playing on remote device.");
}, "Test that pause() on the local video is reflected on the remote device.");
</script>
</html>
8 changes: 4 additions & 4 deletions remote-playback/remote-video-control-seek-manual.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="styles.css" />
<title>Test that seek() on the local video is reflected on the remote device.</title>
<title>Test that seek() on the local video is reflected on the remote device</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/media.js"></script>
Expand Down Expand Up @@ -39,7 +39,7 @@
<script>
let v = document.getElementById("video");

async_test((t) => {
async_test(t => {
let button = document.getElementById("prompt-button");
button.onclick = t.step_func(() => {
promise_test(() => {
Expand All @@ -64,7 +64,7 @@
}
};

let evaluate = (success) =>
let evaluate = success =>
assert_true(success, "Video paused and has correct play position.");

document.getElementById("yes").onclick = t.step_func_done(() =>
Expand All @@ -73,6 +73,6 @@
document.getElementById("no").onclick = t.step_func_done(() =>
evaluate(false)
);
}, "Test if video is playing on remote device.");
}, "Test that seek() on the local video is reflected on the remote device.");
</script>
</html>
Loading

0 comments on commit 119e077

Please sign in to comment.