diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html')
-rw-r--r-- | testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html b/testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html new file mode 100644 index 0000000000..99b45f22c9 --- /dev/null +++ b/testing/web-platform/tests/webrtc-encoded-transform/sframe-transform-buffer-source.html @@ -0,0 +1,50 @@ +<!doctype html> +<html> + <head> + <meta charset="utf-8"> + <script src="/resources/testharness.js"></script> + <script src="/resources/testharnessreport.js"></script> + </head> + <body> + <script> + +async function getEncryptedData(transform) +{ + const chunk = await transform.readable.getReader().read(); + const value = new Uint8Array(chunk.value); + return [...value]; +} + +promise_test(async (test) => { + const key = await crypto.subtle.importKey("raw", new Uint8Array([143, 77, 43, 10, 72, 19, 37, 67, 236, 219, 24, 93, 26, 165, 91, 178]), "HKDF", false, ["deriveBits", "deriveKey"]); + const transform1 = new SFrameTransform; + const transform2 = new SFrameTransform; + const transform3 = new SFrameTransform; + + await transform1.setEncryptionKey(key); + await transform2.setEncryptionKey(key); + await transform3.setEncryptionKey(key); + + const buffer1 = new ArrayBuffer(10); + const buffer2 = new ArrayBuffer(11); + const view1 = new Uint8Array(buffer1); + const view2 = new Uint8Array(buffer2, 1); + for (let i = 0 ; i < buffer1.byteLength; ++i) { + view1[i] = i; + view2[i] = i; + } + + transform1.writable.getWriter().write(buffer1); + transform2.writable.getWriter().write(view1); + transform3.writable.getWriter().write(view2); + + const result1 = await getEncryptedData(transform1); + const result2 = await getEncryptedData(transform2); + const result3 = await getEncryptedData(transform3); + + assert_array_equals(result1, result2, "result2"); + assert_array_equals(result1, result3, "result3"); +}, "Uint8Array as input to SFrameTransform"); + </script> + </body> +</html> |