- add third_party src.
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / inspector / profiler / canvas2d / canvas2d-api-changes.html
1 <html>
2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script>
5
6 var CanvasRenderingContext2DResource = {};
7
8 /**
9  * @const
10  * @type {Array.<string>}
11  */
12 CanvasRenderingContext2DResource.AttributeProperties = [
13     "strokeStyle",
14     "fillStyle",
15     "globalAlpha",
16     "lineWidth",
17     "lineCap",
18     "lineJoin",
19     "miterLimit",
20     "shadowOffsetX",
21     "shadowOffsetY",
22     "shadowBlur",
23     "shadowColor",
24     "globalCompositeOperation",
25     "font",
26     "textAlign",
27     "textBaseline",
28     "lineDashOffset",
29     "imageSmoothingEnabled",
30     "webkitImageSmoothingEnabled",
31     // FIXME: Temporary properties implemented in JSC, but not in V8.
32     "webkitLineDash",
33     "webkitLineDashOffset"
34 ];
35
36 /**
37  * @const
38  * @type {Array.<string>}
39  */
40 CanvasRenderingContext2DResource.PathMethods = [
41     "beginPath",
42     "moveTo",
43     "closePath",
44     "lineTo",
45     "quadraticCurveTo",
46     "bezierCurveTo",
47     "arcTo",
48     "arc",
49     "rect"
50 ];
51
52 /**
53  * @const
54  * @type {Array.<string>}
55  */
56 CanvasRenderingContext2DResource.TransformationMatrixMethods = [
57     "scale",
58     "rotate",
59     "translate",
60     "transform",
61     "setTransform"
62 ];
63
64 /**
65  * @const
66  * @type {Array.<string>}
67  */
68 CanvasRenderingContext2DResource.IgnoreProperties = [
69     "canvas",
70     "currentPath",
71     "createLinearGradient",
72     "createRadialGradient",
73     "createPattern",
74     "save",
75     "restore",
76     "clip",
77     "getLineDash",
78     "setLineDash",
79     // Ignore the properties below.
80     "clearRect",
81     "clearShadow",
82     "createImageData",
83     "drawImage",
84     "drawImageFromRect",
85     "fill",
86     "fillRect",
87     "fillText",
88     "getContextAttributes",
89     "getImageData",
90     "isPointInPath",
91     "isPointInStroke",
92     "measureText",
93     "putImageData",
94     "setAlpha",
95     "setCompositeOperation",
96     "setFillColor",
97     "setLineCap",
98     "setLineJoin",
99     "setLineWidth",
100     "setMiterLimit",
101     "setShadow",
102     "setStrokeColor",
103     "stroke",
104     "strokeRect",
105     "strokeText",
106     "webkitBackingStorePixelRatio",
107     "webkitGetImageDataHD",
108     "webkitPutImageDataHD"
109 ];
110
111 function collectPropertyNames(obj)
112 {
113     var propertyNames = [];
114     for (var property in obj)
115         propertyNames.push(property);
116     propertyNames.sort();
117     return propertyNames;
118 }
119
120 function test()
121 {
122     var canvas = document.createElement("canvas");
123     var ctx = canvas.getContext("2d");
124     if (!ctx) {
125         output("ERROR: Could not create canvas 2D context.");
126         return;
127     }
128     output("New properties and functions that should be manually examined (should be empty to pass the test):");
129     var propertyNames = collectPropertyNames(ctx);
130     var trackedProperties = CanvasRenderingContext2DResource.AttributeProperties.concat(CanvasRenderingContext2DResource.PathMethods, CanvasRenderingContext2DResource.TransformationMatrixMethods, CanvasRenderingContext2DResource.IgnoreProperties);
131     for (var i = 0; i < propertyNames.length; ++i) {
132         var property = propertyNames[i];
133         if (trackedProperties.indexOf(property) !== -1)
134             continue;
135         output(property);
136     }
137
138     var gradient = ctx.createLinearGradient(0, 0, 1, 1);
139     if (!gradient) {
140         output("ERROR: Could not create a gradient object.");
141         return;
142     }
143     output("New properties and functions of CanvasGradient object that should be manually examined (should be empty to pass the test):");
144     propertyNames = collectPropertyNames(gradient);
145     for (var i = 0; i < propertyNames.length; ++i) {
146         var property = propertyNames[i];
147         if (property === "addColorStop")
148             continue;
149         output(property);
150     }
151
152     var pattern = ctx.createPattern(new Image(), "repeat");
153     if (!pattern) {
154         output("ERROR: Could not create a pattern object.");
155         return;
156     }
157     output("New properties and functions of CanvasPattern object that should be manually examined (should be empty to pass the test):");
158     for (var property in pattern)
159         output(property);
160 }
161
162 function runTest()
163 {
164     if (window.testRunner) {
165         testRunner.dumpAsText();
166         testRunner.waitUntilDone();
167     }
168     try {
169         test();
170     } finally {
171         if (window.testRunner)
172             testRunner.notifyDone();
173     }
174 }
175
176 </script>
177 </head>
178 <body onload="runTest()">
179 <p>
180 Test to catch Canvas 2D API changes.
181 If this test should ever fail, we should re-examine the Canvas 2D state saving/restoring logic in the
182 InjectedScriptModule to include any latest changes to the API.
183
184 </p>
185 </body>
186 </html>