diff --git a/screen-capture/getdisplaymedia.https.html b/screen-capture/getdisplaymedia.https.html index 33e70acacbf6a3..69b47474be0192 100644 --- a/screen-capture/getdisplaymedia.https.html +++ b/screen-capture/getdisplaymedia.https.html @@ -218,4 +218,35 @@ }, property + " is supported"); }); } + +[ + {video: {displaySurface: "monitor"}}, + {video: {displaySurface: "window"}}, + {video: {displaySurface: "browser"}}, + {selfBrowserSurface: "include"}, + {selfBrowserSurface: "exclude"}, + {surfaceSwitching: "include"}, + {surfaceSwitching: "exclude"}, + {systemAudio: "include"}, + {systemAudio: "exclude"}, +].forEach(constraints => promise_test(async t => { + const stream = await getDisplayMedia(constraints); + t.add_cleanup(() => stopTracks(stream)); +}, `getDisplayMedia(${j(constraints)}) must succeed`)); + +[ + {selfBrowserSurface: "invalid"}, + {surfaceSwitching: "invalid"}, + {systemAudio: "invalid"}, +].forEach(constraints => promise_test(async t => { + await test_driver.bless('getDisplayMedia()'); + const p = navigator.mediaDevices.getDisplayMedia(constraints); + t.add_cleanup(async () => { + try { stopTracks(await p) } catch {} + }); + await promise_rejects_js( + t, TypeError, Promise.race([p, Promise.resolve()]), + 'getDisplayMedia should have returned an already-rejected promise.'); +}, `getDisplayMedia(${j(constraints)}) must fail with TypeError`)); +