Bug 1463576 - 2. Add test-only geckoview.selection_action.show_on_focus pref; r=me
Add the "geckoview.selection_action.show_on_focus" pref for testing
only. The pref makes us show selection actions when the selection is
initially collapsed in an editor, which makes it easier to test behavior
for collapsed selections.
MozReview-Commit-ID: 3U6UfzokHaI
--- a/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
+++ b/mobile/android/chrome/geckoview/GeckoViewSelectionActionContent.js
@@ -141,17 +141,19 @@ class GeckoViewSelectionActionContent ex
// For mozcaretstatechanged, "visibilitychange" means the caret is hidden.
reason = "visibilitychange";
} else if (!aEvent.collapsed &&
!aEvent.selectionVisible) {
reason = "invisibleselection";
} else if (aEvent.selectionEditable &&
aEvent.collapsed &&
reason !== "longpressonemptycontent" &&
- reason !== "taponcaret") {
+ reason !== "taponcaret" &&
+ !Services.prefs.getBoolPref(
+ "geckoview.selection_action.show_on_focus", false)) {
// Don't show selection actions when merely focusing on an editor or
// repositioning the cursor. Wait until long press or the caret is tapped
// in order to match Android behavior.
reason = "visibilitychange";
}
debug `handleEvent: ${reason}`;
@@ -200,20 +202,22 @@ class GeckoViewSelectionActionContent ex
this._previousMessage = JSON.stringify(msg);
// This event goes to GeckoViewSelectionAction.jsm, where the data is
// further transformed and then sent to GeckoSession.
this.eventDispatcher.sendRequest(msg, {
onSuccess: response => {
if (response.seqNo !== this._seqNo) {
// Stale action.
+ warn `Stale response ${response.id}`;
return;
}
let action = actions.find(action => action.id === response.id);
if (action) {
+ debug `Performing ${response.id}`;
action.perform.call(this, aEvent, response);
} else {
warn `Invalid action ${response.id}`;
}
},
onError: _ => {
// Do nothing; we can get here if the delegate was just unregistered.
},