3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
6 var CanvasRenderingContext2DResource = {};
10 * @type {Array.<string>}
12 CanvasRenderingContext2DResource.AttributeProperties = [
24 "globalCompositeOperation",
29 "imageSmoothingEnabled",
30 "webkitImageSmoothingEnabled",
31 // FIXME: Temporary properties implemented in JSC, but not in V8.
33 "webkitLineDashOffset"
38 * @type {Array.<string>}
40 CanvasRenderingContext2DResource.PathMethods = [
54 * @type {Array.<string>}
56 CanvasRenderingContext2DResource.TransformationMatrixMethods = [
66 * @type {Array.<string>}
68 CanvasRenderingContext2DResource.IgnoreProperties = [
71 "createLinearGradient",
72 "createRadialGradient",
79 // Ignore the properties below.
88 "getContextAttributes",
95 "setCompositeOperation",
106 "webkitBackingStorePixelRatio",
107 "webkitGetImageDataHD",
108 "webkitPutImageDataHD"
111 function collectPropertyNames(obj)
113 var propertyNames = [];
114 for (var property in obj)
115 propertyNames.push(property);
116 propertyNames.sort();
117 return propertyNames;
122 var canvas = document.createElement("canvas");
123 var ctx = canvas.getContext("2d");
125 output("ERROR: Could not create canvas 2D context.");
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)
138 var gradient = ctx.createLinearGradient(0, 0, 1, 1);
140 output("ERROR: Could not create a gradient object.");
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")
152 var pattern = ctx.createPattern(new Image(), "repeat");
154 output("ERROR: Could not create a pattern object.");
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)
164 if (window.testRunner) {
165 testRunner.dumpAsText();
166 testRunner.waitUntilDone();
171 if (window.testRunner)
172 testRunner.notifyDone();
178 <body onload="runTest()">
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.