Automatic update from web-platform-tests [webcodecs] Deprecate VideoFrame.destroy(). This CL adds VideoFrame.close() as an alias for VideoFrame.destroy(), adds a deprecation message for VideoFrame.destroy(), and changes all callsites to use close(). Bug: 1166930 Change-Id: I39b9c68262553a6814f6bb0b6b81c02012c2d026 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631405 Commit-Queue: Dan Sanders <sandersd@chromium.org> Reviewed-by: Jeremy Roman <jbroman@chromium.org> Reviewed-by: Eugene Zemtsov <eugene@chromium.org> Reviewed-by: Guido Urdaneta <guidou@chromium.org> Cr-Commit-Position: refs/heads/master@{#844250} -- wpt-commits: 1895256f46deb64c491bff1d5bc2e4372dd35731 wpt-pr: 27194
115 lines
2.7 KiB
JavaScript
115 lines
2.7 KiB
JavaScript
// META: global=window,dedicatedworker
|
|
// META: script=/common/media.js
|
|
// META: script=/webcodecs/utils.js
|
|
|
|
var defaultInit = {
|
|
timestamp : 100,
|
|
duration : 33,
|
|
}
|
|
|
|
function createDefaultVideoFrame() {
|
|
let image = makeImageBitmap(32,16);
|
|
|
|
return new VideoFrame(image, defaultInit);
|
|
}
|
|
|
|
test(t => {
|
|
let frame = createDefaultVideoFrame();
|
|
|
|
let clone = frame.clone();
|
|
|
|
assert_equals(frame.timestamp, clone.timestamp);
|
|
assert_equals(frame.duration, clone.duration);
|
|
assert_equals(frame.cropWidth, clone.cropWidth);
|
|
assert_equals(frame.cropHeight, clone.cropHeight);
|
|
assert_equals(frame.cropWidth, clone.cropWidth);
|
|
assert_equals(frame.cropHeight, clone.cropHeight);
|
|
|
|
frame.close();
|
|
clone.close();
|
|
}, 'Test we can clone a VideoFrame.');
|
|
|
|
test(t => {
|
|
let frame = createDefaultVideoFrame();
|
|
|
|
let copy = frame;
|
|
let clone = frame.clone();
|
|
|
|
frame.close();
|
|
|
|
assert_not_equals(copy.timestamp, defaultInit.timestamp);
|
|
assert_equals(clone.timestamp, defaultInit.timestamp);
|
|
|
|
clone.close();
|
|
}, 'Verify closing a frame doesn\'t affect its clones.');
|
|
|
|
test(t => {
|
|
let frame = createDefaultVideoFrame();
|
|
|
|
frame.close();
|
|
|
|
assert_throws_dom("InvalidStateError", () => {
|
|
let clone = frame.clone();
|
|
});
|
|
}, 'Verify cloning a closed frame throws.');
|
|
|
|
async_test(t => {
|
|
let localFrame = createDefaultVideoFrame();
|
|
|
|
let channel = new MessageChannel();
|
|
let localPort = channel.port1;
|
|
let externalPort = channel.port2;
|
|
|
|
externalPort.onmessage = t.step_func((e) => {
|
|
let externalFrame = e.data;
|
|
externalFrame.close();
|
|
externalPort.postMessage("Done");
|
|
})
|
|
|
|
localPort.onmessage = t.step_func_done((e) => {
|
|
assert_not_equals(localFrame.timestamp, defaultInit.timestamp);
|
|
})
|
|
|
|
localPort.postMessage(localFrame);
|
|
|
|
}, 'Verify closing frames propagates accross contexts.');
|
|
|
|
async_test(t => {
|
|
let localFrame = createDefaultVideoFrame();
|
|
|
|
let channel = new MessageChannel();
|
|
let localPort = channel.port1;
|
|
let externalPort = channel.port2;
|
|
|
|
externalPort.onmessage = t.step_func((e) => {
|
|
let externalFrame = e.data;
|
|
externalFrame.close();
|
|
externalPort.postMessage("Done");
|
|
})
|
|
|
|
localPort.onmessage = t.step_func_done((e) => {
|
|
assert_equals(localFrame.timestamp, defaultInit.timestamp);
|
|
localFrame.close();
|
|
})
|
|
|
|
localPort.postMessage(localFrame.clone());
|
|
|
|
}, 'Verify closing cloned frames doesn\'t propagate accross contexts.');
|
|
|
|
async_test(t => {
|
|
let localFrame = createDefaultVideoFrame();
|
|
|
|
let channel = new MessageChannel();
|
|
let localPort = channel.port1;
|
|
|
|
localPort.onmessage = t.unreached_func();
|
|
|
|
localFrame.close();
|
|
|
|
assert_throws_dom("DataCloneError", () => {
|
|
localPort.postMessage(localFrame);
|
|
});
|
|
|
|
t.done();
|
|
}, 'Verify posting closed frames throws.');
|