summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/mediacapture-image/resources
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/mediacapture-image/resources
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/mediacapture-image/resources')
-rw-r--r--testing/web-platform/tests/mediacapture-image/resources/imagecapture-helpers.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/mediacapture-image/resources/imagecapture-helpers.js b/testing/web-platform/tests/mediacapture-image/resources/imagecapture-helpers.js
new file mode 100644
index 0000000000..8f142cff41
--- /dev/null
+++ b/testing/web-platform/tests/mediacapture-image/resources/imagecapture-helpers.js
@@ -0,0 +1,55 @@
+'use strict';
+
+// These tests rely on the User Agent providing an implementation of
+// platform image capture backends.
+//
+// In Chromium-based browsers this implementation is provided by a polyfill
+// in order to reduce the amount of test-only code shipped to users. To enable
+// these tests the browser must be run with these options:
+//
+// --enable-blink-features=MojoJS,MojoJSTest
+
+async function loadChromiumResources() {
+ await import('/resources/chromium/mock-imagecapture.js');
+}
+
+async function initialize_image_capture_tests() {
+ if (typeof ImageCaptureTest === 'undefined') {
+ const script = document.createElement('script');
+ script.src = '/resources/test-only-api.js';
+ script.async = false;
+ const p = new Promise((resolve, reject) => {
+ script.onload = () => { resolve(); };
+ script.onerror = e => { reject(e); };
+ })
+ document.head.appendChild(script);
+ await p;
+
+ if (isChromiumBased) {
+ await loadChromiumResources();
+ }
+ }
+ assert_implements(ImageCaptureTest, 'ImageCaptureTest is unavailable');
+ let imageCaptureTest = new ImageCaptureTest();
+ await imageCaptureTest.initialize();
+ return imageCaptureTest;
+}
+
+function image_capture_test(func, name, properties) {
+ promise_test(async (t) => {
+ let imageCaptureTest = await initialize_image_capture_tests();
+ try {
+ await func(t, imageCaptureTest);
+ } finally {
+ await imageCaptureTest.reset();
+ };
+ }, name, properties);
+}
+
+function assert_point2d_array_approx_equals(actual, expected, epsilon) {
+ assert_equals(actual.length, expected.length, 'length');
+ for (var i = 0; i < actual.length; ++i) {
+ assert_approx_equals(actual[i].x, expected[i].x, epsilon, 'x');
+ assert_approx_equals(actual[i].y, expected[i].y, epsilon, 'y');
+ }
+}