Bug 1569581 - Add unit tests for isOriginMatching with null/javascript: origins. r=jaws

Differential Revision: https://phabricator.services.mozilla.com/D43174

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matthew Noorenberghe 2019-08-23 18:22:00 +00:00
Родитель 35e36fcef9
Коммит 56171aa00d
1 изменённых файлов: 23 добавлений и 0 удалений

Просмотреть файл

@ -11,6 +11,17 @@ add_task(function test_isOriginMatching() {
[true, "http://example.com:8080", "http://example.com:8080"], [true, "http://example.com:8080", "http://example.com:8080"],
[true, "https://example.com", "https://example.com"], [true, "https://example.com", "https://example.com"],
[true, "https://example.com:8443", "https://example.com:8443"], [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://mozilla.org"],
[false, "http://example.com", "http://example.com:8080"], [false, "http://example.com", "http://example.com:8080"],
[false, "https://example.com", "http://example.com"], [false, "https://example.com", "http://example.com"],
@ -142,6 +153,18 @@ add_task(function test_isOriginMatching() {
"http://sub.example.mozilla.com", "http://sub.example.mozilla.com",
{ acceptDifferentSubdomains: false }, { 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) { for (let tc of testcases) {
let expected = tc.shift(); let expected = tc.shift();