diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/document-picture-in-picture | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/document-picture-in-picture')
12 files changed, 219 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/WEB_FEATURES.yml b/testing/web-platform/tests/document-picture-in-picture/WEB_FEATURES.yml new file mode 100644 index 0000000000..cf364db88e --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/WEB_FEATURES.yml @@ -0,0 +1,3 @@ +features: +- name: document-picture-in-picture + files: "**" diff --git a/testing/web-platform/tests/document-picture-in-picture/beforeunload-is-disabled.https.html b/testing/web-platform/tests/document-picture-in-picture/beforeunload-is-disabled.https.html new file mode 100644 index 0000000000..35e3e2c547 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/beforeunload-is-disabled.https.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<title>Test that onbeforeunload is disabled for document picture in picture</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(); + var onbeforeunloadDisabled = true; + pipWindow.onbeforeunload = () => { + onbeforeunloadDisabled = false; + return "This is a test"; + } + pipWindow.close(); + assert_true(onbeforeunloadDisabled, 'onbeforeunload should be disabled for document picture in picture'); + }); + </script> +</body> 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/resize-requires-user-gesture.https.html b/testing/web-platform/tests/document-picture-in-picture/resize-requires-user-gesture.https.html new file mode 100644 index 0000000000..f6c4aa4989 --- /dev/null +++ b/testing/web-platform/tests/document-picture-in-picture/resize-requires-user-gesture.https.html @@ -0,0 +1,22 @@ +<!DOCTYPE html> +<title>Test that calling resizeTo() or resizeBy() on a document + picture-in-picture window requires user gesture</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 assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => { + pipWindow.resizeBy(10, 10); + }, 'resizeBy() requires a user gesture for document picture-in-picture'); + await assert_throws_dom('NotAllowedError', pipWindow.DOMException, () => { + pipWindow.resizeTo(400, 400); + }, 'resizeTo() requires a user gesture for document picture-in-picture'); +}); +</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> |