diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/document-picture-in-picture | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/document-picture-in-picture')
9 files changed, 172 insertions, 0 deletions
diff --git a/testing/web-platform/tests/document-picture-in-picture/META.yml b/testing/web-platform/tests/document-picture-in-picture/META.yml new file mode 100644 index 0000000000..879c08803e --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/META.yml @@ -0,0 +1,5 @@ +spec: https://wicg.github.io/document-picture-in-picture/ +suggested_reviewers: + - steimel + - liberato + - beaufortfrancois diff --git a/testing/web-platform/tests/document-picture-in-picture/clears-session-on-close.https.html b/testing/web-platform/tests/document-picture-in-picture/clears-session-on-close.https.html new file mode 100644 index 0000000000..8b1d549dc3 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/clears-session-on-close.https.html @@ -0,0 +1,27 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture.window + is cleared when the PiP window in closed.</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +async_test((t) => { + test_driver.bless('request PiP window').then(t.step_func(_ => { + documentPictureInPicture.requestWindow().then( () => { + const pipWindow = documentPictureInPicture.window; + assert_true(!!pipWindow, "pipWindow should exist with PiP is opened"); + pipWindow.addEventListener('unload', () => { + // `window` is still set until event processing is complete. + scheduler.postTask(t.step_func_done( () => { + assert_true(!documentPictureInPicture.window, + "window should be cleared when PiP is closed"); + })) + }); + pipWindow.close(); + }); + })); +}); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/enter-event.https.html b/testing/web-platform/tests/document-picture-in-picture/enter-event.https.html new file mode 100644 index 0000000000..1cac0ff22d --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/enter-event.https.html @@ -0,0 +1,17 @@ +<!DOCTYPE html> +<title>Test that enter event is fired at documentPictureInPicture + when the PiP window in opened.</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +async_test((t) => { + test_driver.bless('request PiP window').then(t.step_func(_ => { + documentPictureInPicture.onenter = t.step_func_done(); + documentPictureInPicture.requestWindow(); + })); +}); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/iframe-document-pip.https.html b/testing/web-platform/tests/document-picture-in-picture/iframe-document-pip.https.html new file mode 100644 index 0000000000..b978a2d4e6 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/iframe-document-pip.https.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<title>Test that document pip is not allowed in iframes.</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> + <iframe></iframe> +</body> +<script> +promise_test(t => { + const frame = document.querySelector('iframe'); + const frameDOMException = frame.contentWindow.DOMException; + return test_driver.bless('request PiP window from iframe', frame.contentWindow).then(t.step_func(_ => { + return promise_rejects_dom(t, 'NotAllowedError', frameDOMException, + frame.contentWindow.documentPictureInPicture.requestWindow()); + })); +}); +</script> diff --git a/testing/web-platform/tests/document-picture-in-picture/open-pip-window-from-pip-window.https.html b/testing/web-platform/tests/document-picture-in-picture/open-pip-window-from-pip-window.https.html new file mode 100644 index 0000000000..2c5d1170af --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/open-pip-window-from-pip-window.https.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture.requestWindow() + rejects from a PiP window</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +promise_test(async (t) => { + await test_driver.bless('request PiP window from top window'); + const pipWindow = await documentPictureInPicture.requestWindow(); + + await test_driver.bless('request PiP window from PiP window', pipWindow); + await promise_rejects_dom(t, 'NotAllowedError', pipWindow.DOMException, + pipWindow.documentPictureInPicture.requestWindow()); +}); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/requires-secure-context.html b/testing/web-platform/tests/document-picture-in-picture/requires-secure-context.html new file mode 100644 index 0000000000..494bc2ae75 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/requires-secure-context.html @@ -0,0 +1,12 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture is not available in insecure contexts</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> +<script> +test(() => { + assert_equals(undefined, window.documentPictureInPicture); +}, + "documentPictureInPicture should not be available in insecure contexts"); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/requires-user-gesture.https.html b/testing/web-platform/tests/document-picture-in-picture/requires-user-gesture.https.html new file mode 100644 index 0000000000..01a141849e --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/requires-user-gesture.https.html @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture.requestWindow() + fails without a user gesture</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<body> +<script> +promise_test(t => { + return promise_rejects_dom(t, 'NotAllowedError', + documentPictureInPicture.requestWindow()); +}, + "requestWindow should fail without a user gesture"); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/requires-width-and-height-to-both-be-specified.https.html b/testing/web-platform/tests/document-picture-in-picture/requires-width-and-height-to-both-be-specified.https.html new file mode 100644 index 0000000000..0c707c668e --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/requires-width-and-height-to-both-be-specified.https.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture.requestWindow() + fails if width or height is specified without the other</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> +<script> +promise_test(async t => { + await test_driver.bless('request PiP window'); + await promise_rejects_js(t, RangeError, +documentPictureInPicture.requestWindow({width: 500})); +}, + "requestWindow should fail when width is specified without height"); + +promise_test(async t => { + await test_driver.bless('request PiP window'); + await promise_rejects_js(t, RangeError, +documentPictureInPicture.requestWindow({height: 300})); +}, + "requestWindow should fail when height is specified without width"); +</script> +</body> diff --git a/testing/web-platform/tests/document-picture-in-picture/returns-window-with-document.https.html b/testing/web-platform/tests/document-picture-in-picture/returns-window-with-document.https.html new file mode 100644 index 0000000000..a1d7363e54 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/returns-window-with-document.https.html @@ -0,0 +1,35 @@ +<!DOCTYPE html> +<title>Test that documentPictureInPicture.requestWindow() + returns a Window object</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<body> + <div id="div"></div> +<script> +const div = document.getElementById('div'); + +async_test((t) => { + test_driver.bless('request PiP window').then(t.step_func(_ => { + documentPictureInPicture.requestWindow().then(t.step_func_done((pipWindow) => { + assert_true(!!pipWindow.document, + 'Window should contain a document'); + assert_true(documentPictureInPicture.window === pipWindow, + 'DocumentPictureInPicture.window should match the current window'); + + // We should be able to move an element to that document. + assert_true(document.body.contains(div), + 'The original document should start with the div'); + assert_false(pipWindow.document.body.contains(div), + 'The PiP document should not start with the div'); + pipWindow.document.body.append(div); + assert_false(document.body.contains(div), + 'The div should have moved away from the original document'); + assert_true(pipWindow.document.body.contains(div), + 'The div should have moved to the PiP document'); + })); + })); +}); +</script> +</body> |