summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js')
-rw-r--r--testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js81
1 files changed, 73 insertions, 8 deletions
diff --git a/testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js b/testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js
index 8f1724bc85..c1ebafc4a3 100644
--- a/testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js
+++ b/testing/web-platform/tests/webcodecs/video-encoder-flush.https.any.js
@@ -2,16 +2,36 @@
// META: script=/common/media.js
// META: script=/webcodecs/utils.js
// META: script=/webcodecs/video-encoder-utils.js
+// META: variant=?vp8
+// META: variant=?h264_avc
+
+const VP8_CONFIG = {
+ codec: 'vp8',
+ width: 640,
+ height: 480,
+ displayWidth: 800,
+ displayHeight: 600,
+};
+
+const H264_AVC_CONFIG = {
+ codec: 'avc1.42001e', // Baseline
+ width: 640,
+ height: 480,
+ displayWidth: 800,
+ displayHeight: 600,
+ avc: {format: 'avc'},
+};
+
+let CONFIG = null;
+promise_setup(async () => {
+ CONFIG = {
+ '?vp8': VP8_CONFIG,
+ '?h264_avc': H264_AVC_CONFIG,
+ }[location.search];
+});
promise_test(async t => {
let codecInit = getDefaultCodecInit(t);
- let encoderConfig = {
- codec: 'vp8',
- width: 640,
- height: 480,
- displayWidth: 800,
- displayHeight: 600,
- };
let outputs = 0;
let firstOutput = new Promise(resolve => {
@@ -24,7 +44,7 @@ promise_test(async t => {
});
let encoder = new VideoEncoder(codecInit);
- encoder.configure(encoderConfig);
+ encoder.configure(CONFIG);
let frame1 = createFrame(640, 480, 0);
let frame2 = createFrame(640, 480, 33333);
@@ -45,3 +65,48 @@ promise_test(async t => {
assert_equals(outputs, 1, 'outputs');
}, 'Test reset during flush');
+
+promise_test(async t => {
+ let frame1 = createFrame(640, 480, 0);
+ let frame2 = createFrame(640, 480, 33333);
+ t.add_cleanup(() => {
+ frame1.close();
+ frame2.close();
+ });
+
+ const callbacks = {};
+ const encoder = createVideoEncoder(t, callbacks);
+
+ let flushInCallbackDone;
+ let outputs = 0;
+ let firstOutput = new Promise(resolve => {
+ callbacks.output = (chunk, metadata) => {
+ encoder.reset();
+
+ callbacks.output = (chunk, metadata) => {
+ outputs++;
+ };
+
+ encoder.configure(CONFIG);
+ encoder.encode(frame2);
+ flushInCallbackDone = encoder.flush();
+
+ resolve();
+ };
+ });
+
+ encoder.configure(CONFIG);
+ encoder.encode(frame1);
+ const flushDone = encoder.flush();
+
+ // Wait for the first output, then reset.
+ await firstOutput;
+
+ // Flush should have been synchronously rejected.
+ await promise_rejects_dom(t, 'AbortError', flushDone);
+
+ // Wait for the second flush and check the output count.
+ await flushInCallbackDone;
+
+ assert_equals(outputs, 1, 'outputs');
+}, 'Test new flush after reset in a flush callback');