From a90a5cba08fdf6c0ceb95101c275108a152a3aed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:35:37 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- dom/media/test/complete_length_worker.js | 80 ++++++++++++++++++++++ dom/media/test/mochitest.toml | 4 ++ .../test/rdd_process_xpcom/RddProcessTest.cpp | 3 +- dom/media/test/reftest/reftest.list | 2 +- dom/media/test/test_complete_length.html | 49 +++++++++++++ 5 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 dom/media/test/complete_length_worker.js create mode 100644 dom/media/test/test_complete_length.html (limited to 'dom/media/test') 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 @@ + + + + + Test different complete-length fields of Content-Range headers + + + + + + -- cgit v1.2.3