summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/remote-playback
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/remote-playback
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--testing/web-platform/tests/remote-playback/META.yml4
-rw-r--r--testing/web-platform/tests/remote-playback/README.md14
-rw-r--r--testing/web-platform/tests/remote-playback/cancel-watch-availability.html44
-rw-r--r--testing/web-platform/tests/remote-playback/disable-remote-playback-cancel-watch-availability-throws.html29
-rw-r--r--testing/web-platform/tests/remote-playback/disable-remote-playback-prompt-throws.html16
-rw-r--r--testing/web-platform/tests/remote-playback/disable-remote-playback-watch-availability-throws.html17
-rw-r--r--testing/web-platform/tests/remote-playback/idlharness.window.js29
-rw-r--r--testing/web-platform/tests/remote-playback/prompt-in-detached-iframe.html17
-rw-r--r--testing/web-platform/tests/remote-playback/watch-availability-initial-callback.html22
9 files changed, 192 insertions, 0 deletions
diff --git a/testing/web-platform/tests/remote-playback/META.yml b/testing/web-platform/tests/remote-playback/META.yml
new file mode 100644
index 0000000000..a234398b8b
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/META.yml
@@ -0,0 +1,4 @@
+spec: https://w3c.github.io/remote-playback/
+suggested_reviewers:
+ - mfoltzgoogle
+ - louaybassbouss
diff --git a/testing/web-platform/tests/remote-playback/README.md b/testing/web-platform/tests/remote-playback/README.md
new file mode 100644
index 0000000000..b934227593
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/README.md
@@ -0,0 +1,14 @@
+# Remote Playback API specification Tests
+
+The Remote Playback API can be found here:
+
+GitHub repository: https://github.com/w3c/remote-playback/
+
+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.
diff --git a/testing/web-platform/tests/remote-playback/cancel-watch-availability.html b/testing/web-platform/tests/remote-playback/cancel-watch-availability.html
new file mode 100644
index 0000000000..d83c8cecb0
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/cancel-watch-availability.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<title>Tests various ways to call cancelWatchAvailability()</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/media.js"></script>
+<script>
+async_test(t => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+
+ v.remote.watchAvailability(function() {})
+ .then(t.step_func(id => {
+ v.remote.cancelWatchAvailability(id).then(t.step_func(function() {
+ v.remote.cancelWatchAvailability(id).then(
+ t.unreached_func(), t.step_func_done(e => {
+ assert_equals(e.name, 'NotFoundError');
+ })
+ );
+ }), t.unreached_func());
+ }), t.unreached_func());
+}, 'Test that calling cancelWatchAvailability() with an id does remove the callback.');
+
+async_test(t => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+
+ Promise.all([
+ v.remote.watchAvailability(function() {}),
+ v.remote.watchAvailability(function() {})
+ ]).then(t.step_func(ids => {
+ v.remote.cancelWatchAvailability().then(t.step_func(function() {
+ v.remote.cancelWatchAvailability(ids[0]).then(t.unreached_func(), t.step_func(function(e) {
+ assert_equals(e.name, 'NotFoundError');
+ v.remote.cancelWatchAvailability(ids[1])
+ .then(t.unreached_func(), t.step_func_done(function(e) {
+ assert_equals(e.name, 'NotFoundError');
+ }));
+ }));
+ }), t.unreached_func());
+ }), t.unreached_func());
+}, 'Test that calling cancelWatchAvailability() without an id removes all the callbacks.');
+</script>
+</html>
diff --git a/testing/web-platform/tests/remote-playback/disable-remote-playback-cancel-watch-availability-throws.html b/testing/web-platform/tests/remote-playback/disable-remote-playback-cancel-watch-availability-throws.html
new file mode 100644
index 0000000000..bdd35d8101
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/disable-remote-playback-cancel-watch-availability-throws.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<title>Test that calling cancelWatchAvailability() 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>
+async_test(t => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+
+ v.remote.watchAvailability(function() {})
+ .then(id => {
+ v.disableRemotePlayback = true;
+ v.remote.cancelWatchAvailability(id).then(
+ t.unreached_func(),
+ t.step_func(e => {
+ assert_equals(e.name, 'InvalidStateError');
+ v.remote.cancelWatchAvailability().then(
+ t.unreached_func(),
+ 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.');
+</script>
+</html>
diff --git a/testing/web-platform/tests/remote-playback/disable-remote-playback-prompt-throws.html b/testing/web-platform/tests/remote-playback/disable-remote-playback-prompt-throws.html
new file mode 100644
index 0000000000..18333842b6
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/disable-remote-playback-prompt-throws.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<title>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 => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+ v.disableRemotePlayback = true;
+
+ return promise_rejects_dom(t, 'InvalidStateError', v.remote.prompt());
+}, 'Test that calling prompt() when disableRemotePlayback attribute is set throws an exception.');
+</script>
+</html>
diff --git a/testing/web-platform/tests/remote-playback/disable-remote-playback-watch-availability-throws.html b/testing/web-platform/tests/remote-playback/disable-remote-playback-watch-availability-throws.html
new file mode 100644
index 0000000000..b671d9f944
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/disable-remote-playback-watch-availability-throws.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<title>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 => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+ v.disableRemotePlayback = true;
+
+ return promise_rejects_dom(t, 'InvalidStateError',
+ v.remote.watchAvailability(function() {}));
+}, 'Test that calling watchAvailability() when disableRemotePlayback attribute is set throws an exception.');
+</script>
+</html>
diff --git a/testing/web-platform/tests/remote-playback/idlharness.window.js b/testing/web-platform/tests/remote-playback/idlharness.window.js
new file mode 100644
index 0000000000..458bfd0c60
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/idlharness.window.js
@@ -0,0 +1,29 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+// META: script=/common/media.js
+// META: timeout=long
+
+'use strict';
+
+// https://w3c.github.io/remoteplayback/
+
+idl_test(
+ ['remote-playback'],
+ ['html', 'dom'],
+ idl_array => {
+ try {
+ const media = document.createElement('video');
+ media.src = getVideoURI('/media/movie_5');
+ media.width = media.height = 10;
+ document.body.appendChild(media);
+ self.media = media;
+ } catch (e) {
+ // Will be surfaced when media is undefined below.
+ }
+
+ idl_array.add_objects({
+ HTMLVideoElement: ['media'],
+ RemotePlayback: ['media.remote']
+ });
+ }
+);
diff --git a/testing/web-platform/tests/remote-playback/prompt-in-detached-iframe.html b/testing/web-platform/tests/remote-playback/prompt-in-detached-iframe.html
new file mode 100644
index 0000000000..501471755a
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/prompt-in-detached-iframe.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<body>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+promise_test(t => {
+ let i = document.createElement("iframe");
+ document.body.appendChild(i);
+ let audio = document.createElement("audio");
+ i.contentDocument.body.appendChild(audio);
+ let remote = audio.remote;
+ i.remove();
+ return promise_rejects_dom(t, "InvalidAccessError", remote.prompt());
+}, 'Calling remote.prompt() in a detached context should throw InvalidAccessError');
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/remote-playback/watch-availability-initial-callback.html b/testing/web-platform/tests/remote-playback/watch-availability-initial-callback.html
new file mode 100644
index 0000000000..352321b06a
--- /dev/null
+++ b/testing/web-platform/tests/remote-playback/watch-availability-initial-callback.html
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<title>Test that the callback is called once watchAvailability() resolves.</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="/common/media.js"></script>
+<script>
+async_test(t => {
+ var v = document.createElement('video');
+ v.src = getVideoURI('/media/movie_5');
+
+ var promiseResolved = false;
+
+ function callback(available) {
+ assert_true(promiseResolved);
+ }
+
+ v.remote.watchAvailability(t.step_func_done(callback)).then(
+ t.step_func(() => { promiseResolved = true; }), t.unreached_func());
+}, 'Test that the callback is called once watchAvailability() resolves.');
+</script>
+</html>