diff options
Diffstat (limited to 'testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js')
-rw-r--r-- | testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js b/testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js index a3acb82ab2..1c3b8f120d 100644 --- a/testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js +++ b/testing/web-platform/tests/webcodecs/videoDecoder-codec-specific.https.any.js @@ -556,6 +556,75 @@ promise_test(async t => { const callbacks = {}; const decoder = createVideoDecoder(t, callbacks); + decoder.configure(CONFIG); + decoder.decode(CHUNKS[0]); + const flushDone = decoder.flush(); + + let flushDoneInCallback; + let outputs = 0; + await new Promise(resolve => { + callbacks.output = frame => { + decoder.reset(); + frame.close(); + + callbacks.output = frame => { + outputs++; + frame.close(); + }; + callbacks.error = e => { + t.unreached_func('unexpected error()'); + }; + decoder.configure(CONFIG); + decoder.decode(CHUNKS[0]); + flushDoneInCallback = decoder.flush(); + + resolve(); + }; + }); + + // First flush should have been synchronously rejected. + await promise_rejects_dom(t, 'AbortError', flushDone); + // Wait for the second flush and check the output count. + await flushDoneInCallback; + assert_equals(outputs, 1, 'outputs'); +}, 'Test new flush after reset in a flush callback'); + +promise_test(async t => { + await checkImplements(); + const callbacks = {}; + const decoder = createVideoDecoder(t, callbacks); + + decoder.configure(CONFIG); + decoder.decode(CHUNKS[0]); + const flushDone = decoder.flush(); + let flushDoneInCallback; + + await new Promise(resolve => { + callbacks.output = frame => { + decoder.reset(); + frame.close(); + + callbacks.output = frame => { frame.close(); }; + decoder.configure(CONFIG); + decoder.decode(CHUNKS[0]); + decoder.decode(createCorruptChunk(1)); + flushDoneInCallback = decoder.flush(); + + resolve(); + }; + }); + + // First flush should have been synchronously rejected. + await promise_rejects_dom(t, 'AbortError', flushDone); + // Wait for the second flush and check the error in the rejected promise. + await promise_rejects_dom(t, 'EncodingError', flushDoneInCallback); +}, 'Test decoding a corrupt frame after reset in a flush callback'); + +promise_test(async t => { + await checkImplements(); + const callbacks = {}; + const decoder = createVideoDecoder(t, callbacks); + decoder.configure({...CONFIG, optimizeForLatency: true}); decoder.decode(CHUNKS[0]); |