summaryrefslogtreecommitdiffstats
path: root/dom/media/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /dom/media/test
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/test')
-rw-r--r--dom/media/test/complete_length_worker.js80
-rw-r--r--dom/media/test/mochitest.toml4
-rw-r--r--dom/media/test/rdd_process_xpcom/RddProcessTest.cpp3
-rw-r--r--dom/media/test/reftest/reftest.list2
-rw-r--r--dom/media/test/test_complete_length.html49
5 files changed, 135 insertions, 3 deletions
diff --git a/dom/media/test/complete_length_worker.js b/dom/media/test/complete_length_worker.js
new file mode 100644
index 0000000000..ceda63fdd5
--- /dev/null
+++ b/dom/media/test/complete_length_worker.js
@@ -0,0 +1,80 @@
+"use strict";
+
+let client;
+function is(got, expected, name) {
+ client.postMessage({ type: "is", got, expected, name });
+}
+
+self.onactivate = e =>
+ e.waitUntil(
+ (async () => {
+ await self.clients.claim();
+ const allClients = await self.clients.matchAll();
+ client = allClients[0];
+ is(allClients.length, 1, "allClients.length");
+ })()
+ );
+
+let expected_start = 0;
+let response_data = [
+ // One Array element for each response in order:
+ {
+ complete_length: "*",
+ body: "O",
+ },
+ {
+ complete_length: "3",
+ body: "g",
+ },
+ {
+ // Extend length to test that the remainder is fetched.
+ complete_length: "6",
+ body: "g",
+ },
+ {
+ // Reduce length to test that no more is fetched.
+ complete_length: "4",
+ body: "S",
+ },
+];
+
+self.onfetch = e => {
+ if (!e.request.url.endsWith("/media-resource")) {
+ return; // fall back to network fetch
+ }
+ is(
+ response_data.length >= 1,
+ true,
+ `response_data.length (${response_data.length}) > 0`
+ );
+ const { complete_length, body } = response_data.shift();
+ const range = e.request.headers.get("Range");
+ const match = range.match(/^bytes=(\d+)-/);
+ is(Array.isArray(match), true, `Array.isArray(match) for ${range}`);
+ const first = parseInt(match[1]);
+ is(first, expected_start, "first");
+ const last = first + body.length - 1; // inclusive
+ expected_start = last + 1;
+ const init = {
+ status: 206, // Partial Content
+ headers: {
+ "Accept-Ranges": "bytes",
+ "Content-Type": "audio/ogg",
+ "Content-Range": `bytes ${first}-${last}/${complete_length}`,
+ "Content-Length": body.length,
+ },
+ };
+ e.respondWith(new Response(body, init));
+};
+
+self.onmessage = e => {
+ switch (e.data.type) {
+ case "got error event":
+ // Check that all expected requests were received.
+ is(response_data.length, 0, "missing fetch count");
+ client.postMessage({ type: "done" });
+ return;
+ default:
+ is(e.data.type, "__KNOWN__", "e.data.type");
+ }
+};
diff --git a/dom/media/test/mochitest.toml b/dom/media/test/mochitest.toml
index 99bd1c41c8..2490bef305 100644
--- a/dom/media/test/mochitest.toml
+++ b/dom/media/test/mochitest.toml
@@ -444,6 +444,7 @@ support-files = [
"chained-audio-video.ogg^headers^",
"chromeHelper.js",
"cloneElementVisually_helpers.js",
+ "complete_length_worker.js",
"contentType.sjs",
"detodos.opus",
"detodos.opus^headers^",
@@ -767,6 +768,9 @@ tags = "cloneelementvisually"
["test_clone_media_element.html"]
skip-if = ["os == 'android'"] # bug 1108558, android(bug 1232305)
+["test_complete_length.html"]
+scheme = "https"
+
["test_fastSeek-forwards.html"]
["test_fastSeek.html"]
diff --git a/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp b/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp
index fad7d6ee2e..c3e61e3f11 100644
--- a/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp
+++ b/dom/media/test/rdd_process_xpcom/RddProcessTest.cpp
@@ -49,8 +49,7 @@ RddProcessTest::TestTelemetryProbes(JSContext* aCx,
promise->MaybeResolve((int32_t)rddProc->RDDProcessPid());
},
[promise](nsresult aError) {
- MOZ_ASSERT_UNREACHABLE("RddProcessTest; failure to get RDD child");
- promise->MaybeReject(aError);
+ MOZ_CRASH("RddProcessTest; failure to get RDD child");
});
promise.forget(aOutPromise);
diff --git a/dom/media/test/reftest/reftest.list b/dom/media/test/reftest/reftest.list
index bd4cb2d030..8d39975d5a 100644
--- a/dom/media/test/reftest/reftest.list
+++ b/dom/media/test/reftest/reftest.list
@@ -11,5 +11,5 @@ skip-if(Android) fuzzy(0-31,0-573249) fuzzy-if(appleSilicon,0-37,0-543189) == im
skip-if(Android) fuzzy(0-84,0-774213) fails-if(useDrawSnapshot) == uneven_frame_duration_video.html uneven_frame_duration_video-ref.html # Skip on Windows 7 as the resolution of the video is too high for test machines and will fail in the decoder.
# Set media.dormant-on-pause-timeout-ms to avoid decoders becoming dormant and busting test, skip on android as test is too noisy and unstable
skip-if(Android) pref(media.dormant-on-pause-timeout-ms,-1) fuzzy(0-20,0-500) == frame_order_mp4.html frame_order_mp4-ref.html
-skip-if(Android) fuzzy(0-30,0-270000) == incorrect_display_in_bytestream_vp8.html incorrect_display_in_bytestream_vp8-ref.html
+skip-if(Android) fuzzy(0-31,0-270000) == incorrect_display_in_bytestream_vp8.html incorrect_display_in_bytestream_vp8-ref.html
skip-if(Android) fuzzy(0-22,0-381481) == incorrect_display_in_bytestream_vp9.html incorrect_display_in_bytestream_vp9-ref.html
diff --git a/dom/media/test/test_complete_length.html b/dom/media/test/test_complete_length.html
new file mode 100644
index 0000000000..576b00dac2
--- /dev/null
+++ b/dom/media/test/test_complete_length.html
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Test different complete-length fields of Content-Range headers</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script src="/tests/dom/serviceworkers/test/utils.js"></script>
+ <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
+</head>
+<script>
+"use strict";
+
+let oncomplete;
+navigator.serviceWorker.addEventListener("message", e => {
+ switch (e.data.type) {
+ case "is":
+ is(e.data.got, e.data.expected, e.data.name);
+ break;
+ case "done":
+ oncomplete();
+ break;
+ default:
+ record(false, "unknown e.data.type", e.data.type);
+ }
+});
+
+add_task(async () => {
+ // Unregister any previous ServiceWorkerRegistrations that may not have been
+ // removed before a page reload.
+ await unregisterAll();
+ const registration =
+ await registerAndWaitForActive("complete_length_worker.js");
+ SimpleTest.registerCleanupFunction(() => registration.unregister());
+
+ const audio = new Audio("media-resource");
+ audio.preload = "metadata";
+ // An error event is generated because the resource is incomplete.
+ const error_promise = new Promise(r => audio.onerror = r);
+ await error_promise;
+ is(audio.error.code, MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED, "error.code");
+ is(audio.error.message, "NS_ERROR_DOM_MEDIA_METADATA_ERR (0x806e0006)",
+ "error.message");
+
+ // Tell the ServiceWorker that media-resource requests have completed.
+ navigator.serviceWorker.controller.postMessage({type: "got error event"});
+ await new Promise(r => oncomplete = r);
+});
+</script>
+</html>