From: <mgu...@us...> - 2013-02-06 07:43:26
|
Revision: 8097 http://sourceforge.net/p/htmlunit/code/8097 Author: mguillem Date: 2013-02-06 07:43:21 +0000 (Wed, 06 Feb 2013) Log Message: ----------- JavaScript: add empty implementations of CanvasRenderingContext2D methods createImageData, createPattern, createRadialGradient, fillText, getImageData, getLineData, isPointInPath, measureText, putImageData, rect, rotate, setTransform, strokeText, and transform (FF). Modified Paths: -------------- trunk/htmlunit/src/changes/changes.xml trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java Modified: trunk/htmlunit/src/changes/changes.xml =================================================================== --- trunk/htmlunit/src/changes/changes.xml 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/changes/changes.xml 2013-02-06 07:43:21 UTC (rev 8097) @@ -8,6 +8,11 @@ <body> <release version="2.12" date="???" description="Bugfixes, CSS3 Selectors"> + <action type="fix" dev="mguillem"> + JavaScript: add empty implementations of CanvasRenderingContext2D methods createImageData, + createPattern, createRadialGradient, fillText, getImageData, getLineData, isPointInPath, + measureText, putImageData, rect, rotate, setTransform, strokeText, and transform (FF). + </action> <action type="fix" dev="rbri"> Support for CSS pseudo selector ':target' added. </action> Modified: trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java =================================================================== --- trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/main/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2D.java 2013-02-06 07:43:21 UTC (rev 8097) @@ -322,4 +322,116 @@ final Context context, final Scriptable thisObj, final Object[] args, final Function function) { //empty } + + /** + * Creates a new, blank ImageData object with the specified dimensions. + */ + @JsxFunction + public void createImageData() { + //empty + } + + /** + * Creates a pattern. + */ + @JsxFunction + public void createPattern() { + //empty + } + + /** + * Creates a gradient. + */ + @JsxFunction + public void createRadialGradient() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void fillText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void getImageData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void getLineData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void isPointInPath() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void measureText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void putImageData() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void rect() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void rotate() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void setTransform() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void strokeText() { + //empty + } + + /** + * Dummy placeholder. + */ + @JsxFunction + public void transform() { + //empty + } } Modified: trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java =================================================================== --- trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2013-02-05 13:29:25 UTC (rev 8096) +++ trunk/htmlunit/src/test/java/com/gargoylesoftware/htmlunit/javascript/host/canvas/CanvasRenderingContext2DTest.java 2013-02-06 07:43:21 UTC (rev 8097) @@ -14,6 +14,7 @@ */ package com.gargoylesoftware.htmlunit.javascript.host.canvas; +import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.junit.runner.RunWith; @@ -58,6 +59,7 @@ + " ctx.lineTo(10, 10);\n" + " ctx.quadraticCurveTo(0, 10, 15, 10);\n" + " ctx.closePath();\n" + + " ctx.rotate(1.234);\n" + " alert('done');\n" + " } catch(e) { alert('exception'); }\n" + "}\n" @@ -67,4 +69,38 @@ + "</html>"; loadPageWithAlerts2(html); } + + /** + * @throws Exception if an error occurs + */ + @Test + @Alerts(FF = { "drawCustomFocusRing", "drawSystemFocusRing", "getLineDash", "scrollPathIntoView", "setLineDash", + "33 methods" }, + IE = "exception") + public void methods() throws Exception { + final String[] methods = {"arc", "arcTo", "beginPath", "bezierCurveTo", "clearRect", "clip", "closePath", + "createImageData", "createLinearGradient", "createPattern", "createRadialGradient", "drawImage", + "drawCustomFocusRing", "drawSystemFocusRing", "fill", "fillRect", "fillText", "getImageData", + "getLineDash", "isPointInPath", "lineTo", "measureText", "moveTo", "putImageData", "quadraticCurveTo", + "rect", "restore", "rotate", "save", "scale", "scrollPathIntoView", "setLineDash", "setTransform", + "stroke", "strokeRect", "strokeText", "transform", "translate" }; + final String html = "<html><body>\n" + + "<canvas id='myCanvas'></canvas>\n" + + "<script>\n" + + " var canvas = document.getElementById('myCanvas');\n" + + " var nbMethods = 0;\n" + + " var methods = ['" + StringUtils.join(methods, "', '") + "'];\n" + + " try {\n" + + " var ctx = canvas.getContext('2d');\n" + + " for (var i=0; i<methods.length; ++i) {\n" + + " if (typeof ctx[methods[i]] == 'function')\n" + + " nbMethods++;\n" + + " else\n" + + " alert(methods[i]);\n" + + " }\n" + + " alert(nbMethods + ' methods');\n" + + " } catch(e) { alert('exception'); }\n" + + "</script></body></html>"; + loadPageWithAlerts2(html); + } } |