Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / canvas / drawImage-with-broken-image.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <script>
7     window.jsTestIsAsync = true;
8     description("This test checks behavior of Canvas::drawImage with a broken source image.");
9
10     var InvalidStateError = "InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The source width is 0.";
11     var TypeMismatchError = "TypeMismatchError: The type of an object was incompatible with the expected type of the parameter associated to the object.";
12
13     // Create an image with invalid data.
14     var invalidImage = new Image();
15     invalidImage.src = 'resources/repaint.js';
16     invalidImage.onerror = draw;
17
18     var ctx = document.createElement("canvas").getContext('2d');
19     function draw() {
20         // null images should throw TypeError
21         shouldThrow("ctx.drawImage(null, 0, 0)");
22         shouldThrow("ctx.drawImage(null, 0, 0, 20, 20)");
23         shouldThrow("ctx.drawImage(null, 0, 0, 20, 20, 0, 0, 20, 20)");
24
25         // broken images should not throw
26         shouldBe("ctx.drawImage(invalidImage, 0, 0)", "undefined");
27         shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20)", "undefined");
28         shouldBe("ctx.drawImage(invalidImage, 0, 0, 20, 20, 0, 0, 20, 20)", "undefined");
29         shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20)", "undefined");
30         shouldBe("ctx.drawImage(invalidImage, 0, 0, 0, 20, 0, 0, 20, 20)", "undefined");
31
32         finishJSTest();
33     }
34 </script>
35 </body>
36 </html>