| Index: LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html
|
| diff --git a/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html b/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html
|
| deleted file mode 100644
|
| index 35e5d57c83d8412714e4e4575a52a0a69160423b..0000000000000000000000000000000000000000
|
| --- a/LayoutTests/inspector/profiler/canvas2d/canvas2d-profiler-capturing-basics.html
|
| +++ /dev/null
|
| @@ -1,311 +0,0 @@
|
| -<html>
|
| -<head>
|
| - <script src="../../../http/tests/inspector/inspector-test.js"></script>
|
| - <script src="../canvas-profiler-test.js"></script>
|
| -<script>
|
| -
|
| -var ctx;
|
| -var rawCtx;
|
| -var ctxResource;
|
| -
|
| -var sampleAttributes1 = {
|
| - "strokeStyle": "#000001",
|
| - "fillStyle": "#000002",
|
| - "globalAlpha": 0.5,
|
| - "lineWidth": 2,
|
| - "lineCap": "round",
|
| - "lineJoin": "bevel",
|
| - "miterLimit": 12,
|
| - "shadowOffsetX": 1,
|
| - "shadowOffsetY": 2,
|
| - "shadowBlur": 3,
|
| - "shadowColor": "#000003",
|
| - "globalCompositeOperation": "source-in",
|
| - "font": "12px sans-serif",
|
| - "textAlign": "end",
|
| - "textBaseline": "top",
|
| - "lineDashOffset": 1
|
| -};
|
| -
|
| -var sampleAttributes2 = {
|
| - "strokeStyle": "#100001",
|
| - "fillStyle": "#100002",
|
| - "globalAlpha": 0,
|
| - "lineWidth": 3,
|
| - "lineCap": "square",
|
| - "lineJoin": "round",
|
| - "miterLimit": 11,
|
| - "shadowOffsetX": 3,
|
| - "shadowOffsetY": 4,
|
| - "shadowBlur": 2,
|
| - "shadowColor": "#100003",
|
| - "globalCompositeOperation": "xor",
|
| - "font": "13px sans-serif",
|
| - "textAlign": "left",
|
| - "textBaseline": "middle",
|
| - "lineDashOffset": 2
|
| -};
|
| -
|
| -function assignAttributes(attributes)
|
| -{
|
| - for (var attribute in attributes)
|
| - ctx[attribute] = attributes[attribute];
|
| -}
|
| -
|
| -function assertAttributes(attributes)
|
| -{
|
| - for (var attribute in attributes)
|
| - console.assert(ctx[attribute] === attributes[attribute], "Expected value for attribute " + attribute + ": " + attributes[attribute] + ", but was: " + ctx[attribute]);
|
| -}
|
| -
|
| -function assertNumberOfCallsInLog(expected)
|
| -{
|
| - var errors = [];
|
| - var calls = ctxResource.calls();
|
| - if (calls.length !== expected.length) {
|
| - var names = [];
|
| - for (var i = 0; calls[i]; ++i)
|
| - names.push(calls[i].functionName());
|
| - errors.push("Expected size of the 2D context call log: " + expected.length + ", but was: " + calls.length + ", names: " + names);
|
| - } else {
|
| - for (var i = 0; i < calls.length; ++i) {
|
| - var name = calls[i].functionName();
|
| - var expectedName = expected[i];
|
| - if (name !== expectedName)
|
| - errors.push("Expected name: " + expectedName + ", but was: " + name + ", at index: " + i);
|
| - }
|
| - }
|
| - if (errors.length)
|
| - console.error("FAIL: " + errors.join("\n ") + "\n " + (new Error).stack);
|
| -}
|
| -
|
| -function testDrawingAttributes()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - assignAttributes(sampleAttributes1);
|
| - assertAttributes(sampleAttributes1);
|
| - assertNumberOfCallsInLog([]);
|
| -
|
| - // Save previous attribute values and set new values.
|
| - ctx.save();
|
| - assignAttributes(sampleAttributes2);
|
| - assertAttributes(sampleAttributes2);
|
| - assertNumberOfCallsInLog(["save"]);
|
| -
|
| - // Restore previous attribute values.
|
| - ctx.restore();
|
| - assertAttributes(sampleAttributes1);
|
| - // Call log should be empty after save() and restore() calls.
|
| - assertNumberOfCallsInLog([]);
|
| -}
|
| -
|
| -function testSaveRestoreSequence()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.restore();
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.save();
|
| - assertNumberOfCallsInLog(["save"]);
|
| - ctx.save();
|
| - assertNumberOfCallsInLog(["save", "save"]);
|
| - ctx.save();
|
| - assertNumberOfCallsInLog(["save", "save", "save"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "save"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.restore();
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog([]);
|
| -}
|
| -
|
| -function callPathMethods()
|
| -{
|
| - ctx.beginPath();
|
| - ctx.lineWidth = 2;
|
| - ctx.moveTo(11, 12);
|
| - ctx.lineTo(111, 112);
|
| - ctx.stroke();
|
| -}
|
| -
|
| -function clearContextResourceLog()
|
| -{
|
| - while (ctxResource.calls().length)
|
| - ctxResource.calls().pop();
|
| - assertNumberOfCallsInLog([]);
|
| -}
|
| -
|
| -function testPathMethodsSequence()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["beginPath", "moveTo", "lineTo"]);
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["beginPath", "moveTo", "lineTo"]); // old methods should have been cleared
|
| - ctx.ellipse(100, 100, 50, 75, 45, 0, 2 * Math.PI);
|
| - ctx.stroke();
|
| - assertNumberOfCallsInLog(["beginPath", "moveTo", "lineTo", "ellipse"]);
|
| - clearContextResourceLog();
|
| -}
|
| -
|
| -function testClipMethods()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.save();
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["save", "beginPath", "moveTo", "lineTo"]);
|
| - ctx.clip();
|
| - assertNumberOfCallsInLog(["save", "beginPath", "moveTo", "lineTo", "clip"]);
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["save", "beginPath", "moveTo", "lineTo", "clip", "beginPath", "moveTo", "lineTo"]);
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["save", "beginPath", "moveTo", "lineTo", "clip", "beginPath", "moveTo", "lineTo"]); // the last calls should have been cleared
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "beginPath", "moveTo", "lineTo", "restore"]);
|
| - ctx.beginPath();
|
| - assertNumberOfCallsInLog(["beginPath"]);
|
| - clearContextResourceLog();
|
| -}
|
| -
|
| -function testMatrixMethods()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.save();
|
| - ctx.translate(100, 200);
|
| - ctx.scale(0.9, 0.9);
|
| - ctx.rotate(0.2);
|
| - ctx.translate(-100, -200);
|
| - assertNumberOfCallsInLog(["save", "translate", "scale", "rotate", "translate"]);
|
| - ctx.setTransform(1, 2, 3, 4, 5, 6);
|
| - ctx.rotate(0.3);
|
| - assertNumberOfCallsInLog(["save", "setTransform", "rotate"]);
|
| - ctx.resetTransform();
|
| - assertNumberOfCallsInLog(["save", "resetTransform"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog([]);
|
| -}
|
| -
|
| -function testMatrixMethodsWithPathMethods()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.save();
|
| - ctx.translate(100, 200);
|
| - ctx.scale(0.9, 0.9);
|
| - ctx.rotate(0.2);
|
| - ctx.translate(-100, -200);
|
| - assertNumberOfCallsInLog(["save", "translate", "scale", "rotate", "translate"]);
|
| - ctx.beginPath();
|
| - ctx.rect(1, 1, 10, 10);
|
| - ctx.translate(1, 2);
|
| - assertNumberOfCallsInLog(["save", "translate", "scale", "rotate", "translate", "beginPath", "rect", "translate"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "translate", "scale", "rotate", "translate", "beginPath", "rect", "restore"]);
|
| - ctx.beginPath();
|
| - assertNumberOfCallsInLog(["beginPath"]);
|
| - clearContextResourceLog();
|
| -}
|
| -
|
| -function testNestedSaveRestoreCalls()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - ctx.save();
|
| - ctx.translate(100, 200);
|
| - ctx.beginPath();
|
| - ctx.rect(1, 1, 10, 10);
|
| - ctx.clip();
|
| - ctx.save();
|
| - ctx.rotate(0.2);
|
| - callPathMethods();
|
| - assertNumberOfCallsInLog(["save", "translate", "beginPath", "rect", "clip", "save", "rotate", "beginPath", "moveTo", "lineTo"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "translate", "beginPath", "rect", "clip", "save", "rotate", "beginPath", "moveTo", "lineTo", "restore"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "translate", "save", "rotate", "beginPath", "moveTo", "lineTo", "restore", "restore"]);
|
| - ctx.restore();
|
| - assertNumberOfCallsInLog(["save", "translate", "save", "rotate", "beginPath", "moveTo", "lineTo", "restore", "restore"]); // no effect
|
| - ctx.setTransform(1, 2, 3, 4, 5, 6);
|
| - assertNumberOfCallsInLog(["save", "translate", "save", "rotate", "beginPath", "moveTo", "lineTo", "restore", "restore", "setTransform"]); // nothing to remove from the log
|
| - ctx.beginPath();
|
| - assertNumberOfCallsInLog(["setTransform", "beginPath"]);
|
| - clearContextResourceLog();
|
| -}
|
| -
|
| -function testDeepNestedSaveRestoreCalls()
|
| -{
|
| - assertNumberOfCallsInLog([]);
|
| - var expected = [];
|
| - for (var i = 0; i < 10; ++i) {
|
| - ctx.save();
|
| - ctx.translate(1, 2);
|
| - expected.push("save", "translate");
|
| - }
|
| - assertNumberOfCallsInLog(expected);
|
| - callPathMethods();
|
| - expected.push("beginPath", "moveTo", "lineTo");
|
| - assertNumberOfCallsInLog(expected);
|
| - for (var i = 0; i < 10; ++i) {
|
| - ctx.rotate(1);
|
| - ctx.scale(2, 2);
|
| - ctx.clip();
|
| - ctx.transform(3, 3, 3, 3, 3, 3);
|
| - ctx.restore();
|
| - expected.push("restore");
|
| - assertNumberOfCallsInLog(expected);
|
| - }
|
| - assertNumberOfCallsInLog(expected);
|
| - ctx.beginPath();
|
| - assertNumberOfCallsInLog(["beginPath"]); // now clear up the log
|
| - clearContextResourceLog();
|
| -}
|
| -
|
| -function createAndRunCanvas2DProgram()
|
| -{
|
| - ctx = createCanvas2DContext();
|
| - console.assert(ctx, "Failed to create 2D context");
|
| -
|
| - ctxResource = ctx["__resourceObject"];
|
| - console.assert(ctxResource, "2D context is not wrapped");
|
| -
|
| - rawCtx = ctxResource.wrappedObject();
|
| - console.assert(rawCtx, "No raw 2D context found");
|
| - console.assert(ctx !== rawCtx, "Proxy and RAW contexts should not be the same");
|
| -
|
| - testDrawingAttributes();
|
| - testSaveRestoreSequence();
|
| - testPathMethodsSequence();
|
| - testClipMethods();
|
| - testMatrixMethods();
|
| - testMatrixMethodsWithPathMethods();
|
| - testNestedSaveRestoreCalls();
|
| - testDeepNestedSaveRestoreCalls();
|
| -
|
| - return "SUCCESS";
|
| -}
|
| -
|
| -function test()
|
| -{
|
| - InspectorTest.enableCanvasAgent(step1);
|
| - function step1()
|
| - {
|
| - InspectorTest.evaluateInPage("createAndRunCanvas2DProgram()", step2);
|
| - }
|
| - function step2(error)
|
| - {
|
| - InspectorTest.assertEquals("SUCCESS", error.description);
|
| - InspectorTest.completeTest();
|
| - }
|
| -}
|
| -
|
| -</script>
|
| -</head>
|
| -<body onload="runTest()">
|
| -<p>
|
| -Tests Canvas 2D capturing basics.
|
| -</p>
|
| -<a href="https://bugs.webkit.org/show_bug.cgi?id=100752">Bug 100752</a>
|
| -
|
| -</body>
|
| -</html>
|
|
|