Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: toolkit/components/passwordmgr/test/unit/xpcshell.toml
/**
* Test LoginHelper.isOriginMatching
*/
"use strict";
add_task(function test_isOriginMatching() {
let testcases = [
// Index 0 holds the expected return value followed by arguments to isOriginMatching.
// The formActionOrigin can be "javascript:"
[true, "javascript:", "javascript:"],
// HTTP Auth. logins have a null formActionOrigin
[true, null, null],
[
true,
{ schemeUpgrades: true },
],
[
true,
{ schemeUpgrades: true },
],
[
true,
{ schemeUpgrades: true },
],
[
true,
{ schemeUpgrades: true },
],
[
false,
{ schemeUpgrades: true },
], // downgrade
[
false,
{ schemeUpgrades: true },
], // port mismatch
[
false,
{ schemeUpgrades: true },
], // port mismatch
[
false,
{ schemeUpgrades: true },
],
[
true,
{ acceptDifferentSubdomains: true },
],
[
true,
{ acceptDifferentSubdomains: true },
],
[
true,
{ acceptDifferentSubdomains: true },
],
[
true,
{ acceptDifferentSubdomains: true },
],
[
false,
{ acceptDifferentSubdomains: true, schemeUpgrades: true },
],
[
true,
{ acceptDifferentSubdomains: true, schemeUpgrades: true },
],
[
true,
{ acceptDifferentSubdomains: true },
],
[
false,
{ acceptDifferentSubdomains: true },
],
// signon.includeOtherSubdomainsInLookup allows acceptDifferentSubdomains to be false
[
false,
{ acceptDifferentSubdomains: false },
],
[
false,
{ acceptDifferentSubdomains: false },
],
[
false,
{ acceptDifferentSubdomains: false },
],
[
false,
{ acceptDifferentSubdomains: false },
],
// HTTP Auth. logins have a null formActionOrigin
[
false,
null,
{
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)
);
}
});