From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/screen-capture/META.yml | 7 + .../screen-capture/delegate-request.https.sub.html | 80 ++++++ .../getdisplaymedia-after-discard.https.html | 45 ++++ ...displaymedia-capture-controller.https.window.js | 201 +++++++++++++++ .../getdisplaymedia-framerate.https.html | 42 ++++ .../screen-capture/getdisplaymedia.https.html | 279 +++++++++++++++++++++ .../tests/screen-capture/historical.https.html | 10 + .../screen-capture/idlharness.https.window.js | 16 ++ .../permissions-policy-audio+video.https.sub.html | 48 ++++ .../permissions-policy-audio.https.sub.html | 48 ++++ .../permissions-policy-video.https.sub.html | 48 ++++ .../resources/delegate-request-subframe.sub.html | 22 ++ 12 files changed, 846 insertions(+) create mode 100644 testing/web-platform/tests/screen-capture/META.yml create mode 100644 testing/web-platform/tests/screen-capture/delegate-request.https.sub.html create mode 100644 testing/web-platform/tests/screen-capture/getdisplaymedia-after-discard.https.html create mode 100644 testing/web-platform/tests/screen-capture/getdisplaymedia-capture-controller.https.window.js create mode 100644 testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html create mode 100644 testing/web-platform/tests/screen-capture/getdisplaymedia.https.html create mode 100644 testing/web-platform/tests/screen-capture/historical.https.html create mode 100644 testing/web-platform/tests/screen-capture/idlharness.https.window.js create mode 100644 testing/web-platform/tests/screen-capture/permissions-policy-audio+video.https.sub.html create mode 100644 testing/web-platform/tests/screen-capture/permissions-policy-audio.https.sub.html create mode 100644 testing/web-platform/tests/screen-capture/permissions-policy-video.https.sub.html create mode 100644 testing/web-platform/tests/screen-capture/resources/delegate-request-subframe.sub.html (limited to 'testing/web-platform/tests/screen-capture') diff --git a/testing/web-platform/tests/screen-capture/META.yml b/testing/web-platform/tests/screen-capture/META.yml new file mode 100644 index 0000000000..6fbb899ac3 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/META.yml @@ -0,0 +1,7 @@ +spec: https://w3c.github.io/mediacapture-screen-share/ +suggested_reviewers: + - alvestrand + - martinthomson + - uysalere + - jan-ivar + - eladalon1983 diff --git a/testing/web-platform/tests/screen-capture/delegate-request.https.sub.html b/testing/web-platform/tests/screen-capture/delegate-request.https.sub.html new file mode 100644 index 0000000000..8cc81c1383 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/delegate-request.https.sub.html @@ -0,0 +1,80 @@ + +Display-capture request delegation test + + + + + + +
+ Verifies that getDisplayMedia() calls from a cross-origin subframe without user activation + works if and only if the top frame has user activation and it delegates the capability to the + subframe. +
+ + + + diff --git a/testing/web-platform/tests/screen-capture/getdisplaymedia-after-discard.https.html b/testing/web-platform/tests/screen-capture/getdisplaymedia-after-discard.https.html new file mode 100644 index 0000000000..445120f8c2 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/getdisplaymedia-after-discard.https.html @@ -0,0 +1,45 @@ + +Test for rejected promise from getDisplayMedia() in a discarded browsing + context + + + + + + diff --git a/testing/web-platform/tests/screen-capture/getdisplaymedia-capture-controller.https.window.js b/testing/web-platform/tests/screen-capture/getdisplaymedia-capture-controller.https.window.js new file mode 100644 index 0000000000..fa1fd84b36 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/getdisplaymedia-capture-controller.https.window.js @@ -0,0 +1,201 @@ +// META: script=/resources/testdriver.js +// META: script=/resources/testdriver-vendor.js +// META: timeout=long + +'use strict'; + +const validFocusBehaviors = ['focus-captured-surface', 'no-focus-change']; +const validDisplaySurfaces = ['window', 'browser']; + +test(() => { + assert_own_property(window, 'CaptureController'); +}, 'CaptureController in window'); + +const stopTracks = stream => stream.getTracks().forEach(track => track.stop()); + +validFocusBehaviors.forEach( + (focusBehavior) => test( + (t) => { + const controller = new CaptureController(); + controller.setFocusBehavior(focusBehavior); + }, + `setFocusBehavior("${ + focusBehavior}") must succeed before capture starts`)); + +['invalid', null, undefined, {}, true].forEach( + (focusBehavior) => test( + () => { + const controller = new CaptureController(); + assert_throws_js( + TypeError, () => controller.setFocusBehavior(focusBehavior)); + }, + `setFocusBehavior("${ + focusBehavior}") must throw TypeError if focusBehavior is invalid`)); + +promise_test(async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia({controller}); + t.add_cleanup(() => stopTracks(stream)); + assert_equals(stream.getTracks().length, 1); + assert_equals(stream.getVideoTracks().length, 1); + assert_equals(stream.getAudioTracks().length, 0); +}, 'getDisplayMedia({controller}) must succeed'); + +['invalid', null, {}, true].forEach( + (controller) => promise_test( + async (t) => { + await test_driver.bless('getDisplayMedia()'); + await promise_rejects_js( + t, TypeError, + navigator.mediaDevices.getDisplayMedia({controller})); + }, + `getDisplayMedia({controller: ${ + controller}}) must fail with TypeError`)); + +promise_test(async (t) => { + const controller = new CaptureController(); + + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia({controller}); + t.add_cleanup(() => stopTracks(stream)); + + await test_driver.bless('getDisplayMedia()'); + const p = navigator.mediaDevices.getDisplayMedia({controller}); + t.add_cleanup(async () => { + try { + stopTracks(await p); + } catch { + } + }); + await promise_rejects_dom( + t, 'InvalidStateError', Promise.race([p, Promise.resolve()]), + 'getDisplayMedia should have returned an already-rejected promise.'); +}, 'getDisplayMedia({controller}) must fail with InvalidStateError if controller is bound'); + +validDisplaySurfaces.forEach((displaySurface) => { + validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface}}); + t.add_cleanup(() => stopTracks(stream)); + controller.setFocusBehavior(focusBehavior); + }, + `setFocusBehavior("${ + focusBehavior}") must succeed when window of opportunity is opened if capturing a ${ + displaySurface}`)); +}); + +validDisplaySurfaces.forEach((displaySurface) => { + validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const p = navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface}}); + controller.setFocusBehavior(focusBehavior); + const stream = await p; + t.add_cleanup(() => stopTracks(stream)); + }, + `setFocusBehavior("${ + focusBehavior}") must succeed when getDisplayMedia promise is pending if capturing a ${ + displaySurface}`)); +}); + +validDisplaySurfaces.forEach((displaySurface) => { + validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface}}); + stopTracks(stream); + assert_throws_dom( + 'InvalidStateError', + () => controller.setFocusBehavior(focusBehavior)); + }, + `setFocusBehavior("${ + focusBehavior}") must throw InvalidStateError when track is stopped if capturing a ${ + displaySurface}`)); +}); + +validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface: 'monitor'}}); + t.add_cleanup(() => stopTracks(stream)); + assert_throws_dom( + 'InvalidStateError', + () => controller.setFocusBehavior(focusBehavior)); + }, + `setFocusBehavior("${ + focusBehavior}") must throw InvalidStateError if capturing a monitor`)); + +validDisplaySurfaces.forEach((displaySurface) => { + validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface}}); + t.add_cleanup(() => stopTracks(stream)); + await new Promise((resolve) => step_timeout(resolve, 0)); + assert_throws_dom( + 'InvalidStateError', + () => controller.setFocusBehavior(focusBehavior)); + }, + `setFocusBehavior("${ + focusBehavior}") must throw InvalidStateError when window of opportunity is closed if capturing a ${ + displaySurface}`)); +}); + +validDisplaySurfaces.forEach((displaySurface) => { + validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + await test_driver.bless('getDisplayMedia()'); + const stream = await navigator.mediaDevices.getDisplayMedia( + {controller, video: {displaySurface}}); + t.add_cleanup(() => stopTracks(stream)); + controller.setFocusBehavior(focusBehavior) + assert_throws_dom( + 'InvalidStateError', + () => controller.setFocusBehavior(focusBehavior)); + }, + `setFocusBehavior("${ + focusBehavior}") must throw InvalidStateError the second time if capturing a ${ + displaySurface}`)); +}); + +validFocusBehaviors.forEach( + (focusBehavior) => promise_test( + async (t) => { + const controller = new CaptureController(); + const options = { + controller: controller, + video: {width: {max: 0}}, + } + try { + await test_driver.bless('getDisplayMedia()'); + stopTracks(await navigator.mediaDevices.getDisplayMedia(options)); + } catch (err) { + assert_equals(err.name, 'OverconstrainedError', err.message); + assert_throws_dom( + 'InvalidStateError', + () => controller.setFocusBehavior(focusBehavior)); + return; + } + assert_unreached('getDisplayMedia should have failed'); + }, + `setFocusBehavior("${ + focusBehavior}") must throw InvalidStateError if getDisplayMedia fails`)); diff --git a/testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html b/testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html new file mode 100644 index 0000000000..c17b25d987 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html @@ -0,0 +1,42 @@ + + +getDisplayMedia + + + + + + + + diff --git a/testing/web-platform/tests/screen-capture/getdisplaymedia.https.html b/testing/web-platform/tests/screen-capture/getdisplaymedia.https.html new file mode 100644 index 0000000000..095b98dea4 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/getdisplaymedia.https.html @@ -0,0 +1,279 @@ + + +getDisplayMedia + + + + + + + diff --git a/testing/web-platform/tests/screen-capture/historical.https.html b/testing/web-platform/tests/screen-capture/historical.https.html new file mode 100644 index 0000000000..d510bc4208 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/historical.https.html @@ -0,0 +1,10 @@ + + +getDisplayMedia historical tests + + + diff --git a/testing/web-platform/tests/screen-capture/idlharness.https.window.js b/testing/web-platform/tests/screen-capture/idlharness.https.window.js new file mode 100644 index 0000000000..527565ea96 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/idlharness.https.window.js @@ -0,0 +1,16 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +'use strict'; + +// https://w3c.github.io/mediacapture-screen-share/ + +idl_test( + ['screen-capture'], + ['mediacapture-streams', 'html', 'dom'], + idl_array => { + idl_array.add_objects({ + MediaDevices: ['navigator.mediaDevices'], + }); + } +); diff --git a/testing/web-platform/tests/screen-capture/permissions-policy-audio+video.https.sub.html b/testing/web-platform/tests/screen-capture/permissions-policy-audio+video.https.sub.html new file mode 100644 index 0000000000..2e7df39125 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/permissions-policy-audio+video.https.sub.html @@ -0,0 +1,48 @@ + + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-capture/permissions-policy-audio.https.sub.html b/testing/web-platform/tests/screen-capture/permissions-policy-audio.https.sub.html new file mode 100644 index 0000000000..7bfc33f861 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/permissions-policy-audio.https.sub.html @@ -0,0 +1,48 @@ + + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-capture/permissions-policy-video.https.sub.html b/testing/web-platform/tests/screen-capture/permissions-policy-video.https.sub.html new file mode 100644 index 0000000000..6740466ef2 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/permissions-policy-video.https.sub.html @@ -0,0 +1,48 @@ + + + + + + + + + + + diff --git a/testing/web-platform/tests/screen-capture/resources/delegate-request-subframe.sub.html b/testing/web-platform/tests/screen-capture/resources/delegate-request-subframe.sub.html new file mode 100644 index 0000000000..2b3295bc20 --- /dev/null +++ b/testing/web-platform/tests/screen-capture/resources/delegate-request-subframe.sub.html @@ -0,0 +1,22 @@ + +Display-capture request delegation test: subframe + + -- cgit v1.2.3