From 4b0b0f1f42785b5d3bc8c278e04f5b0d5c05c4cd Mon Sep 17 00:00:00 2001 From: Sean Feng Date: Mon, 24 Oct 2022 15:21:29 +0000 Subject: [PATCH] Bug 1783497 - Update LoginInfo related tests in passwordmgr for recent chrome url changes r=smaug,sfoster,credential-management-reviewers,sgalich These tests expect `Service.io.newURI` raises exception when the given urls are chrome urls. Since we no longer raise exception for chrome url canonicalization failures, the tests need to be updated. Plus, this should be fine because even without the canonicalization changes, using a chrome url like "chrome://path/path/path" would raise exception too. Differential Revision: https://phabricator.services.mozilla.com/D159591 --- toolkit/components/passwordmgr/LoginInfo.jsm | 2 +- .../components/passwordmgr/test/unit/test_displayOrigin.js | 6 ++---- .../passwordmgr/test/unit/test_getPasswordOrigin.js | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/toolkit/components/passwordmgr/LoginInfo.jsm b/toolkit/components/passwordmgr/LoginInfo.jsm index 9616a8d87591..b3a5b839cf6e 100644 --- a/toolkit/components/passwordmgr/LoginInfo.jsm +++ b/toolkit/components/passwordmgr/LoginInfo.jsm @@ -36,7 +36,7 @@ nsLoginInfo.prototype = { displayOrigin = uri.displayHostPort || this.origin; } catch (ex) { // Fallback to this.origin set above in case a URI can't be contructed e.g. - // chrome://FirefoxAccounts + // file:// } if (this.httpRealm === null) { diff --git a/toolkit/components/passwordmgr/test/unit/test_displayOrigin.js b/toolkit/components/passwordmgr/test/unit/test_displayOrigin.js index e8e8d5606c5a..a42f066b3e0b 100644 --- a/toolkit/components/passwordmgr/test/unit/test_displayOrigin.js +++ b/toolkit/components/passwordmgr/test/unit/test_displayOrigin.js @@ -15,10 +15,8 @@ add_task(function test_displayOrigin() { info(displayOrigin); Assert.equal(typeof displayOrigin, "string", "Check type"); Assert.greater(displayOrigin.length, 0, "Check length"); - if ( - loginInfo.origin.startsWith("chrome://") || - loginInfo.origin.startsWith("file://") - ) { + if (loginInfo.origin.startsWith("file://")) { + // Fails to create the URL Assert.ok(displayOrigin.startsWith(loginInfo.origin), "Contains origin"); } else { Assert.ok( diff --git a/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js b/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js index 3aa72b62b05d..9df18d05cce7 100644 --- a/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js +++ b/toolkit/components/passwordmgr/test/unit/test_getPasswordOrigin.js @@ -7,7 +7,7 @@ const TESTCASES = [ ["javascript:void(0);", null], ["javascript:void(0);", "javascript:", true], - ["chrome://MyAccount", null], + ["chrome://MyAccount", "chrome://myaccount"], ["data:text/html,example", null], [ "http://username:password@example.com:80/foo?bar=baz#fragment",