summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html
parentInitial commit. (diff)
downloadfirefox-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/screen-capture/getdisplaymedia-framerate.https.html')
-rw-r--r--testing/web-platform/tests/screen-capture/getdisplaymedia-framerate.https.html42
1 files changed, 42 insertions, 0 deletions
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 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>getDisplayMedia</title>
+<meta name="timeout" content="long">
+<button id="button">User gesture</button>
+<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>
+<video id="display"></video>
+<script>
+ 'use strict';
+
+const stopTracks = stream => stream.getTracks().forEach(track => track.stop());
+
+async function getDisplayMedia(constraints) {
+ const p = new Promise(r => button.onclick = r);
+ await test_driver.click(button);
+ await p;
+ return navigator.mediaDevices.getDisplayMedia(constraints);
+}
+
+promise_test( async t => {
+ const v = document.getElementById('display');
+ v.autoplay = true;
+ // work around firefox bug 1586505, orthogonal to what's being tested
+ const frames = () => v.mozPaintedFrames ?? v.getVideoPlaybackQuality()?.totalVideoFrames;
+ const target_rate = 5;
+ const stream = await getDisplayMedia({video: {width:160, frameRate: target_rate}});
+ t.add_cleanup(() => stopTracks(stream));
+ v.srcObject = stream;
+ const intitial_time = v.currentTime;
+ const initial_frame_count = frames();
+ await new Promise(r => t.step_timeout(r, 10000));
+ const total_elapsed_frames = frames() - initial_frame_count;
+ const total_elapsed_time = v.currentTime - intitial_time;
+ const average_fps = total_elapsed_frames / total_elapsed_time;
+ assert_greater_than_equal(average_fps, target_rate * 0.50);
+ assert_less_than_equal(average_fps, target_rate * 1.75);
+}, "getDisplayMedia() must adhere to frameRate if set");
+
+</script>