Bug 1797557 - Ensure storing VideoFrames in IndexedDB throws r=padenot,smaug

Serializing a VideoFrame when `forStorage=true` should throw a
`DataCloneError` (See [1] for more detail).

[1] https://w3c.github.io/webcodecs/#videoframe-transfer-serialization

Differential Revision: https://phabricator.services.mozilla.com/D162679
This commit is contained in:
Chun-Min Chang 2022-11-22 15:04:16 +00:00
Родитель f4b3f2d11e
Коммит 1d6c701b03
1 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -110,3 +110,28 @@ async_test(t => {
t.done();
}, 'Verify posting closed frames throws.');
promise_test(async t => {
const open = indexedDB.open('VideoFrameTestDB', 1);
open.onerror = t.unreached_func('open should succeed');
open.onupgradeneeded = (event) => {
let db = event.target.result;
db.createObjectStore('MyVideoFrames', { keyPath: 'id' });
};
let db = await new Promise((resolve) => {
open.onsuccess = (e) => {
resolve(e.target.result);
};
});
t.add_cleanup(() => {
db.close();
indexedDB.deleteDatabase(db.name);
});
let transaction = db.transaction(['MyVideoFrames'], 'readwrite');
const store = transaction.objectStore('MyVideoFrames');
let frame = createDefaultVideoFrame();
assert_throws_dom("DataCloneError", () => {
store.add(frame);
});
}, 'Verify storing a frame throws.');