Bug 1774302 - Add a wpt passing VideoFrame between main and worker r=smaug

Depends on D159546

Differential Revision: https://phabricator.services.mozilla.com/D160307
This commit is contained in:
Chun-Min Chang 2022-10-26 16:41:54 +00:00
Родитель 4343b67583
Коммит f122a37829
1 изменённых файлов: 19 добавлений и 0 удалений

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

@ -4,6 +4,11 @@
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='/common/get-host-info.sub.js'></script>
<script id='workerCode' type='javascript/worker'>
self.onmessage = (e) => {
postMessage(e.data);
};
</script>
</head>
<body>
<script>
@ -25,6 +30,20 @@ promise_test(async () => {
assert_false(await canSendVideoFrame(target, frame));
}, 'Verify frames cannot be passed accross the different agent clusters');
promise_test(async () => {
const blob = new Blob([document.querySelector('#workerCode').textContent], {
type: 'text/javascript',
});
const worker = new Worker(window.URL.createObjectURL(blob));
let frame = createVideoFrame(30);
worker.postMessage(frame);
const received = await new Promise(resolve => worker.onmessage = e => {
resolve(e.data);
});
assert_equals(received.toString(), '[object VideoFrame]');
assert_equals(received.timestamp, 30);
}, 'Verify frames can be passed back and forth between main and worker');
function appendIframe(src) {
const frame = document.createElement('iframe');
document.body.appendChild(frame);