summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webcodecs/video-decoder.crossOriginIsolated.https.any.js
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/webcodecs/video-decoder.crossOriginIsolated.https.any.js
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/webcodecs/video-decoder.crossOriginIsolated.https.any.js')
-rw-r--r--testing/web-platform/tests/webcodecs/video-decoder.crossOriginIsolated.https.any.js68
1 files changed, 68 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webcodecs/video-decoder.crossOriginIsolated.https.any.js b/testing/web-platform/tests/webcodecs/video-decoder.crossOriginIsolated.https.any.js
new file mode 100644
index 0000000000..3232844a31
--- /dev/null
+++ b/testing/web-platform/tests/webcodecs/video-decoder.crossOriginIsolated.https.any.js
@@ -0,0 +1,68 @@
+// META: global=window,dedicatedworker
+// META: script=/webcodecs/utils.js
+
+const testData = {
+ src: 'h264.mp4',
+ config: {
+ codec: 'avc1.64000b',
+ description: {offset: 9490, size: 45},
+ codedWidth: 320,
+ codedHeight: 240,
+ displayAspectWidth: 320,
+ displayAspectHeight: 240,
+ }
+};
+
+// Create a view of an ArrayBuffer.
+function view(buffer, {offset, size}) {
+ return new Uint8Array(buffer, offset, size);
+}
+
+function testSharedArrayBufferDescription(t, useView) {
+ const data = testData;
+
+ // Don't run test if the codec is not supported.
+ assert_equals("function", typeof VideoDecoder.isConfigSupported);
+ let supported = false;
+ return VideoDecoder.isConfigSupported({codec: data.config.codec})
+ .catch(_ => {
+ assert_implements_optional(false, data.config.codec + ' unsupported');
+ })
+ .then(support => {
+ supported = support.supported;
+ assert_implements_optional(
+ supported, data.config.codec + ' unsupported');
+ return fetch(data.src);
+ })
+ .then(response => {
+ return response.arrayBuffer();
+ })
+ .then(buf => {
+ config = {...data.config};
+ if (data.config.description) {
+ let desc = new SharedArrayBuffer(data.config.description.size);
+ let descView = new Uint8Array(desc);
+ descView.set(view(buf, data.config.description));
+ config.description = useView ? descView : desc;
+ }
+
+ // Support was verified above, so the description shouldn't change
+ // that.
+ return VideoDecoder.isConfigSupported(config);
+ })
+ .then(support => {
+ assert_true(support.supported);
+
+ const decoder = new VideoDecoder(getDefaultCodecInit(t));
+ decoder.configure(config);
+ assert_equals(decoder.state, 'configured', 'state');
+ });
+}
+
+promise_test(t => {
+ return testSharedArrayBufferDescription(t, /*useView=*/ false);
+}, 'Test isConfigSupported() and configure() using a SharedArrayBuffer');
+
+promise_test(t => {
+ return testSharedArrayBufferDescription(t, /*useView=*/ true);
+}, 'Test isConfigSupported() and configure() using a Uint8Array(SharedArrayBuffer)');