Bug 1623476 - Scroll element into view before simulating a click on it in test_bug500885.html. r=kats

The top-level document containing the iframe in which the test runs can be
scrolled by things that happen in previous tests (e.g. a zoomToFocusedInput
in a previous test), causing the target element to be outside of the visual
viewport.

After bug 1556556, event synthesization functions will no longer support
targeting elements outside the visual viewport.

Differential Revision: https://phabricator.services.mozilla.com/D67523

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2020-03-23 22:24:42 +00:00
parent 7208849141
commit 7c3a542e38
2 changed files with 23 additions and 11 deletions

View File

@ -189,6 +189,7 @@ support-files =
object_bug287465_o2.html
object_bug556645.html
file.webm
!/gfx/layers/apz/test/mochitest/apz_test_utils.js
[test_a_text.html]
[test_anchor_href_cache_invalidation.html]

View File

@ -7,6 +7,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=500885
<title>Test for Bug 500885</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<script type="text/javascript" src="/tests/gfx/layers/apz/test/mochitest/apz_test_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
@ -36,17 +38,26 @@ function test() {
domActivateEvents++;
});
domActivateEvents = 0;
wu.sendMouseEvent("mousedown", rect.left + 5, rect.top + 5, 0, 1, 0);
wu.sendMouseEvent("mouseup", rect.left + 5, rect.top + 5, 0, 1, 0);
is(domActivateEvents, 1, "click on button should fire 1 DOMActivate event");
domActivateEvents = 0;
wu.sendMouseEvent("mousedown", rect.right - 5, rect.top + 5, 0, 1, 0);
wu.sendMouseEvent("mouseup", rect.right - 5, rect.top + 5, 0, 1, 0);
is(domActivateEvents, 1, "click on text field should fire 1 DOMActivate event");
} finally {
fileInput.scrollIntoView({ behaviour: "smooth" });
waitForApzFlushedRepaints(function() {
try {
domActivateEvents = 0;
wu.sendMouseEvent("mousedown", rect.left + 5, rect.top + 5, 0, 1, 0);
wu.sendMouseEvent("mouseup", rect.left + 5, rect.top + 5, 0, 1, 0);
is(domActivateEvents, 1, "click on button should fire 1 DOMActivate event");
domActivateEvents = 0;
wu.sendMouseEvent("mousedown", rect.right - 5, rect.top + 5, 0, 1, 0);
wu.sendMouseEvent("mouseup", rect.right - 5, rect.top + 5, 0, 1, 0);
is(domActivateEvents, 1, "click on text field should fire 1 DOMActivate event");
} finally {
SimpleTest.executeSoon(function() {
MockFilePicker.cleanup();
SimpleTest.finish();
});
}
});
} catch {
SimpleTest.executeSoon(function() {
MockFilePicker.cleanup();
SimpleTest.finish();