Bug 1277895 - Http auth dialog can be cut. r=dolske a=ritu
authorDragana Damjanovic <dd.mozilla@gmail.com>
Wed, 19 Oct 2016 12:25:40 -0700
changeset 350726 2bcf7a0d6dd030237bb11532a5a9d7be0ecdbcef
parent 350725 bc14a6826c3200ff5c6342b4005e15879a7d129a
child 350727 5eb505aa477323a9e395c2fb6d86c019c1973615
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdolske, ritu
bugs1277895
milestone50.0
Bug 1277895 - Http auth dialog can be cut. r=dolske a=ritu
mobile/android/components/PromptService.js
toolkit/components/passwordmgr/test/mochitest/test_prompt.html
toolkit/components/prompts/src/nsPrompter.js
toolkit/components/prompts/test/test_modal_prompts.html
toolkit/components/prompts/test/test_subresources_prompts.html
--- a/mobile/android/components/PromptService.js
+++ b/mobile/android/components/PromptService.js
@@ -701,17 +701,17 @@ var PromptUtils = {
     } else if (isCrossOrig) {
       text = this.bundle.formatStringFromName("EnterUserPasswordForCrossOrigin", [displayHost], 1);
     } else if (!realm) {
       text = this.bundle.formatStringFromName("EnterUserPasswordFor2", [displayHost], 1);
     } else {
       text = this.bundle.formatStringFromName("EnterLoginForRealm2", [realm, displayHost], 2);
     }
 
-    return text;
+    return text.replace(/\n{1,}/g,' ');
   },
 
   // JS port of http://mxr.mozilla.org/mozilla-central/source/embedding/components/windowwatcher/nsPromptUtils.h#89
   getAuthHostPort: function pu_getAuthHostPort(aChannel, aAuthInfo) {
     let uri = aChannel.URI;
     let res = { host: null, port: -1 };
     if (aAuthInfo.flags & aAuthInfo.AUTH_PROXY) {
       let proxy = aChannel.QueryInterface(Ci.nsIProxiedChannel);
--- a/toolkit/components/passwordmgr/test/mochitest/test_prompt.html
+++ b/toolkit/components/passwordmgr/test/mochitest/test_prompt.html
@@ -911,17 +911,17 @@ add_task(function* runTests() {
                                        null,      // aTriggeringPrincipal
                                        Ci.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                                        Ci.nsIContentPolicy.TYPE_OTHER);
 
   var level = Ci.nsIAuthPrompt2.LEVEL_NONE;
 
   // ===== test 500 =====
   state = {
-    msg         : "http://example.com is requesting your username and password.\n\nThe site says: “some realm”",
+    msg         : "http://example.com is requesting your username and password. The site says: “some realm”",
     title       : "Authentication Required",
     textValue   : "inuser",
     passValue   : "inpass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -944,17 +944,17 @@ add_task(function* runTests() {
   yield promptDone;
 
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "outuser", "Checking returned username");
   is(authinfo.password, "outpass", "Checking returned password");
 
   // ===== test 501 =====
   state = {
-    msg         : "http://example.com is requesting your username and password.\n\nThe site says: “some realm”",
+    msg         : "http://example.com is requesting your username and password. The site says: “some realm”",
     title       : "Authentication Required",
     textValue   : "outuser",
     passValue   : "outpass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -970,17 +970,17 @@ add_task(function* runTests() {
   isOk = prompter2.promptAuth(channel1, level, authinfo);
   yield promptDone;
 
   ok(!isOk, "Checking dialog return value (cancel)");
 
   // ===== test 502 =====
   // test filling in password-only login
   state = {
-    msg         : "http://example.com is requesting your username and password.\n\nThe site says: “http://example.com”",
+    msg         : "http://example.com is requesting your username and password. The site says: “http://example.com”",
     title       : "Authentication Required",
     textValue   : "",
     passValue   : "examplepass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1003,17 +1003,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "", "Checking returned username");
   is(authinfo.password, "examplepass", "Checking returned password");
 
   // ===== test 503 =====
   // test filling in existing login (undetermined from multiple selection)
   // user2name/user2pass would also be valid to fill here.
   state = {
-    msg         : "http://example2.com is requesting your username and password.\n\nThe site says: “http://example2.com”",
+    msg         : "http://example2.com is requesting your username and password. The site says: “http://example2.com”",
     title       : "Authentication Required",
     textValue   : "user1name",
     passValue   : "user1pass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1036,17 +1036,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   ok(authinfo.username == "user1name" || authinfo.username == "user2name", "Checking returned username");
   ok(authinfo.password == "user1pass" || authinfo.password == "user2pass", "Checking returned password");
 
   // ===== test 504 =====
   // test filling in existing login (undetermined --> user1)
   // user2name/user2pass would also be valid to fill here.
   state = {
-    msg         : "http://example2.com is requesting your username and password.\n\nThe site says: “http://example2.com”",
+    msg         : "http://example2.com is requesting your username and password. The site says: “http://example2.com”",
     title       : "Authentication Required",
     textValue   : "user1name",
     passValue   : "user1pass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1072,17 +1072,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "user1name", "Checking returned username");
   is(authinfo.password, "user1pass", "Checking returned password");
 
   // ===== test 505 =====
   // test filling in existing login (undetermined --> user2)
   // user2name/user2pass would also be valid to fill here.
   state = {
-    msg         : "http://example2.com is requesting your username and password.\n\nThe site says: “http://example2.com”",
+    msg         : "http://example2.com is requesting your username and password. The site says: “http://example2.com”",
     title       : "Authentication Required",
     textValue   : "user1name",
     passValue   : "user1pass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1109,17 +1109,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "user2name", "Checking returned username");
   is(authinfo.password, "user2pass", "Checking returned password");
 
   // ===== test 506 =====
   // test changing a password (undetermined --> user2 w/ newpass)
   // user2name/user2pass would also be valid to fill here.
   state = {
-    msg         : "http://example2.com is requesting your username and password.\n\nThe site says: “http://example2.com”",
+    msg         : "http://example2.com is requesting your username and password. The site says: “http://example2.com”",
     title       : "Authentication Required",
     textValue   : "user1name",
     passValue   : "user1pass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1146,17 +1146,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "user2name", "Checking returned username");
   is(authinfo.password, "NEWuser2pass", "Checking returned password");
 
   // ===== test 507 =====
   // test changing a password (undetermined --> user2 w/ origpass)
   // user2name/user2pass would also be valid to fill here.
   state = {
-    msg         : "http://example2.com is requesting your username and password.\n\nThe site says: “http://example2.com”",
+    msg         : "http://example2.com is requesting your username and password. The site says: “http://example2.com”",
     title       : "Authentication Required",
     textValue   : "user1name",
     passValue   : "user1pass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1182,17 +1182,17 @@ add_task(function* runTests() {
 
   ok(isOk, "Checking dialog return value (accept)");
   is(authinfo.username, "user2name", "Checking returned username");
   is(authinfo.password, "user2pass", "Checking returned password");
 
   // ===== test 508 =====
   // test proxy login (default = no autologin), make sure it prompts.
   state = {
-    msg         : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password.\n\nThe site says: “Proxy Realm”",
+    msg         : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password. The site says: “Proxy Realm”",
     title       : "Authentication Required",
     textValue   : "proxuser",
     passValue   : "proxpass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1239,17 +1239,17 @@ add_task(function* runTests() {
   ok(isOk, "Checking dialog return value (accept)");
   isnot(time1, time2, "Checking that timeLastUsed was updated");
   is(proxyAuthinfo.username, "proxuser", "Checking returned username");
   is(proxyAuthinfo.password, "proxpass", "Checking returned password");
 
   // ===== test 510 =====
   // test proxy login (with autologin), ensure it prompts after a failed auth.
   state = {
-    msg         : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password.\n\nThe site says: “Proxy Realm”",
+    msg         : "The proxy moz-proxy://127.0.0.1:8888 is requesting a username and password. The site says: “Proxy Realm”",
     title       : "Authentication Required",
     textValue   : "proxuser",
     passValue   : "proxpass",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1304,17 +1304,17 @@ add_task(function* runTests() {
   // clear plain HTTP auth sessions before the test, to allow
   // running them more than once.
   var authMgr = Cc['@mozilla.org/network/http-auth-manager;1'].
                 getService(Ci.nsIHttpAuthManager);
   authMgr.clearAll();
 
   // ===== test 1000 =====
   state = {
-    msg         : "http://mochi.test:8888 is requesting your username and password.\n\nThe site says: “mochitest”",
+    msg         : "http://mochi.test:8888 is requesting your username and password. The site says: “mochitest”",
     title       : "Authentication Required",
     textValue   : "mochiuser1",
     passValue   : "mochipass1",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1333,17 +1333,17 @@ add_task(function* runTests() {
   var iframeLoaded = onloadPromiseFor("iframe");
   iframe.src = "authenticate.sjs?user=mochiuser1&pass=mochipass1";
   yield promptDone;
   yield iframeLoaded;
   checkEchoedAuthInfo({user: "mochiuser1", pass: "mochipass1"},
                       iframe.contentDocument);
 
   state = {
-    msg         : "http://mochi.test:8888 is requesting your username and password.\n\nThe site says: “mochitest2”",
+    msg         : "http://mochi.test:8888 is requesting your username and password. The site says: “mochitest2”",
     title       : "Authentication Required",
     textValue   : "mochiuser2",
     passValue   : "mochipass2",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1374,17 +1374,17 @@ add_task(function* runTests() {
   yield iframeLoaded;
   checkEchoedAuthInfo({user: "mochiuser1", pass: "mochipass1"},
                       iframe.contentDocument);
 
   // Same realm we've already authenticated to, but with a different
   // expected password (to trigger an auth prompt, and change-password
   // popup notification).
   state = {
-    msg         : "http://mochi.test:8888 is requesting your username and password.\n\nThe site says: “mochitest”",
+    msg         : "http://mochi.test:8888 is requesting your username and password. The site says: “mochitest”",
     title       : "Authentication Required",
     textValue   : "mochiuser1",
     passValue   : "mochipass1",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1424,17 +1424,17 @@ add_task(function* runTests() {
   popup.remove();
 
   yield pwchanged;
 
   // Same as last test, but for a realm we haven't already authenticated
   // to (but have an existing saved login for, so that we'll trigger
   // a change-password popup notification.
   state = {
-    msg         : "http://mochi.test:8888 is requesting your username and password.\n\nThe site says: “mochitest3”",
+    msg         : "http://mochi.test:8888 is requesting your username and password. The site says: “mochitest3”",
     title       : "Authentication Required",
     textValue   : "mochiuser3",
     passValue   : "mochipass3-old",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -1479,17 +1479,17 @@ add_task(function* runTests() {
   yield pwchanged;
 
 
   // Clear cached auth from this subtest, and avoid leaking due to bug 459620.
   authMgr.clearAll();
   ok(true, "authMgr cleared cached auth");
 
   state = {
-    msg         : "http://mochi.test:8888 is requesting your username and password.\n\nThe site says: “mochitest3”",
+    msg         : "http://mochi.test:8888 is requesting your username and password. The site says: “mochitest3”",
     title       : "Authentication Required",
     textValue   : "",
     passValue   : "",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
--- a/toolkit/components/prompts/src/nsPrompter.js
+++ b/toolkit/components/prompts/src/nsPrompter.js
@@ -280,17 +280,17 @@ var PromptUtilsTemp = {
         } else if (isCrossOrig) {
             text = PromptUtils.getLocalizedString("EnterUserPasswordForCrossOrigin", [displayHost]);
         } else if (!realm) {
             text = PromptUtils.getLocalizedString("EnterUserPasswordFor2", [displayHost]);
         } else {
             text = PromptUtils.getLocalizedString("EnterLoginForRealm2", [realm, displayHost]);
         }
 
-        return text;
+        return text.replace(/\n{1,}/g,' ');
     },
 
     getTabModalPrompt : function (domWin) {
         var promptBox = null;
 
         try {
             // Get the topmost window, in case we're in a frame.
             var promptWin = domWin.top;
--- a/toolkit/components/prompts/test/test_modal_prompts.html
+++ b/toolkit/components/prompts/test/test_modal_prompts.html
@@ -1015,17 +1015,17 @@ function* runTests() {
         yield promptDone;
     }
 
 
     // =====
     // (promptAuth is only accessible from the prompt service)
     info("Starting test: promptAuth with long realm");
     state = {
-        msg : 'http://example.com is requesting your username and password.\n\nThe site '  +
+        msg : 'http://example.com is requesting your username and password. The site '  +
               'says: \u201cabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ' +
               'abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi '        +
               'abcdefghi \u2026\u201d',
         title : "TestTitle",
         iconClass   : "authentication-icon question-icon",
         titleHidden : true,
         textHidden  : false,
         passHidden  : false,
@@ -1068,17 +1068,17 @@ function* runTests() {
         password : "",
         domain   : "",
         flags    : Ci. nsIAuthInformation.AUTH_HOST |
                    Ci.nsIAuthInformation.CROSS_ORIGIN_SUB_RESOURCE,
         authenticationScheme : "basic",
         realm : ""
     }
     state = {
-        msg : 'http://example.com is requesting your username and password.\n\n' +
+        msg : 'http://example.com is requesting your username and password. ' +
               'WARNING: Your password will not be sent to the website you are currently visiting!',
         title : "TestTitle",
         iconClass   : "authentication-icon question-icon",
         titleHidden : true,
         textHidden  : false,
         passHidden  : false,
         checkHidden : false,
         textValue   : "",
@@ -1111,17 +1111,17 @@ function* runTests() {
         username : "",
         password : "",
         domain   : "",
         flags : Ci. nsIAuthInformation.AUTH_HOST | Ci.nsIAuthInformation.CROSS_ORIGIN_SUB_RESOURCE,
         authenticationScheme : "basic",
         realm : "Something!!!"
     }
     state = {
-        msg : 'http://example.com is requesting your username and password.\n\n' +
+        msg : 'http://example.com is requesting your username and password. ' +
               'WARNING: Your password will not be sent to the website you are currently visiting!',
         title : "TestTitle",
         iconClass   : "authentication-icon question-icon",
         titleHidden : true,
         textHidden  : false,
         passHidden  : false,
         checkHidden : false,
         textValue   : "",
--- a/toolkit/components/prompts/test/test_subresources_prompts.html
+++ b/toolkit/components/prompts/test/test_subresources_prompts.html
@@ -114,17 +114,17 @@ add_task(function* runTestAuth()
   // cross-origin subresources load
 
   // Force parent to not look for tab-modal prompts, as they're not
   // used for auth prompts.
   isTabModal = false;
 
   state = {
     msg         : "http://mochi.test:8888 is requesting your username " +
-                  "and password.\n\nThe site says: “mochitest”",
+                  "and password. The site says: “mochitest”",
     title       : "Authentication Required",
     textValue   : "",
     passValue   : "",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,
     checkHidden : true,
@@ -150,17 +150,17 @@ add_task(function* runTestAuth()
   checkEchoedAuthInfo({user: "mochiuser1", pass: "mochipass1"},
                       iframe_prompt.contentDocument);
 
   // Cross-origin subresourse test.
 
   // Force parent to not look for tab-modal prompts, as they're not used for auth prompts.
   isTabModal =false;
   state = {
-    msg         : "http://example.com is requesting your username and password.\n\n" +
+    msg         : "http://example.com is requesting your username and password. " +
                   "WARNING: Your password will not be sent to the website you are currently visiting!",
     title       : "Authentication Required",
     textValue   : "",
     passValue   : "",
     iconClass   : "authentication-icon question-icon",
     titleHidden : true,
     textHidden  : false,
     passHidden  : false,