Bug 1569581 - Add unit tests for isOriginMatching with null/javascript: origins. r=jaws
☠☠ backed out by 76269370e3a0 ☠ ☠
authorMatthew Noorenberghe <mozilla@noorenberghe.ca>
Fri, 23 Aug 2019 18:22:00 +0000
changeset 553388 a8dc5f13dfcf8f6b54401818e1921803c427a029
parent 553387 7e2df056a778edae9665468db1db139102639c1d
child 553389 06e0c353b3ef7b08c9bacc0f4c0eed30102de68c
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1569581
milestone70.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 1569581 - Add unit tests for isOriginMatching with null/javascript: origins. r=jaws Differential Revision: https://phabricator.services.mozilla.com/D43174
toolkit/components/passwordmgr/test/unit/test_isOriginMatching.js
--- a/toolkit/components/passwordmgr/test/unit/test_isOriginMatching.js
+++ b/toolkit/components/passwordmgr/test/unit/test_isOriginMatching.js
@@ -6,16 +6,27 @@
 
 add_task(function test_isOriginMatching() {
   let testcases = [
     // Index 0 holds the expected return value followed by arguments to isOriginMatching.
     [true, "http://example.com", "http://example.com"],
     [true, "http://example.com:8080", "http://example.com:8080"],
     [true, "https://example.com", "https://example.com"],
     [true, "https://example.com:8443", "https://example.com:8443"],
+
+    // The formActionOrigin can be "javascript:"
+    [true, "javascript:", "javascript:"],
+    [false, "javascript:", "http://example.com"],
+    [false, "http://example.com", "javascript:"],
+
+    // HTTP Auth. logins have a null formActionOrigin
+    [true, null, null],
+    [false, null, "http://example.com"],
+    [false, "http://example.com", null],
+
     [false, "http://example.com", "http://mozilla.org"],
     [false, "http://example.com", "http://example.com:8080"],
     [false, "https://example.com", "http://example.com"],
     [false, "https://example.com", "https://mozilla.org"],
     [false, "http://example.com", "http://sub.example.com"],
     [false, "https://example.com", "https://sub.example.com"],
     [false, "http://example.com", "https://example.com:8443"],
     [false, "http://example.com:8080", "http://example.com:8081"],
@@ -137,16 +148,28 @@ add_task(function test_isOriginMatching(
       { acceptDifferentSubdomains: false },
     ],
     [
       false,
       "http://sub.example.com",
       "http://sub.example.mozilla.com",
       { acceptDifferentSubdomains: false },
     ],
+
+    // HTTP Auth. logins have a null formActionOrigin
+    [
+      false,
+      null,
+      "http://example.com",
+      {
+        acceptDifferentSubdomains: false,
+        acceptWildcardMatch: true,
+        schemeUpgrades: true,
+      },
+    ],
   ];
   for (let tc of testcases) {
     let expected = tc.shift();
     Assert.strictEqual(
       LoginHelper.isOriginMatching(...tc),
       expected,
       "Check " + JSON.stringify(tc)
     );