From 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:47:29 +0200 Subject: Adding upstream version 115.8.0esr. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/screen-details/META.yml | 1 + .../getScreenDetails.tentative.https.window.js | 63 ++++++++++++++++++++++ .../isExtended.tentative.https.window.js | 11 ++++ .../screen-details/permission.https.window.js | 20 +++++++ 4 files changed, 95 insertions(+) create mode 100644 testing/web-platform/tests/screen-details/META.yml create mode 100644 testing/web-platform/tests/screen-details/getScreenDetails.tentative.https.window.js create mode 100644 testing/web-platform/tests/screen-details/isExtended.tentative.https.window.js create mode 100644 testing/web-platform/tests/screen-details/permission.https.window.js (limited to 'testing/web-platform/tests/screen-details') diff --git a/testing/web-platform/tests/screen-details/META.yml b/testing/web-platform/tests/screen-details/META.yml new file mode 100644 index 0000000000..abfee89ffb --- /dev/null +++ b/testing/web-platform/tests/screen-details/META.yml @@ -0,0 +1 @@ +spec: https://webscreens.github.io/window-placement/ diff --git a/testing/web-platform/tests/screen-details/getScreenDetails.tentative.https.window.js b/testing/web-platform/tests/screen-details/getScreenDetails.tentative.https.window.js new file mode 100644 index 0000000000..06f0344f3a --- /dev/null +++ b/testing/web-platform/tests/screen-details/getScreenDetails.tentative.https.window.js @@ -0,0 +1,63 @@ +// META: global=window +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +'use strict'; + +promise_test(async t => { + assert_equals(typeof self.getScreenDetails, 'function'); +}, 'getScreenDetails() is present'); + +promise_test(async t => { + await test_driver.set_permission({name: 'window-management'}, 'granted'); + const screenDetails = await self.getScreenDetails(); + assert_true(ScreenDetails.prototype.isPrototypeOf(screenDetails)); + assert_true(ScreenDetailed.prototype.isPrototypeOf(screenDetails.currentScreen)); + assert_true(Array.prototype.isPrototypeOf(screenDetails.screens)); + assert_greater_than(screenDetails.screens.length, 0); + assert_true(ScreenDetailed.prototype.isPrototypeOf(screenDetails.screens[0])); + assert_true(screenDetails.screens.includes(screenDetails.currentScreen)); +}, 'getScreenDetails() returns the expected interface with permission granted'); + +promise_test(async t => { + await test_driver.set_permission({name: 'window-management'}, 'granted'); + assert_greater_than((await self.getScreenDetails()).screens.length, 0); + await test_driver.set_permission({name: 'window-management'}, 'denied'); + await promise_rejects_dom(t, 'NotAllowedError', self.getScreenDetails()); +}, 'getScreenDetails() rejects the promise with permission denied'); + +promise_test(async t => { + await test_driver.set_permission({name: 'window-management'}, 'granted'); + let iframe = document.body.appendChild(document.createElement('iframe')); + assert_greater_than((await iframe.contentWindow.getScreenDetails()).screens.length, 0); + + let iframeGetScreens; + let constructor; + await new Promise(resolve => { + iframe.contentWindow.onunload = () => { + // Grab these before the contentWindow is removed. + iframeGetScreens = iframe.contentWindow.getScreenDetails; + constructor = iframe.contentWindow.DOMException; + resolve(); + }; + document.body.removeChild(iframe); + }); + assert_not_equals(iframeGetScreens, undefined); + assert_not_equals(constructor, undefined); + + await t.step_wait(() => !iframe.contentWindow, 'execution context invalid'); + assert_equals(iframe.contentWindow, null); + await promise_rejects_dom(t, 'InvalidStateError', constructor, iframeGetScreens()); +}, 'getScreenDetails() resolves for attached iframe; rejects for detached iframe'); + +promise_test(async t => { + await test_driver.set_permission({name: 'window-management'}, 'granted'); + let iframe = document.body.appendChild(document.createElement('iframe')); + const screenDetails = await iframe.contentWindow.getScreenDetails(); + assert_greater_than(screenDetails.screens.length, 0); + assert_equals(screenDetails.currentScreen, screenDetails.screens[0]); + iframe.remove(); + await t.step_wait(() => !iframe.contentWindow, 'execution context invalid'); + assert_equals(iframe.contentWindow, null); + assert_equals(screenDetails.screens.length, 0); + assert_equals(screenDetails.currentScreen, null); +}, 'Cached ScreenDetails interface from detached iframe does not crash, behaves okay'); diff --git a/testing/web-platform/tests/screen-details/isExtended.tentative.https.window.js b/testing/web-platform/tests/screen-details/isExtended.tentative.https.window.js new file mode 100644 index 0000000000..3c814ae3d9 --- /dev/null +++ b/testing/web-platform/tests/screen-details/isExtended.tentative.https.window.js @@ -0,0 +1,11 @@ +// META: global=window +'use strict'; + +promise_test(async t => { + assert_equals(typeof self.screen.isExtended, 'boolean'); +}, 'screen.isExtended is present'); + +promise_test(async t => { + let iframe = document.body.appendChild(document.createElement('iframe')); + assert_equals(typeof iframe.contentWindow.screen.isExtended, 'boolean'); +}, 'screen.isExtended is present for attached iframes'); diff --git a/testing/web-platform/tests/screen-details/permission.https.window.js b/testing/web-platform/tests/screen-details/permission.https.window.js new file mode 100644 index 0000000000..f477bd4230 --- /dev/null +++ b/testing/web-platform/tests/screen-details/permission.https.window.js @@ -0,0 +1,20 @@ +// META: global=window +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +"use strict"; + +promise_test(async t => { + await test_driver.set_permission({ name: "window-management" }, "denied"); + + const status = await navigator.permissions.query({ name:"window-management" }); + assert_class_string(status, "PermissionStatus"); + assert_equals(status.state, "denied"); +}, "Deny window management permission should work."); + +promise_test(async t => { + await test_driver.set_permission({ name: "window-management" }, "granted"); + + const status = await navigator.permissions.query({ name: "window-management" }); + assert_class_string(status, "PermissionStatus"); + assert_equals(status.state, "granted"); +}, "Grant window management permission should work."); -- cgit v1.2.3