Bug 1492704 - 1. Update auto-fill then selecting tabs; r=petru
authorJim Chen <nchen@mozilla.com>
Thu, 04 Oct 2018 20:41:37 +0000
changeset 495451 7b49a74b30e60b6e030bb3e23b444f8eac0ca715
parent 495450 3be82e46d044dc1082fc28cded2deb15bb92acc2
child 495452 538da6bb518b6a794a81ea76584c190dd66e17e9
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspetru
bugs1492704
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1492704 - 1. Update auto-fill then selecting tabs; r=petru Update auto-fill info when selecting tabs. Also for auto-fill focus and page events, only handle those events for the foreground tab, so events from background tabs don't inadvertently affect auto-fill for the foreground tab. Differential Revision: https://phabricator.services.mozilla.com/D6757
mobile/android/chrome/content/browser.js
mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -3768,16 +3768,17 @@ Tab.prototype = {
     this.browser.addEventListener("DOMWillOpenModalDialog", this, true);
     this.browser.addEventListener("pagehide", this, true);
     this.browser.addEventListener("pageshow", this, true);
     this.browser.addEventListener("MozApplicationManifest", this, true);
     this.browser.addEventListener("TabPreZombify", this, true);
     this.browser.addEventListener("DOMWindowFocus", this, true);
     this.browser.addEventListener("focusin", this, true);
     this.browser.addEventListener("focusout", this, true);
+    this.browser.addEventListener("TabSelect", this, true);
 
     // Note that the XBL binding is untrusted
     this.browser.addEventListener("VideoBindingAttached", this, true, true);
     this.browser.addEventListener("VideoBindingCast", this, true, true);
 
     Services.obs.addObserver(this, "audioFocusChanged", false);
     Services.obs.addObserver(this, "before-first-paint");
     Services.obs.addObserver(this, "media-playback");
@@ -3906,16 +3907,17 @@ Tab.prototype = {
     this.browser.removeEventListener("DOMWillOpenModalDialog", this, true);
     this.browser.removeEventListener("pagehide", this, true);
     this.browser.removeEventListener("pageshow", this, true);
     this.browser.removeEventListener("MozApplicationManifest", this, true);
     this.browser.removeEventListener("TabPreZombify", this, true);
     this.browser.removeEventListener("DOMWindowFocus", this, true);
     this.browser.removeEventListener("focusin", this, true);
     this.browser.removeEventListener("focusout", this, true);
+    this.browser.removeEventListener("TabSelect", this, true);
 
     this.browser.removeEventListener("VideoBindingAttached", this, true, true);
     this.browser.removeEventListener("VideoBindingCast", this, true, true);
 
     Services.obs.removeObserver(this, "audioFocusChanged");
     Services.obs.removeObserver(this, "before-first-paint");
     Services.obs.removeObserver(this, "media-playback");
 
@@ -4435,38 +4437,48 @@ Tab.prototype = {
           type: "Tab:Select",
           tabID: this.id,
           foreground: true,
         });
         break;
       }
 
       case "focusin": {
-        if (aEvent.composedTarget instanceof HTMLInputElement) {
+        if (BrowserApp.selectedTab === this &&
+            aEvent.composedTarget instanceof HTMLInputElement) {
           this._autoFill.onFocus(aEvent.composedTarget);
         }
         break;
       }
 
       case "focusout": {
-        if (aEvent.composedTarget instanceof HTMLInputElement) {
+        if (BrowserApp.selectedTab === this &&
+            aEvent.composedTarget instanceof HTMLInputElement) {
           this._autoFill.onFocus(null);
         }
         break;
       }
 
+      case "TabSelect": {
+        this._autoFill.clearElements();
+        this._autoFill.scanDocument(this.browser.contentDocument);
+        break;
+      }
+
       case "pagehide": {
-        if (aEvent.target === this.browser.contentDocument) {
+        if (BrowserApp.selectedTab === this &&
+            aEvent.target === this.browser.contentDocument) {
           this._autoFill.clearElements();
         }
         break;
       }
 
       case "pageshow": {
-        if (aEvent.target === this.browser.contentDocument && aEvent.persisted) {
+        if (BrowserApp.selectedTab === this &&
+            aEvent.target === this.browser.contentDocument && aEvent.persisted) {
           this._autoFill.scanDocument(aEvent.target);
         }
 
         // The rest of this only handles pageshow for the top-level document.
         if (aEvent.originalTarget.defaultView != this.browser.contentWindow)
           return;
 
         GlobalEventDispatcher.sendRequest({
--- a/mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewAutoFill.jsm
@@ -62,17 +62,17 @@ class GeckoViewAutoFill {
       task.arm();
       if (!this._autoFillTasks) {
         this._autoFillTasks = new WeakMap();
       }
       this._autoFillTasks.set(aFormLike.rootElement, task);
       return;
     }
 
-    debug `Adding auto-fill ${aFormLike}`;
+    debug `Adding auto-fill ${aFormLike.rootElement.tagName}`;
 
     this._autoFillTasks.delete(aFormLike.rootElement);
 
     if (!this._autoFillInfos) {
       this._autoFillInfos = new WeakMap();
       this._autoFillElements = new Map();
     }