mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1692110 part 3: Don't run accessibility checks for click events generated by drag/drop. r=places-reviewers,ayeddi,Gijs,Standard8
Drag/drop generates click events, but these aren't actually a click event intended to activate a control. Therefore, we don't want to run accessibility checks for the target. To achieve this, EventUtils.synthesizeDropAfterDragOver instructs AccessibilityUtils to ignore click events while the event is being sent. This requires that EventUtils has the reference to AccessibilityUtils set by the browser test harness. As such, some tests had to be adjusted so that they use EventUtils from the browser test scope, rather than loading their own copy of EventUtils. Differential Revision: https://phabricator.services.mozilla.com/D185776
This commit is contained in:
parent
7648dc6ca0
commit
8197fa684d
@ -1,12 +1,6 @@
|
||||
async function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
let EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
// ---- Test dragging the proxy icon ---
|
||||
var value = content.location.href;
|
||||
var urlString = value + "\n" + content.document.title;
|
||||
|
@ -19,12 +19,6 @@ add_task(async function () {
|
||||
|
||||
await pushPrefs([HOMEPAGE_PREF, "about:mozilla"]);
|
||||
|
||||
let EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
// Since synthesizeDrop triggers the srcElement, need to use another button
|
||||
// that should be visible.
|
||||
let dragSrcElement = document.getElementById("sidebar-button");
|
||||
|
@ -180,11 +180,6 @@ async function drop(dragData, expectedURLs) {
|
||||
info(
|
||||
`Starting test for dragData:${dragDataString}; expectedURLs.length:${expectedURLs.length}`
|
||||
);
|
||||
let EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
// Since synthesizeDrop triggers the srcElement, need to use another button
|
||||
// that should be visible.
|
||||
|
@ -189,11 +189,6 @@ async function drop(dragData, expectedURLs, ignoreFirstWindow = false) {
|
||||
info(
|
||||
`Starting test for dragData:${dragDataString}; expectedURLs.length:${expectedURLs.length}`
|
||||
);
|
||||
let EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
// Since synthesizeDrop triggers the srcElement, need to use another button
|
||||
// that should be visible.
|
||||
|
@ -163,11 +163,6 @@ async function drop(dragData, expectedURLs) {
|
||||
info(
|
||||
`Starting test for dragData:${dragDataString}; expectedURLs.length:${expectedURLs.length}`
|
||||
);
|
||||
let EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
let awaitDrop = BrowserTestUtils.waitForEvent(gBrowser.tabContainer, "drop");
|
||||
|
||||
|
@ -4,12 +4,6 @@
|
||||
|
||||
requestLongerTimeout(2);
|
||||
|
||||
const EVENTUTILS_URL =
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js";
|
||||
var EventUtils = {};
|
||||
|
||||
Services.scriptloader.loadSubScript(EVENTUTILS_URL, EventUtils);
|
||||
|
||||
/**
|
||||
* Tests that tabs from Private Browsing windows cannot be dragged
|
||||
* into non-private windows, and vice-versa.
|
||||
|
@ -10,12 +10,6 @@ ChromeUtils.defineESModuleGetters(this, {
|
||||
"resource://testing-common/CustomizableUITestUtils.sys.mjs",
|
||||
});
|
||||
|
||||
var EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
/**
|
||||
* Instance of CustomizableUITestUtils for the current browser window.
|
||||
*/
|
||||
|
@ -1,12 +1,5 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
// Instead of loading EventUtils.js into the test scope in browser-test.js for all tests,
|
||||
// we only need EventUtils.js for a few files which is why we are using loadSubScript.
|
||||
var EventUtils = {};
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js",
|
||||
EventUtils
|
||||
);
|
||||
|
||||
add_task(async function test() {
|
||||
// Make sure the bookmarks bar is visible and restore its state on cleanup.
|
||||
|
@ -653,6 +653,7 @@ this.AccessibilityUtils = (function () {
|
||||
},
|
||||
|
||||
init() {
|
||||
this._shouldHandleClicks = true;
|
||||
// A top level xul window's DocShell doesn't have a chromeEventHandler
|
||||
// attribute. In that case, the chrome event handler is just the global
|
||||
// window object.
|
||||
@ -666,7 +667,21 @@ this.AccessibilityUtils = (function () {
|
||||
this._handler = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Suppress (or disable suppression of) handling of captured click events.
|
||||
* This should only be called by EventUtils, etc. when a click event will
|
||||
* be generated but we know it is not actually a click intended to activate
|
||||
* a control; e.g. drag/drop. Tests that wish to disable specific checks
|
||||
* should use setEnv instead.
|
||||
*/
|
||||
suppressClickHandling(shouldSuppress) {
|
||||
this._shouldHandleClicks = !shouldSuppress;
|
||||
},
|
||||
|
||||
handleEvent({ composedTarget }) {
|
||||
if (!this._shouldHandleClicks) {
|
||||
return;
|
||||
}
|
||||
const bounds =
|
||||
composedTarget.ownerGlobal?.windowUtils?.getBoundsWithoutFlushing(
|
||||
composedTarget
|
||||
|
@ -2979,7 +2979,14 @@ function synthesizeDropAfterDragOver(
|
||||
);
|
||||
sendDragEvent(event, aDestElement, aDestWindow);
|
||||
}
|
||||
// Don't run accessibility checks for this click, since we're not actually
|
||||
// clicking. It's just generated as part of the drop.
|
||||
// this.AccessibilityUtils might not be set if this isn't a browser test or
|
||||
// if a browser test has loaded its own copy of EventUtils for some reason.
|
||||
// In the latter case, the test probably shouldn't do that.
|
||||
this.AccessibilityUtils?.suppressClickHandling(true);
|
||||
synthesizeMouse(aDestElement, 2, 2, { type: "mouseup" }, aDestWindow);
|
||||
this.AccessibilityUtils?.suppressClickHandling(false);
|
||||
|
||||
return effect;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user