summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/2dcontext/hit-regions/addHitRegions-NotSupportedError-01.html
blob: 05818aeb8bb66f24e91c83fdad9502b2a06285cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hit regions: addHitRegion throws NotSupportedError</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="log"></div>
<div style="display: none"><canvas id="canvas"><button id="button">button</button></canvas></div>

<script>
test(function () {
    assert_throws({ name: "NotSupportedError" },
        function () {
            var canvas = document.getElementById("canvas");
            // Reset context
            canvas.width = canvas.width;
            var button = document.getElementById("button");
            var context = canvas.getContext("2d");

            // Shapes are painted without affecting the current default path,
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-rectangles-to-the-canvas
            context.fillRect(25, 25, 25, 25);

            // If the specified path has no pixels, throw a NotSupportedError exception and abort these steps.
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#hit-regions
            context.addHitRegion({ id: "notsupportederror_fillRect", control: button })
        }, "fillRect should not affect current default path and NotSupportedError should be thrown.");
}, "fillRect should not affect current default path and NotSupportedError should be thrown.");

test(function () {
    assert_throws({ name: "NotSupportedError" },
        function () {
            var canvas = document.getElementById("canvas");
            // Reset context
            canvas.width = canvas.width;
            var button = document.getElementById("button");
            var context = canvas.getContext("2d");

            // "Shapes are painted without affecting the current default path,"
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-rectangles-to-the-canvas
            context.strokeRect(75, 25, 25, 25);

            // "If the specified path has no pixels, throw a NotSupportedError exception and abort these steps."
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#hit-regions
            context.addHitRegion({ id: "notsupportederror_strokeRect", control: button })
        }, "strokeRect should not affect current default path and NotSupportedError should be thrown.");
}, "strokeRect should not affect current default path and NotSupportedError should be thrown.");

test(function() {
    assert_throws({ name: "NotSupportedError" },
        function () {
            var canvas = document.getElementById("canvas");
            // Reset context
            canvas.width = canvas.width;
            var button = document.getElementById("button");
            var context = canvas.getContext("2d");

            // "These shapes are painted without affecting the current path"
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-rectangles-to-the-canvas
            context.fillText("fillText", 25, 100);

            // "If the specified path has no pixels, throw a NotSupportedError exception and abort these steps."
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-text-to-the-canvas
            context.addHitRegion({ id: "notsupportederror_fillText", control: button });
        }, "fillText should not affect current default path and NotSupportedError should be thrown.");
}, "fillText should not affect current default path and NotSupportedError should be thrown.");

test(function() {
    assert_throws({ name: "NotSupportedError" },
        function () {
            var canvas = document.getElementById("canvas");
            canvas.width = canvas.width;
            var button = document.getElementById("button");
            var context = canvas.getContext("2d");
            // "These shapes are painted without affecting the current path"
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-rectangles-to-the-canvas
            context.strokeText("strokeText", 75, 100);

            // "If the specified path has no pixels, throw a NotSupportedError exception and abort these steps."
            // http://www.w3.org/html/wg/drafts/2dcontext/html5_canvas_CR/#drawing-text-to-the-canvas
            context.addHitRegion({ id: "notsupportederror_strokeText", control: button });
        }, "strokeText should not affect current default path and NotSupportedError shuld be thrown.");
}, "strokeText should not affect current default path and NotSupportedError shuld be thrown.");
</script>
</body>
</html>