layout/reftests/canvas/ctm-singular-sanity.html
author Xianzhu Wang <wangxianzhu@chromium.org>
Tue, 05 Mar 2019 12:18:01 +0000
changeset 464575 4325ba7b38576495a78289c2a8f4dff391922e66
parent 113750 b2bfb82c9687d7e86db3ef499b95664bd7d16c2b
permissions -rw-r--r--
Bug 1529059 [wpt PR 15420] - [BlinkGenPropertyTrees] Initiailize double_sided of synthetic effect, a=testonly Automatic update from web-platform-tests [BlinkGenPropertyTrees] Initiailize double_sided of synthetic effect Previously synthetic effects always had double_sided==false, causing the layer disappear when the backface was facing forward. Bug: 928190 Change-Id: I35534b40346d5c5918bc99c00a4ca6b4e3b68796 Reviewed-on: https://chromium-review.googlesource.com/c/1475815 Reviewed-by: Philip Rogers <pdr@chromium.org> Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Cr-Commit-Position: refs/heads/master@{#632764} -- wpt-commits: a89467050deaf1dcbd9140a2f0670b1b85e518ee wpt-pr: 15420

<html>
<head>
  <script type="text/javascript">

function assert(cond, msg) { if (!cond) { throw msg; } }

function isSameTM(m1, m2) {
    // XXX this is probably the ugliest possible way to write this function,
    // but it's intended to be lowest-common-denominator
    if (!(m1.length === 6 && m1.length === m2.length)) {
        return false;
    }
    for (var i = 0; i < m1.length; ++i) {
        if (m1[i] !== m2[i]) {
            return false;
        }
    }
    return true;
}

window.onload = function() {
    var IM = [ 1, 0, 0, 1, 0, 0 ];

    try {
        var ctx = document.getElementById("c1").getContext("2d");

        var singular = [ 0, 0, 0, 0, 0, 0 ];
        ctx.mozCurrentTransform = singular;
        assert(isSameTM(singular, ctx.mozCurrentTransform),
               "Expected setting CTM to a singular matrix to work");
        var inv = ctx.mozCurrentTransformInverse;
        assert(!isSameTM(inv, inv),
               "Expected to get back matrix of NaN's from currentTransformInverse");
        ctx.mozCurrentTransform = IM;

        var m = [ 1, 2, 3, 4, 5, 6 ];
        ctx.mozCurrentTransform = m;
        ctx.mozCurrentTransformInverse = singular;
        assert(isSameTM(m, ctx.mozCurrentTransform),
                        "Setting currentTransformInverse to a singular matrix is a no-op");
        ctx.mozCurrentTransform = IM;
    } catch (e) {
        document.body.innerHTML = "FAIL: "+ e.toString();
        return;
    }
    document.body.innerHTML = "Pass";
}
  </script>
</head>
<body>
  <div><canvas id="c1" width="300" height="300"></canvas></div>
</body>
</html>