testing/web-platform/tests/html/canvas/offscreen/fill-and-stroke-styles/2d.pattern.paint.norepeat.coord2.html
author Aaron Krajeski <krajeski@gmail.com>
Tue, 05 May 2020 19:39:02 +0000
changeset 529326 d4e1e62aed03db1d447f6b31b8d1347c2ad2e43b
child 604175 8c8326a5e1017f214639db0061c86bad7911f51d
permissions -rw-r--r--
Bug 1631036 [wpt PR 23070] - Reorganize canvas 2d tests, a=testonly Automatic update from web-platform-tests Reorganize canvas 2d tests (#23070) This is the first part of https://github.com/web-platform-tests/wpt/issues/22979. Starting small with this first PR, because small mean ~3k renamed files. In summary: 2dcontext -> html/canvas/dom-element offscreen-canvas -> html/canvas/offscreen The tools folder inside 2dcontext and offscreen-canvas has been merged such that `tools/build.sh` generates dom-canvas and offscreen canvas tests. Next steps: 1. Take the tests that are in `html/semantics/embedded-content/the-canvas-element` and move them inside the `canvas` folder. 2. Autogen folders for detached, offscreen worker, transferControlToOffscreen and transferControlToOfscreen in workers. 3. Split up `tools/tests*.yaml` files. 4. Make non-autogen'd tests autogen'd. -- wpt-commits: 5232c1fc4679136d16c54d9f6bcc5ceb468ca755 wpt-pr: 23070

<!DOCTYPE html>
<!-- DO NOT EDIT! This test has been generated by /html/canvas/tools/gentest.py. -->
<title>OffscreenCanvas test: 2d.pattern.paint.norepeat.coord2</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/html/canvas/resources/canvas-tests.js"></script>

<h1>2d.pattern.paint.norepeat.coord2</h1>
<p class="desc"></p>


<script>
var t = async_test("");
var t_pass = t.done.bind(t);
var t_fail = t.step_func(function(reason) {
    throw reason;
});
t.step(function() {

var offscreenCanvas = new OffscreenCanvas(100, 50);
var ctx = offscreenCanvas.getContext('2d');

var promise = new Promise(function(resolve, reject) {
    var xhr = new XMLHttpRequest();
    xhr.open("GET", '/images/green.png');
    xhr.responseType = 'blob';
    xhr.send();
    xhr.onload = function() {
        resolve(xhr.response);
    };
});
promise.then(function(response) {
    createImageBitmap(response).then(bitmap => {
        var pattern = ctx.createPattern(bitmap, 'no-repeat');
        ctx.fillStyle = pattern;
        ctx.fillRect(0, 0, 50, 50);
        ctx.fillStyle = '#f00';
        ctx.fillRect(50, 0, 50, 50);
        ctx.fillStyle = pattern;
        ctx.translate(50, 0);
        ctx.fillRect(-50, 0, 100, 50);
        _assertPixel(offscreenCanvas, 1,1, 0,255,0,255, "1,1", "0,255,0,255");
        _assertPixel(offscreenCanvas, 98,1, 0,255,0,255, "98,1", "0,255,0,255");
        _assertPixel(offscreenCanvas, 1,48, 0,255,0,255, "1,48", "0,255,0,255");
        _assertPixel(offscreenCanvas, 98,48, 0,255,0,255, "98,48", "0,255,0,255");
    }, t_fail);
}).then(t_pass, t_fail);

});
</script>