forked from mirrors/gecko-dev
Automatic update from web-platform-tests Mark codec interfaces as SecureContext Bug: 1243519 Change-Id: Ib2d77aca4848053408ef0e8a78d95df0c6b9bbaf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3120330 Commit-Queue: Chrome Cunningham <chcunningham@chromium.org> Auto-Submit: Chrome Cunningham <chcunningham@chromium.org> Reviewed-by: Dale Curtis <dalecurtis@chromium.org> Cr-Commit-Position: refs/heads/main@{#915665} -- wpt-commits: 26f620a206708bc7bd2cd0c7d953f0916c33719b wpt-pr: 30187
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
// META: global=window
|
|
// META: script=/common/media.js
|
|
// META: script=/webcodecs/utils.js
|
|
|
|
var defaultInit = {
|
|
timestamp: 1234,
|
|
channels: 2,
|
|
sampleRate: 8000,
|
|
frames: 1,
|
|
};
|
|
|
|
function testAudioData(useView) {
|
|
let localData =
|
|
new SharedArrayBuffer(defaultInit.channels * defaultInit.frames * 4);
|
|
let view = new Float32Array(localData);
|
|
view[0] = -1.0;
|
|
view[1] = 1.0;
|
|
|
|
let audio_data_init = {
|
|
timestamp: defaultInit.timestamp,
|
|
data: useView ? view : localData,
|
|
numberOfFrames: defaultInit.frames,
|
|
numberOfChannels: defaultInit.channels,
|
|
sampleRate: defaultInit.sampleRate,
|
|
format: 'f32-planar',
|
|
}
|
|
|
|
let data = new AudioData(audio_data_init);
|
|
|
|
let copyDest = new SharedArrayBuffer(data.allocationSize({planeIndex: 0}));
|
|
let destView = new Float32Array(copyDest);
|
|
data.copyTo(useView ? destView : copyDest, {planeIndex: 0});
|
|
assert_equals(destView[0], -1.0, 'copyDest[0]');
|
|
data.copyTo(useView ? destView : copyDest, {planeIndex: 1});
|
|
assert_equals(destView[0], 1.0, 'copyDest[1]');
|
|
}
|
|
|
|
test(t => {
|
|
testAudioData(/*useView=*/ false);
|
|
}, 'Test construction and copyTo() using a SharedArrayBuffer');
|
|
|
|
test(t => {
|
|
testAudioData(/*useView=*/ true);
|
|
}, 'Test construction and copyTo() using a Uint8Array(SharedArrayBuffer)');
|