https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 392366fb149414c0c2ef08b3d4741a32069025f3 authored by Han Leon on 21 December 2017, 10:00:24 UTC
[ServiceWorker] Let Client.url be the creation url of the window client
Tip revision: 392366f
createImageBitmap-drawImage.html
<!DOCTYPE html>
<html>
<title>createImageBitmap + drawImage test</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/canvas-tests.js"></script>
<script src="common.js"></script>
<link rel="stylesheet" href="/common/canvas-tests.css">
<body>
<script>
(function() {
    promise_test(function() {
        return new Promise(function(resolve, reject) {
            var img = new Image();
            img.onload = function() { resolve(img); };
            img.src = "/images/pattern.png";
        }).then(function(img) {
            return testDrawImageBitmap(img);
        });
    }, "createImageBitmap from a HTMLImageElement, and drawImage on the created ImageBitmap");

    promise_test(function() {
        return new Promise(function(resolve, reject) {
            var xhr = new XMLHttpRequest();
            xhr.open("GET", '/images/pattern.png');
            xhr.responseType = 'blob';
            xhr.send();
            xhr.onload = function() {
                blob = xhr.response;
                resolve(blob);
            };
        }).then(function(blob) {
            return testDrawImageBitmap(blob);
        });
    }, "createImageBitmap from a Blob, and drawImage on the created ImageBitmap");

    promise_test(function() {
        var testCanvas = document.createElement("canvas");
        initializeTestCanvas(testCanvas);
        return testDrawImageBitmap(testCanvas);
    }, "createImageBitmap from a HTMLCanvasElement, and drawImage on the created ImageBitmap");

    promise_test(function() {
        var testCanvas = document.createElement("canvas");
        initializeTestCanvas(testCanvas);
        return new Promise(function(resolve, reject) {
            createImageBitmap(testCanvas).then(function(bitmap) {
                resolve(bitmap);
            });
        }).then(function(bitmap) {
            return testDrawImageBitmap(bitmap);
        });
    }, "createImageBitmap from an ImageBitmap, and drawImage on the created ImageBitmap");

    promise_test(function() {
        var imgData = new ImageData(20, 20);
        initializeImageData(imgData, 20, 20);
        return testDrawImageBitmap(imgData);
    }, "createImageBitmap from an ImageData, and drawImage on the created ImageBitmap");

    promise_test(function() {
        return new Promise(function(resolve, reject) {
            var video = document.createElement("video");
            video.oncanplaythrough = function() {
                resolve(video);
            };
            video.src = "/images/pattern.ogv";
        }).then(function(video) {
            return testDrawImageBitmap(video);
        });
    }, "createImageBitmap from a HTMLVideoElement, and drawImage on the created ImageBitmap");
})();
</script>
</body>
</html>
back to top