| Differences between
and this patch
- a/LayoutTests/ChangeLog +11 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2021-10-12  Cameron McCormack  <heycam@apple.com>
2
3
        Test that colors in a canvas.captureStream() video track are preserved when sent over a peer connection
4
        https://bugs.webkit.org/show_bug.cgi?id=231645
5
        <rdar://problem/84172363>
6
7
        Reviewed by Youenn Fablet.
8
9
        * webrtc/captureStream-color-space-expected.txt: Added.
10
        * webrtc/captureStream-color-space.html: Added.
11
1
2021-09-28  Cameron McCormack  <heycam@apple.com>
12
2021-09-28  Cameron McCormack  <heycam@apple.com>
2
13
3
        Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
14
        Ensure CanvasRenderingContext2D.drawImage(video) uses the right color space
- a/LayoutTests/webrtc/captureStream-color-space-expected.txt +4 lines
Line 0 a/LayoutTests/webrtc/captureStream-color-space-expected.txt_sec1
1
2
3
PASS Test that colors in a canvas.captureStream() video track are preserved when sent over a peer connection
4
- a/LayoutTests/webrtc/captureStream-color-space.html +51 lines
Line 0 a/LayoutTests/webrtc/captureStream-color-space.html_sec1
1
<!DOCTYPE html>
2
<title>Test that colors in a canvas.captureStream() video track are preserved when sent over a peer connection</title>
3
<script src="../resources/testharness.js"></script>
4
<script src="../resources/testharnessreport.js"></script>
5
<canvas id="src" width="16" height="16"></canvas>
6
<video id="vid" width="16" height="16" autoplay></video>
7
<canvas id="dst" width="16" height="16"></canvas>
8
<script>
9
function drawSourceThenCheckDestination() {
10
    const srcContext = src.getContext("2d");
11
    srcContext.fillStyle = "#800000";
12
    srcContext.fillRect(0, 0, 16, 16);
13
14
    const dstContext = dst.getContext("2d");
15
    dstContext.clearRect(0, 0, 16, 16);
16
    dstContext.drawImage(vid, 0, 0);
17
18
    // The stream takes a few frames to get started. Wait until the drawImage() call paints something.
19
    const imageData = dstContext.getImageData(0, 0, 1, 1);
20
    if (!imageData.data[3]) {
21
        requestAnimationFrame(t.step_func(drawSourceThenCheckDestination));
22
        return;
23
    }
24
25
    const actual = [...imageData.data];
26
    const expected = [128, 0, 0, 255];
27
    assert_array_approx_equals(actual, expected, 2, `actual = ${actual}, expected = ${expected}`);
28
    t.done();
29
}
30
31
var t = async_test(async function(t) {
32
    requestAnimationFrame(t.step_func(drawSourceThenCheckDestination));
33
34
    const connectionA = new RTCPeerConnection();
35
    const connectionB = new RTCPeerConnection();
36
37
    connectionA.onicecandidate = e => connectionB.addIceCandidate(e.candidate);
38
    connectionB.onicecandidate = e => connectionA.addIceCandidate(e.candidate);
39
40
    connectionA.addTrack(src.captureStream().getVideoTracks()[0]);
41
    connectionB.ontrack = e => vid.srcObject = new MediaStream([e.track]);
42
43
    const descriptionA = await connectionA.createOffer();
44
    connectionA.setLocalDescription(descriptionA);
45
    await connectionB.setRemoteDescription(descriptionA);
46
47
    const descriptionB = await connectionB.createAnswer();
48
    connectionB.setLocalDescription(descriptionB);
49
    connectionA.setRemoteDescription(descriptionB);
50
});
51
</script>

Return to Bug 231645