Bug 1158496 - JavaScript error: nsSuiteGlue.js, line 291: NS_NOINTERFACE: Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsIWebProgress.DOMWindow] r=Neil
authorPhilip Chee <philip.chee@gmail.com>
Tue, 23 Jun 2015 22:15:21 +0800
changeset 22803 33c0832f86e06bcb95b626f06e1cd12f6029db15
parent 22802 1fafcee93411a4bc9ef99eda31887bf5809887c7
child 22804 cd3b2d6056ab91b53edead971c71205a55ed2cf4
push id1443
push usermbanner@mozilla.com
push dateMon, 10 Aug 2015 18:31:17 +0000
treeherdercomm-beta@8fe07d686c22 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs1158496, 762593, 1149975
Bug 1158496 - JavaScript error: nsSuiteGlue.js, line 291: NS_NOINTERFACE: Component returned failure code: 0x80004002 (NS_NOINTERFACE) [nsIWebProgress.DOMWindow] r=Neil Also ports TOOLKIT patch from Bug 762593 - Add logic for validating if password input fields are insecure Also ports Bug 1149975 - Part 1 of 2 - Handle visibility of the login fill doorhanger anchor.
suite/browser/content.js
suite/browser/jar.mn
suite/common/src/nsSuiteGlue.js
new file mode 100644
--- /dev/null
+++ b/suite/browser/content.js
@@ -0,0 +1,36 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* This content script should work in any browser or iframe and should not
+ * depend on the frame being contained in tabbrowser. */
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "LoginManagerContent",
+  "resource://gre/modules/LoginManagerContent.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "InsecurePasswordUtils",
+  "resource://gre/modules/InsecurePasswordUtils.jsm");
+
+addMessageListener("RemoteLogins:fillForm", message => {
+  LoginManagerContent.receiveMessage(message, content);
+});
+
+addEventListener("DOMFormHasPassword", event => {
+  LoginManagerContent.onDOMFormHasPassword(event, content);
+  InsecurePasswordUtils.checkForInsecurePasswords(event.target);
+});
+
+addEventListener("pageshow", event => {
+  LoginManagerContent.onPageShow(event, content);
+}, true);
+
+addEventListener("DOMAutoComplete", event => {
+  LoginManagerContent.onUsernameInput(event);
+});
+
+addEventListener("blur", event => {
+  LoginManagerContent.onUsernameInput(event);
+});
--- a/suite/browser/jar.mn
+++ b/suite/browser/jar.mn
@@ -2,16 +2,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 comm.jar:
 % content navigator %content/navigator/
 % content navigator-platform %content/navigator-platform/ platform
 % content navigator-region %content/navigator-region/
    content/navigator/browser.js
+   content/navigator/content.js
    content/navigator/fullScreen.js
    content/navigator/hiddenWindow.xul
    content/navigator/linkToolbarHandler.js
    content/navigator/linkToolbarItem.js
    content/navigator/linkToolbarOverlay.js
    content/navigator/linkToolbarOverlay.xul
    content/navigator/mailNavigatorOverlay.js
    content/navigator/mailNavigatorOverlay.xul
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -2,24 +2,20 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/AddonManager.jsm");
-Components.utils.import("resource://gre/modules/LoginManagerContent.jsm");
 Components.utils.import("resource://gre/modules/LoginManagerParent.jsm");
 Components.utils.import("resource:///modules/Sanitizer.jsm");
 Components.utils.import("resource:///modules/mailnewsMigrator.js");
 
-var onFormPassword = LoginManagerContent.onFormPassword.bind(LoginManagerContent);
-var onUsernameInput = LoginManagerContent.onUsernameInput.bind(LoginManagerContent);
-
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "UserAgentOverrides",
                                   "resource://gre/modules/UserAgentOverrides.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
@@ -157,16 +153,19 @@ SuiteGlue.prototype = {
         this._onProfileAfterChange();
         break;
       case "final-ui-startup":
         this._onProfileStartup();
         this._promptForMasterPassword();
         this._checkForNewAddons();
         Services.search.init();
         LoginManagerParent.init();
+        Components.classes["@mozilla.org/globalmessagemanager;1"]
+                  .getService(Components.interfaces.nsIMessageListenerManager)
+                  .loadFrameScript("chrome://navigator/content/content.js", true);
         Components.utils.import("resource://gre/modules/Webapps.jsm");
         Components.utils.import("resource://gre/modules/NotificationDB.jsm");
         break;
       case "sessionstore-windows-restored":
         this._onBrowserStartup(subject);
         break;
       case "browser:purge-session-history":
         // reset the console service's error buffer
@@ -290,22 +289,16 @@ SuiteGlue.prototype = {
           str.data = aLocation.spec;
           Services.prefs.setComplexValue("browser.history.last_page_visited",
                                          Components.interfaces.nsISupportsString, str);
           break;
       }
     }
   },
 
-  onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
-    aWebProgress.DOMWindow.addEventListener("DOMFormHasPassword", onFormPassword, true);
-    aWebProgress.DOMWindow.addEventListener("DOMAutoComplete", onUsernameInput, true);
-    aWebProgress.DOMWindow.addEventListener("change", onUsernameInput, true);
-  },
-
   // initialization (called on application startup)
   _init: function()
   {
     // observer registration
     Services.obs.addObserver(this, "profile-before-change", true);
     Services.obs.addObserver(this, "profile-after-change", true);
     Services.obs.addObserver(this, "final-ui-startup", true);
     Services.obs.addObserver(this, "sessionstore-windows-restored", true);
@@ -321,17 +314,17 @@ SuiteGlue.prototype = {
     Services.obs.addObserver(this, "dl-done", true);
     Services.obs.addObserver(this, "places-init-complete", true);
     Services.obs.addObserver(this, "places-database-locked", true);
     Services.obs.addObserver(this, "places-shutdown", true);
     Services.obs.addObserver(this, "browser-search-engine-modified", true);
     Services.prefs.addObserver("devtools.debugger.", this, true);
     Components.classes['@mozilla.org/docloaderservice;1']
               .getService(Components.interfaces.nsIWebProgress)
-              .addProgressListener(this, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION | Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
+              .addProgressListener(this, Components.interfaces.nsIWebProgress.NOTIFY_LOCATION);
   },
 
   // profile is available
   _onProfileAfterChange: function()
   {
     // check if we're in safe mode
     if (Services.appinfo.inSafeMode) {
       Services.ww.openWindow(null, "chrome://communicator/content/safeMode.xul",