issue513: No more password dialog when visiting HTTP Basic AUTH (e.g. htpasswd) protected sites

Priority: urgent Status: resolved
Messages
msg1330 (view) Author: jrm Date: 2017-02-12.16:45:15
Using the latest code from the git repository and Firefox 51.0.1, visiting a protected site (e.g.
http://ftfl.ca/bm) fails and no login prompt is displayed.

Terminal output when visiting such a site:

JavaScript error: resource://gre/components/nsLoginManagerPrompter.js, line 1373: TypeError: win.gBrowser
is undefined
JavaScript error: , line 0: uncaught exception: 2147500033
JavaScript error: resource://gre/components/nsPrompter.js, line 741: TypeError: checkValue is undefined
Console error: [JavaScript Error: "TypeError: win.gBrowser is undefined" {file:
"resource://gre/components/nsLoginManagerPrompter.js" line: 1373}]
  Category: chrome javascript
Console error: [JavaScript Error: "nsPrompter: Delegation to password manager failed: [Exception...
"[JavaScript Error: "win.gBrowser is undefined" {file:
"resource://gre/components/nsLoginManagerPrompter.js" line: 1373}]'[JavaScript Error: "win.gBrowser is
undefined" {file: "resource://gre/components/nsLoginManagerPrompter.js" line: 1373}]' when calling
method: [nsIPromptFactory::getPrompt]"  nsresult: "0x80570021
(NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "JS frame ::
resource://gre/components/nsPrompter.js :: Prompter.prototype.getPrompt :: line 42"  data: yes]" {file:
"resource://gre/components/nsPrompter.js" line: 44}]
Prompter.prototype.getPrompt@resource://gre/components/nsPrompter.js:44:17

  Category: XPConnect JavaScript
Console error: [JavaScript Error: "uncaught exception: 2147500033"]
  Category: chrome javascript
Console error: [JavaScript Error: "TypeError: checkValue is undefined" {file:
"resource://gre/components/nsPrompter.js" line: 741}]
  Category: chrome javascript
Console error: [JavaScript Error: "The character encoding of the HTML document was not declared. The
document will render with garbledtext in some browser configurations if the document contains characters
from outside the US-ASCII range. The character encoding of thepage must be declared in the document or in
the transfer protocol." {file: "https://ftfl.ca/bm" line: 0}]
  Category: HTML parser
Console error: [JavaScript Warning: "Warning: nsFaviconService::setAndFetchFaviconForPage() deprecated,
please use nsFaviconService::setAndFetchFaviconForPage(..., [optional aLoadingPrincipal])" {file:
"chrome://conkeror/content/favicon.js" line: 24}]
  Category: Security by Default
msg1331 (view) Author: XTaran Date: 2017-03-27.19:30:07
I can confirm this. A currently still working workaround is using
Firefox ESR which is still available at version 45.8 But soon, Firefox
ESR will be bumped to be based on FF 52 or so and then that workaround
is gone.
msg1332 (view) Author: XTaran Date: 2017-03-27.19:52:00
This Mozilla bug seems to be related, although its fix might rather be
the cause than the fix as its said to have happened with Firefox
before 51: https://bugzilla.mozilla.org/show_bug.cgi?id=1308817

The fix is in FoxyProxy's git repository at
https://code.getfoxyproxy.org/Foxyproxy_Firefox/commit/?id=25dd26d71aa5e18f3dbdb31ad93a163a130433eb
msg1333 (view) Author: madalu Date: 2017-04-02.15:39:43
The firefox diff that broke this for conkeror is here:

https://hg.mozilla.org/mozilla-central/diff/6a563348b8be/toolkit/components/passwordmgr/nsLoginManagerPrompter.js

I believe the problem is that mozilla has replaced the getBrowser method with gBrowser throughout the
firefox code base. But conkeror only defines getBrowser in windows.js (line 200). 

Furthermore, there is a new getBrowserForContentWindow method that we need to define. See this seamonkey
bug for an example:

https://api-dev.bugzilla.mozilla.org/show_bug.cgi?id=1300539
msg1334 (view) Author: XTaran Date: 2017-04-02.19:49:22
madalu: Thanks for these hints. Unfortunately they're not enough hints
for me to actually find a fix.

At least the following patch does _not_ suffice:

--- a/modules/window.js
+++ b/modules/window.js
@@ -198,6 +198,8 @@ function window_initialize (window) {
     // Add a getBrowser() and content to help certain extensions designed
     // for Firefox work with conkeror
     window.getBrowser = window_get_this_browser;
+    window.gBrowser = window_get_this_browser;
+    window.getBrowserForContentWindow = window_get_this_browser;
     window.__defineGetter__('content',
                             function () {
                                 return this.buffers.current.browser.contentWindow;
msg1335 (view) Author: madalu Date: 2017-04-03.16:16:04
Sorry, I wasn't clear in my earlier post. The method getBrowserForContentWindow is invoked as follows in 
nsLoginManagerPrompter.js:

    let windows = Services.wm.getEnumerator(null);
    while (windows.hasMoreElements()) {
      let win = windows.getNext();
      let browser = win.gBrowser.getBrowserForContentWindow(aWindow);
      if (browser) {
        return { win, browser };
      }
    }
    return null;

So it is a method called on the browser object returned by gBrowser. And I believe it takes an instance of 
nsIDOMWindow as an argument. Its implementation in Seamonkey here (https://api-
dev.bugzilla.mozilla.org/show_bug.cgi?id=1300539#c12) seems to suggest that it is called on an array of 
browser objects.

As I understand it, these methods were not exposed to any of the code conkeror relied on before; conkeror 
itself traditionally just hacked a getBrowser (i.e., gBrowser) method so that it could be called by 
extensions. But now these methods are directly invoked in nsLoginManagerPrompter.
msg1347 (view) Author: XTaran Date: 2017-11-29.17:51:23
Thanks to a patch sent to me (unfortunately only to me as it seems) by consolers(Madeleine@117.193.29.82)
on IRC in a /query, this bug is now fixed in git.

Will make an 1.0.4 release including that patch soon.
History
Date User Action Args
2017-11-29 17:51:23XTaransetstatus: chatting -> resolved
messages: + msg1347
2017-04-03 16:16:04madalusetmessages: + msg1335
2017-04-02 19:49:22XTaransetmessages: + msg1334
2017-04-02 15:39:43madalusetmessages: + msg1333
2017-03-27 19:52:00XTaransetmessages: + msg1332
2017-03-27 19:30:41XTaransetnosy: + XTaran
2017-03-27 19:30:07XTaransetstatus: unread -> chatting
priority: bug -> urgent
messages: + msg1331
title: No prompt when visiting htpasswd-protected sites -> No more password dialog when visiting HTTP Basic AUTH (e.g. htpasswd) protected sites
2017-02-12 16:45:15jrmcreate