1 description("This tests that page scaling and CSS transforms do not affect mouse event pageX and pageY coordinates for " +
2 "content embedded in an iframe.");
4 var html = document.documentElement;
6 var iframe = document.createElement("iframe");
7 iframe.style.border = "none";
8 iframe.style.width = "200px";
9 iframe.style.height = "200px";
10 iframe.style.background = "green";
12 var div = document.createElement("div");
13 div.style.width = "100px";
14 div.style.height = "100px";
15 div.style.backgroundColor = "blue";
19 function appendEventLog(event) {
20 var msg = event.type + "(" + event.pageX + ", " + event.pageY + ")";
22 if (window.eventSender) {
29 function clearEventLog() {
33 function sendEvents(button) {
34 if (!window.eventSender) {
35 debug("This test requires the EventSender API (provided by, for example, DumpRenderTree or WebKitTestRunner). Click on the blue rect with the left mouse button to log the mouse coordinates.")
38 eventSender.mouseDown(button);
39 eventSender.mouseUp(button);
42 function testEvents(button, description, expectedString) {
45 shouldBeEqualToString("eventLog", expectedString);
50 function iframeLoaded() {
51 // Add the div to the iframe.
52 div.addEventListener("click", appendEventLog, false);
53 iframe.contentWindow.document.body.insertBefore(div, iframe.contentWindow.document.body.firstChild);
55 if (window.eventSender && window.internals) {
56 eventSender.mouseMoveTo(10, 10);
57 // We are clicking in the same position on screen. As we scale or transform the page,
58 // we expect the pageX and pageY event coordinates to change because different
59 // parts of the document are under the mouse.
61 testEvents(0, "Unscaled", "click(10, 10)");
63 window.internals.setPageScaleFactorLimits(0.5, 0.5);
64 window.internals.setPageScaleFactor(0.5);
65 testEvents(0, "setPageScale(0.5)", "click(20, 20)");
67 window.internals.setPageScaleFactorLimits(1, 1);
68 window.internals.setPageScaleFactor(1.0);
69 html.style["-webkit-transform"] = "scale(0.5, 2.0)";
70 html.style["-webkit-transform-origin"] = "0 0";
71 testEvents(0, "CSS scale(0.5, 2.0)", "click(20, 5)");
73 window.internals.setPageScaleFactorLimits(0.5, 0.5);
74 window.internals.setPageScaleFactor(0.5);
75 testEvents(0, "setPageScale(0.5), CSS scale(0.5, 2.0)", "click(40, 10)");
81 // Mouse events only work after an initial layout
82 document.body.offsetLeft;
84 // Add the iframe to the document.
85 iframe.src = "resources/page-scaled-mouse-click-iframe-inner.html";
86 document.body.insertBefore(iframe, document.body.firstChild);
88 window.jsTestIsAsync = true;