mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Update web-platform-tests to revision b'421155a1c8752a36b465e62f466b18f821190e08'
This commit is contained in:
parent
871cefc926
commit
fd56698ec7
722 changed files with 19686 additions and 8130 deletions
|
@ -0,0 +1,111 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<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>
|
||||
<script id='sharedWorkerCode' type='javascript/worker'>
|
||||
self.onconnect = function (event) {
|
||||
const port = event.ports[0];
|
||||
port.onmessage = function (e) {
|
||||
port.postMessage(e.data);
|
||||
};
|
||||
};
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const HELPER = '/webcodecs/videoFrame-serialization.crossAgentCluster.helper.html';
|
||||
const SAMEORIGIN_BASE = get_host_info().HTTPS_ORIGIN;
|
||||
const CROSSORIGIN_BASE = get_host_info().HTTPS_NOTSAMESITE_ORIGIN;
|
||||
const SAMEORIGIN_HELPER = SAMEORIGIN_BASE + HELPER;
|
||||
const CROSSORIGIN_HELPER = CROSSORIGIN_BASE + HELPER;
|
||||
|
||||
promise_test(async () => {
|
||||
const target = (await appendIframe(SAMEORIGIN_HELPER)).contentWindow;
|
||||
let frame = createVideoFrame(10);
|
||||
assert_true(await canSendVideoFrame(target, frame));
|
||||
}, 'Verify frames can be passed within the same agent clusters');
|
||||
|
||||
promise_test(async () => {
|
||||
const target = (await appendIframe(CROSSORIGIN_HELPER)).contentWindow;
|
||||
let frame = createVideoFrame(20);
|
||||
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');
|
||||
|
||||
promise_test(async () => {
|
||||
const blob = new Blob([document.querySelector('#sharedWorkerCode').textContent], {
|
||||
type: 'text/javascript',
|
||||
});
|
||||
const worker = new SharedWorker(window.URL.createObjectURL(blob));
|
||||
let frame = createVideoFrame(40);
|
||||
worker.port.postMessage(frame);
|
||||
const received = await new Promise(resolve => worker.port.onmessage = e => {
|
||||
resolve(e.data);
|
||||
});
|
||||
assert_equals(received.toString(), '[object VideoFrame]');
|
||||
assert_equals(received.timestamp, 40);
|
||||
}, 'Verify frames can be passed back and forth between main and sharedworker');
|
||||
|
||||
promise_test(async () => {
|
||||
navigator.serviceWorker.register('videoFrame-serialization.crossAgentCluster.serviceworker.js');
|
||||
navigator.serviceWorker.ready.then((registration) => {
|
||||
let frame = createVideoFrame(50);
|
||||
registration.active.postMessage(frame);
|
||||
registration.active.postMessage({'id': 50});
|
||||
});
|
||||
const received = await new Promise(resolve => navigator.serviceWorker.onmessage = (e) => {
|
||||
resolve(e.data);
|
||||
});
|
||||
assert_equals(received, 'NOT_RECEIVED');
|
||||
}, 'Verify frames cannot be passed to serviceworker');
|
||||
|
||||
function appendIframe(src) {
|
||||
const frame = document.createElement('iframe');
|
||||
document.body.appendChild(frame);
|
||||
frame.src = src;
|
||||
return new Promise(resolve => frame.onload = () => resolve(frame));
|
||||
};
|
||||
|
||||
function createVideoFrame(ts) {
|
||||
let data = new Uint8Array([
|
||||
1, 2, 3, 4, 5, 6, 7, 8,
|
||||
9, 10, 11, 12, 13, 14, 15, 16,
|
||||
]);
|
||||
return new VideoFrame(data, {
|
||||
timestamp: ts,
|
||||
codedWidth: 2,
|
||||
codedHeight: 2,
|
||||
format: 'RGBA',
|
||||
});
|
||||
}
|
||||
|
||||
function canSendVideoFrame(target, vf) {
|
||||
target.postMessage(vf, '*');
|
||||
target.postMessage({'id': vf.timestamp}, '*');
|
||||
return new Promise(resolve => window.onmessage = e => {
|
||||
resolve(e.data == 'RECEIVED');
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue