|
16 | 16 | const assert_json_equals = (a, b) => assert_equals(JSON.stringify(a), JSON.stringify(b)); |
17 | 17 | const assert_json_not_equals = (a, b) => assert_not_equals(JSON.stringify(a), JSON.stringify(b)); |
18 | 18 |
|
| 19 | +const reuse = {}; // speed up tests |
| 20 | + |
19 | 21 | promise_test(async t => { |
20 | 22 | const frame = await createRTCEncodedFrameFromScratch("video"); |
| 23 | + reuse["video"] = frame; |
21 | 24 | assert_true(frame instanceof RTCEncodedVideoFrame); |
22 | 25 | assert_equals(frame.type, "key"); // first frame is key |
23 | 26 |
|
|
30 | 33 |
|
31 | 34 | promise_test(async t => { |
32 | 35 | const frame = await createRTCEncodedFrameFromScratch("audio"); |
| 36 | + reuse["audio"] = frame; |
33 | 37 | assert_true(frame instanceof RTCEncodedAudioFrame); |
34 | 38 |
|
35 | 39 | const clone = new RTCEncodedAudioFrame(frame); |
|
52 | 56 | const kind = constr.includes("Video")? "video" : "audio"; |
53 | 57 |
|
54 | 58 | promise_test(async t => { |
55 | | - const frame = await createRTCEncodedFrameFromScratch(kind); |
| 59 | + const frame = reuse[kind]; |
56 | 60 | const oldData = frame.getMetadata(); |
57 | 61 | // test single key replacement |
58 | 62 | for (const key of Object.keys(oldData)) { |
|
78 | 82 | }, `${constr} copy construction metadata override on main thread.`); |
79 | 83 |
|
80 | 84 | promise_test(async t => { |
81 | | - const frame = await createRTCEncodedFrameFromScratch(kind); |
| 85 | + const frame = reuse[kind]; |
82 | 86 | assert_greater_than(frame.data.byteLength, 0); |
83 | 87 | const length = frame.data.byteLength; |
84 | 88 | const clone = structuredClone(frame); |
|
88 | 92 | }, `${constr} structuredClone on main thread.`); |
89 | 93 |
|
90 | 94 | promise_test(async t => { |
91 | | - const frame = await createRTCEncodedFrameFromScratch(kind); |
| 95 | + const frame = reuse[kind]; |
92 | 96 | assert_greater_than(frame.data.byteLength, 0); |
93 | 97 | const length = frame.data.byteLength; |
94 | 98 | const clone = structuredClone(frame, {transfer: [frame.data]}); |
|
0 commit comments