Index: LayoutTests/svg/hittest/pointer-events-all.html |
diff --git a/LayoutTests/svg/hittest/pointer-events-all.html b/LayoutTests/svg/hittest/pointer-events-all.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e648dfd7fb16b4a0c4f42b1fd88a0184bca786f4 |
--- /dev/null |
+++ b/LayoutTests/svg/hittest/pointer-events-all.html |
@@ -0,0 +1,178 @@ |
+<!DOCTYPE html> |
+Regression test for <a href="http://crbug.com/350338">http://crbug.com/350338</a>. This tests pointer-events:all on various shapes to make sure that the values of the 'fill' and 'stroke' properties do not affect event processing. If this test passes, you will see "PASS" below. |
+<p id="result">Running test...</p> |
+<style> |
+body { |
+ height: 1000px; |
+} |
+.testShape { |
+ pointer-events: all; |
+} |
+</style> |
+<svg id="svg" width="690" height="400" version="1.1"> |
+ <!-- fill:none --> |
+ <rect id="rect1" class="testShape" x="20" y="30" width="60" height="40" stroke="#000" stroke-width="10" fill="none"/> |
+ <ellipse id="ellipse1" class="testShape" cx="150" cy="50" rx="20" ry="35" transform="rotate(20 150 50)" stroke="#000" stroke-width="10" fill="none"/> |
+ <line id="line1" class="testShape" x1="220" y1="20" x2="280" y2="80" stroke="#000" stroke-width="10" fill="none"/> |
+ <polyline id="polyline1" class="testShape" points="320,20 380,40 350,60 380,80 310,80" stroke="#000" stroke-width="10" fill="none"/> |
+ <polygon id="polygon1" class="testShape" points="430,30 440,60 460,80 490,30 460,20" stroke="#000" stroke-width="10" fill="none"/> |
+ <path id="path1" class="testShape" d="M610,20 a100 100 0 0 0 -70 70 a100 100 0 0 0 70 -70 z" stroke="#000" stroke-width="10" fill="none"/> |
+ |
+ <!-- stroke:none --> |
+ <rect id="rect2" class="testShape" x="20" y="130" width="60" height="40" stroke="none" stroke-width="10" fill="#ccc"/> |
+ <ellipse id="ellipse2" class="testShape" cx="150" cy="150" rx="20" ry="35" transform="rotate(20 150 150)" stroke="none" stroke-width="10" fill="#ccc"/> |
+ <line id="line2" class="testShape" x1="220" y1="120" x2="280" y2="180" stroke="none" stroke-width="10" fill="#ccc"/> |
+ <polyline id="polyline2" class="testShape" points="320,120 380,140 350,160 380,180 310,180" stroke="none" stroke-width="10" fill="#ccc"/> |
+ <polygon id="polygon2" class="testShape" points="430,130 440,160 460,180 490,130 460,120" stroke="none" stroke-width="10" fill="#ccc"/> |
+ <path id="path2" class="testShape" d="M610,120 a100 100 0 0 0 -70 70 a100 100 0 0 0 70 -70 z" stroke="none" stroke-width="10" fill="#ccc"/> |
+ |
+ <use id="useRect1" xlink:href="#rect1" class="testShape" y="200"/> |
+ <use id="useEllipse1" xlink:href="#ellipse1" class="testShape" y="200"/> |
+ <use id="useLine1" xlink:href="#line1" class="testShape" y="200"/> |
+ <use id="usePolyline1" xlink:href="#polyline1" class="testShape" y="200"/> |
+ <use id="usePolygon1" xlink:href="#polygon1" class="testShape" y="200"/> |
+ <use id="usePath1" xlink:href="#path1" class="testShape" y="200"/> |
+ |
+ <use id="useRect2" xlink:href="#rect2" class="testShape" y="200"/> |
+ <use id="useEllipse2" xlink:href="#ellipse2" class="testShape" y="200"/> |
+ <use id="useLine2" xlink:href="#line2" class="testShape" y="200"/> |
+ <use id="usePolyline2" xlink:href="#polyline2" class="testShape" y="200"/> |
+ <use id="usePolygon2" xlink:href="#polygon2" class="testShape" y="200"/> |
+ <use id="usePath2" xlink:href="#path2" class="testShape" y="200"/> |
+</svg> |
+<script type="text/javascript"> |
+if (window.testRunner) { |
+ testRunner.dumpAsText(); |
+ testRunner.waitUntilDone(); |
+} |
+ |
+var svg = document.getElementById("svg"); |
+window.onload = function () { |
+ var tests = [ |
+ { x: 16, y: 36, expectedElemId: "rect1" }, |
+ { x: 54, y: 58, expectedElemId: "rect1" }, |
+ { x: 28, y: 77, expectedElemId: "svg" }, |
+ |
+ { x: 139, y: 20, expectedElemId: "svg" }, |
+ { x: 129, y: 41, expectedElemId: "ellipse1" }, |
+ { x: 149, y: 55, expectedElemId: "ellipse1" }, |
+ { x: 166, y: 70, expectedElemId: "ellipse1" }, |
+ { x: 128, y: 82, expectedElemId: "svg" }, |
+ |
+ { x: 219, y: 19, expectedElemId: "svg" }, |
+ { x: 242, y: 40, expectedElemId: "line1" }, |
+ { x: 253, y: 64, expectedElemId: "svg" }, |
+ |
+ { x: 318, y: 84, expectedElemId: "polyline1" }, |
+ { x: 323, y: 47, expectedElemId: "polyline1" }, |
+ { x: 324, y: 18, expectedElemId: "polyline1" }, |
+ { x: 375, y: 64, expectedElemId: "svg" }, |
+ |
+ { x: 426, y: 28, expectedElemId: "polygon1" }, |
+ { x: 455, y: 44, expectedElemId: "polygon1" }, |
+ { x: 445, y: 71, expectedElemId: "polygon1" }, |
+ { x: 461, y: 85, expectedElemId: "polygon1" }, |
+ { x: 497, y: 26, expectedElemId: "svg" }, |
+ |
+ { x: 536, y: 95, expectedElemId: "path1" }, |
+ { x: 560, y: 70, expectedElemId: "path1" }, |
+ { x: 555, y: 54, expectedElemId: "path1" }, |
+ { x: 595, y: 38, expectedElemId: "path1" }, |
+ { x: 614, y: 16, expectedElemId: "path1" }, |
+ { x: 569, y: 33, expectedElemId: "svg" } |
+ ]; |
+ |
+ // Create a copy of the tests for the stroke:none shapes, which are identical to the shapes |
+ // 100px above except for the 'stroke' and 'fill'. |
+ // Also create a copy of the tests for the stroke:none & fill:none shapes. |
+ var elemIdMap = { |
+ "rect1": "rect2", |
+ "ellipse1": "ellipse2", |
+ "line1": "line2", |
+ "polyline1": "polyline2", |
+ "polygon1": "polygon2", |
+ "path1": "path2" |
+ }; |
+ var extraTests = tests.map(function (test, i, tests) { |
+ return { |
+ x: test.x, |
+ y: 100 + test.y, |
+ expectedElemId: elemIdMap[test.expectedElemId] || test.expectedElemId |
+ }; |
+ }) |
+ tests.push.apply(tests, extraTests); |
+ |
+ // Now copy all of the tests again, for the <use> elements. |
+ elemIdMap = { |
+ "rect1": "useRect1", |
+ "ellipse1": "useEllipse1", |
+ "line1": "useLine1", |
+ "polyline1": "usePolyline1", |
+ "polygon1": "usePolygon1", |
+ "path1": "usePath1", |
+ |
+ "rect2": "useRect2", |
+ "ellipse2": "useEllipse2", |
+ "line2": "useLine2", |
+ "polyline2": "usePolyline2", |
+ "polygon2": "usePolygon2", |
+ "path2": "usePath2" |
+ }; |
+ tests.push.apply(tests, tests.map(function (test, i, tests) { |
+ return { |
+ x: test.x, |
+ y: test.y + 200, |
+ expectedElemId: elemIdMap[test.expectedElemId] || test.expectedElemId |
+ }; |
+ })); |
+ |
+ var bcr = svg.getBoundingClientRect(), |
+ x0 = bcr.left << 0, |
+ y0 = bcr.top << 0; |
+ |
+ for (var i = 0; i < tests.length; ++i) { |
+ var test = tests[i], |
+ elem = document.elementFromPoint(x0 + test.x, y0 + test.y), |
+ expectedElem = document.getElementById(test.expectedElemId), |
+ success; |
+ if (elem !== expectedElem) { |
+ success = false; |
+ result.textContent = "FAIL - unexpected element at (" + test.x + ", " + test.y + ")"; |
+ } else { |
+ success = true; |
+ } |
+ |
+ // Draw a dot and a label at the test point (helps with identification). |
+ markPoint(test.x, test.y, success); |
+ } |
+ |
+ if (result.textContent == "Running test...") |
+ result.textContent = "PASS"; |
+ |
+ if (window.testRunner) |
+ testRunner.notifyDone(); |
+}; |
+ |
+function markPoint(testX, testY, success) { |
+ var dot = document.createElementNS("http://www.w3.org/2000/svg", "circle"); |
+ dot.setAttribute("pointer-events", "none"); |
+ dot.setAttribute("cx", testX); |
+ dot.setAttribute("cy", testY); |
+ dot.setAttribute("r", "2"); |
+ if (success) |
+ dot.setAttribute("fill", "#0c0"); |
+ else |
+ dot.setAttribute("fill", "red"); |
+ svg.appendChild(dot); |
+ var label = document.createElementNS("http://www.w3.org/2000/svg", "text"); |
+ label.setAttribute("pointer-events", "none"); |
+ label.setAttribute("x", testX + 4); |
+ label.setAttribute("y", testY); |
+ label.textContent = "(" + testX + ", " + testY + ")"; |
+ if (success) |
+ label.setAttribute("fill", "#0c0"); |
+ else |
+ label.setAttribute("fill", "red"); |
+ svg.appendChild(label); |
+} |
+</script> |