mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 2614fbb8d385 (bug 1147561) for Android mochitest failures.
This commit is contained in:
parent
e4130e4a07
commit
3078cf7bdf
@ -2,10 +2,11 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function nsLoginInfo() {}
|
||||
|
||||
@ -38,7 +39,7 @@ nsLoginInfo.prototype = {
|
||||
this.passwordField = aPasswordField;
|
||||
},
|
||||
|
||||
matches(aLogin, ignorePassword) {
|
||||
matches : function (aLogin, ignorePassword) {
|
||||
if (this.hostname != aLogin.hostname ||
|
||||
this.httpRealm != aLogin.httpRealm ||
|
||||
this.username != aLogin.username)
|
||||
@ -49,18 +50,8 @@ nsLoginInfo.prototype = {
|
||||
|
||||
// If either formSubmitURL is blank (but not null), then match.
|
||||
if (this.formSubmitURL != "" && aLogin.formSubmitURL != "" &&
|
||||
this.formSubmitURL != aLogin.formSubmitURL) {
|
||||
// If we have the same formSubmitURL hostPort we should match (ignore scheme)
|
||||
try {
|
||||
let loginURI = Services.io.newURI(aLogin.formSubmitURL, null, null);
|
||||
let matchURI = Services.io.newURI(this.formSubmitURL, null, null);
|
||||
if (loginURI.hostPort != matchURI.hostPort) {
|
||||
return false;
|
||||
}
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.formSubmitURL != aLogin.formSubmitURL)
|
||||
return false;
|
||||
|
||||
// The .usernameField and .passwordField values are ignored.
|
||||
|
||||
|
@ -329,10 +329,6 @@ this.LoginManagerStorage_json.prototype = {
|
||||
let conditions = [];
|
||||
|
||||
function match(aLogin) {
|
||||
let returnValue = {
|
||||
match: false,
|
||||
strictMatch: true
|
||||
};
|
||||
for (let field in matchData) {
|
||||
let value = matchData[field];
|
||||
switch (field) {
|
||||
@ -340,18 +336,7 @@ this.LoginManagerStorage_json.prototype = {
|
||||
case "formSubmitURL":
|
||||
if (value != null) {
|
||||
if (aLogin.formSubmitURL != "" && aLogin.formSubmitURL != value) {
|
||||
// Check if it matches with a different scheme
|
||||
try {
|
||||
let loginURI = Services.io.newURI(aLogin.formSubmitURL, null, null);
|
||||
let matchURI = Services.io.newURI(value, null, null);
|
||||
if (loginURI.hostPort != matchURI.hostPort) {
|
||||
return returnValue; // not a match at all
|
||||
} else {
|
||||
returnValue.strictMatch = false; // not a strict match
|
||||
}
|
||||
} catch (e) {
|
||||
return returnValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -370,9 +355,9 @@ this.LoginManagerStorage_json.prototype = {
|
||||
case "timePasswordChanged":
|
||||
case "timesUsed":
|
||||
if (value == null && aLogin[field]) {
|
||||
return returnValue;
|
||||
return false;
|
||||
} else if (aLogin[field] != value) {
|
||||
return returnValue;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
// Fail if caller requests an unknown property.
|
||||
@ -380,14 +365,12 @@ this.LoginManagerStorage_json.prototype = {
|
||||
throw new Error("Unexpected field: " + field);
|
||||
}
|
||||
}
|
||||
returnValue.match = true;
|
||||
return returnValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
let foundLogins = [], foundIds = [], fallbackLogins = [], fallbackIds = [];
|
||||
let foundLogins = [], foundIds = [];
|
||||
for (let loginItem of this._store.data.logins) {
|
||||
let result = match(loginItem);
|
||||
if (result.match) {
|
||||
if (match(loginItem)) {
|
||||
// Create the new nsLoginInfo object, push to array
|
||||
let login = Cc["@mozilla.org/login-manager/loginInfo;1"].
|
||||
createInstance(Ci.nsILoginInfo);
|
||||
@ -402,20 +385,11 @@ this.LoginManagerStorage_json.prototype = {
|
||||
login.timeLastUsed = loginItem.timeLastUsed;
|
||||
login.timePasswordChanged = loginItem.timePasswordChanged;
|
||||
login.timesUsed = loginItem.timesUsed;
|
||||
// If protocol does not match, use as a fallback login
|
||||
if (result.strictMatch) {
|
||||
foundLogins.push(login);
|
||||
foundIds.push(loginItem.id);
|
||||
} else {
|
||||
fallbackLogins.push(login);
|
||||
fallbackIds.push(loginItem.id);
|
||||
}
|
||||
foundLogins.push(login);
|
||||
foundIds.push(loginItem.id);
|
||||
}
|
||||
}
|
||||
if (!foundLogins.length && fallbackLogins.length) {
|
||||
this.log("_searchLogins: returning " + fallbackLogins.length + " fallback logins");
|
||||
return [fallbackLogins, fallbackIds];
|
||||
}
|
||||
|
||||
this.log("_searchLogins: returning " + foundLogins.length + " logins");
|
||||
return [foundLogins, foundIds];
|
||||
},
|
||||
|
@ -492,8 +492,8 @@ LoginManagerStorage_mozStorage.prototype = {
|
||||
// Historical compatibility requires this special case
|
||||
case "formSubmitURL":
|
||||
if (value != null) {
|
||||
// As we also need to check for different schemes at the URI
|
||||
// this case gets handled by filtering the result of the query.
|
||||
conditions.push("formSubmitURL = :formSubmitURL OR formSubmitURL = ''");
|
||||
params["formSubmitURL"] = value;
|
||||
break;
|
||||
}
|
||||
// Normal cases.
|
||||
@ -531,7 +531,7 @@ LoginManagerStorage_mozStorage.prototype = {
|
||||
}
|
||||
|
||||
let stmt;
|
||||
let logins = [], ids = [], fallbackLogins = [], fallbackIds = [];;
|
||||
let logins = [], ids = [];
|
||||
try {
|
||||
stmt = this._dbCreateStatement(query, params);
|
||||
// We can't execute as usual here, since we're iterating over rows
|
||||
@ -550,18 +550,8 @@ LoginManagerStorage_mozStorage.prototype = {
|
||||
login.timeLastUsed = stmt.row.timeLastUsed;
|
||||
login.timePasswordChanged = stmt.row.timePasswordChanged;
|
||||
login.timesUsed = stmt.row.timesUsed;
|
||||
if (login.formSubmitURL == "" ||
|
||||
login.formSubmitURL == matchData["formSubmitURL"]) {
|
||||
logins.push(login);
|
||||
ids.push(stmt.row.id);
|
||||
} else {
|
||||
let loginURI = Services.io.newURI(login.formSubmitURL, null, null);
|
||||
let matchURI = Services.io.newURI(matchData.formSubmitURL, null, null);
|
||||
if (loginURI.hostPort == matchURI.hostPort) {
|
||||
fallbackLogins.push(login);
|
||||
fallbackIds.push(stmt.row.id);
|
||||
}
|
||||
}
|
||||
logins.push(login);
|
||||
ids.push(stmt.row.id);
|
||||
}
|
||||
} catch (e) {
|
||||
this.log("_searchLogins failed: " + e.name + " : " + e.message);
|
||||
@ -571,10 +561,6 @@ LoginManagerStorage_mozStorage.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
if (!logins.length && fallbackLogins.length) {
|
||||
this.log("_searchLogins: returning " + fallbackLogins.length + " fallback logins");
|
||||
return [fallbackLogins, fallbackIds];
|
||||
}
|
||||
this.log("_searchLogins: returning " + logins.length + " logins");
|
||||
return [logins, ids];
|
||||
},
|
||||
|
@ -71,15 +71,6 @@ this.LoginTestUtils = {
|
||||
Assert.ok(expected.every(e => actual.some(a => a.equals(e))));
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that every login in "expected" matches one in "actual".
|
||||
* The comparison uses the "matches" method of nsILoginInfo.
|
||||
*/
|
||||
assertLoginListsMatches(actual, expected, ignorePassword) {
|
||||
Assert.equal(expected.length, actual.length);
|
||||
Assert.ok(expected.every(e => actual.some(a => a.matches(e, ignorePassword))));
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that the two provided arrays of strings contain the same values,
|
||||
* maybe in a different order, case-sensitively.
|
||||
@ -175,6 +166,9 @@ this.LoginTestUtils.testData = {
|
||||
new LoginInfo("http://www3.example.com", "http://www.example.com", null,
|
||||
"the username", "the password",
|
||||
"form_field_username", "form_field_password"),
|
||||
new LoginInfo("http://www3.example.com", "https://www.example.com", null,
|
||||
"the username", "the password",
|
||||
"form_field_username", "form_field_password"),
|
||||
new LoginInfo("http://www3.example.com", "http://example.com", null,
|
||||
"the username", "the password",
|
||||
"form_field_username", "form_field_password"),
|
||||
|
@ -124,12 +124,6 @@ Login Manager test: forms with 1 password field
|
||||
<button type='submit'>Submit</button>
|
||||
</form>
|
||||
|
||||
<form id='form15' action='https://mochi.test:8888/tests/formtest.js'> 15
|
||||
<!-- Different scheme for same url, should be filled -->
|
||||
<input type='text' name='uname' value=''>
|
||||
<input type='password' name='pname' value=''>
|
||||
<button type='submit'>Submit</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@ -163,9 +157,6 @@ function startTest() {
|
||||
checkForm(f++, "xxxxxxxx", "testuser", "testpass");
|
||||
checkForm(f++, "testuser", "testpass", "xxxxxxxx");
|
||||
|
||||
//15
|
||||
checkForm(f++, "testuser", "testpass");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,6 @@ var login8B = new nsLoginInfo(
|
||||
var login8C = new nsLoginInfo(
|
||||
"http://mochi.test:8888", "http://autocomplete5", null,
|
||||
"form9userAABz", "form9pass", "uname", "pword");
|
||||
|
||||
var login9 = new nsLoginInfo(
|
||||
"http://mochi.test:8888", "http://autocomplete6", null,
|
||||
"testuser9", "testpass9", "uname", "pword");
|
||||
|
||||
// try/catch in case someone runs the tests manually, twice.
|
||||
try {
|
||||
pwmgr.addLogin(login0);
|
||||
@ -93,7 +88,6 @@ try {
|
||||
pwmgr.addLogin(login7);
|
||||
pwmgr.addLogin(login8A);
|
||||
pwmgr.addLogin(login8B);
|
||||
pwmgr.addLogin(login9);
|
||||
} catch (e) {
|
||||
ok(false, "addLogin threw: " + e);
|
||||
}
|
||||
@ -163,13 +157,6 @@ try {
|
||||
<input type="password" name="pword">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
|
||||
<!-- test for different scheme -->
|
||||
<form id="form10" action="https://autocomplete6" onsubmit="return false;">
|
||||
<input type="text" name="uname">
|
||||
<input type="password" name="pword">
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<pre id="test">
|
||||
@ -783,25 +770,6 @@ function* runTest() {
|
||||
// check that empty results are cached - bug 496466
|
||||
checkMenuEntries([]);
|
||||
|
||||
/* test 705 */
|
||||
// Check that formSubmitURL with different schemes matches
|
||||
// Turn our attention to form10
|
||||
uname = $_(10, "uname");
|
||||
pword = $_(10, "pword");
|
||||
|
||||
// Trigger autocomplete popup
|
||||
restoreForm();
|
||||
doKey("down");
|
||||
yield runNextTest("expect popup");
|
||||
|
||||
// Check first entry
|
||||
doKey("down");
|
||||
checkACForm("", ""); // value shouldn't update
|
||||
doKey("return"); // not "enter"!
|
||||
yield waitForCompletion();
|
||||
checkACForm("testuser9", "testpass9");
|
||||
yield runNextTest();
|
||||
|
||||
SimpleTest.finish();
|
||||
return;
|
||||
}
|
||||
|
@ -56,8 +56,7 @@ var subtests = [
|
||||
"subtst_notifications_2pw_0un.html", // 28
|
||||
"http://example.org" + testpath + "subtst_notifications_2pw_1un_1text.html", // 29
|
||||
"http://example.org" + testpath + "subtst_notifications_2pw_1un_1text.html", // 30
|
||||
"subtst_notifications_1.html", // 31
|
||||
];
|
||||
];
|
||||
|
||||
|
||||
var ignoreLoad = false;
|
||||
@ -511,34 +510,9 @@ function checkTest() {
|
||||
|
||||
// remove the added login
|
||||
pwmgr.removeAllLogins();
|
||||
|
||||
// Add login for the next test
|
||||
pwmgr.addLogin(login3);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case 31: {
|
||||
// make sure we didn't prompt for an existing login with different
|
||||
// scheme for formSubmitURL.
|
||||
is(gotUser, "notifyu1", "Checking submitted username");
|
||||
is(gotPass, "notifyp1", "Checking submitted password");
|
||||
popup = getPopup(popupNotifications, "password-save");
|
||||
ok(!popup, "checking for no notification popup");
|
||||
|
||||
// Check to make sure we updated the timestamps and use count on the
|
||||
// existing login that was submitted for this form.
|
||||
var logins = pwmgr.getAllLogins();
|
||||
is(logins.length, 1, "Should only have 1 login");
|
||||
ok(SpecialPowers.call_Instanceof(logins[0], Ci.nsILoginMetaInfo), "metainfo QI");
|
||||
is(logins[0].timesUsed, 2, "check .timesUsed for existing login submission");
|
||||
ok(logins[0].timeLastUsed > logins[0].timeCreated, "timeLastUsed bumped");
|
||||
ok(logins[0].timeCreated == logins[0].timePasswordChanged, "timeChanged not updated");
|
||||
|
||||
// remove that login
|
||||
pwmgr.removeAllLogins();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ok(false, "Unexpected call to checkTest for test #" + testNum);
|
||||
|
||||
@ -575,8 +549,6 @@ var login1B = new nsLoginInfo("http://mochi.test:8888", "http://mochi.test:8888"
|
||||
"notifyu1B", "notifyp1B", "user", "pass");
|
||||
var login2B = new nsLoginInfo("http://mochi.test:8888", "http://mochi.test:8888", null,
|
||||
"", "notifyp1B", "", "pass");
|
||||
var login3 = new nsLoginInfo("http://mochi.test:8888", "https://mochi.test:8888", null,
|
||||
"notifyu1", "notifyp1", "user", "pass");
|
||||
|
||||
var parentScriptURL = SimpleTest.getTestFileURL("pwmgr_common.js");
|
||||
var mm = SpecialPowers.loadChromeScript(parentScriptURL);
|
||||
|
@ -97,55 +97,6 @@ function checkAllSearches(aQuery, aExpectedCount)
|
||||
checkSearchLogins(aQuery, aExpectedCount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests findLogins, searchLogins, and countLogins with a different set of
|
||||
* queries for the search and expected resultset.
|
||||
*
|
||||
* @param {Object} aQuery
|
||||
* The "hostname", "formSubmitURL", and "httpRealm" properties of this
|
||||
* object are passed as parameters to findLogins, countLogins
|
||||
* and searchLogins function.
|
||||
* @param {Object} buildQuery
|
||||
* The "hostname", "formSubmitURL", and "httpRealm" properties of the
|
||||
* object used to build the expected logins to have as a result.
|
||||
* @param {Number} aExpectedCount
|
||||
* Number of logins from the test data that should be found. The actual
|
||||
* list of logins is obtained using the buildExpectedLogins helper, and
|
||||
* this value is just used to verify that modifications to the test data
|
||||
* don't make the current test meaningless.
|
||||
*/
|
||||
function checkAllSearchesTwoSets(aQuery, expectedQuery, aExpectedCount)
|
||||
{
|
||||
do_print("Testing all search functions for " + JSON.stringify(aQuery) +
|
||||
" and " + JSON.stringify(expectedQuery));
|
||||
|
||||
let expectedLogins = buildExpectedLogins(expectedQuery);
|
||||
|
||||
// The findLogins and countLogins functions support wildcard matches by
|
||||
// specifying empty strings as parameters, while searchLogins requires
|
||||
// omitting the property entirely.
|
||||
let hostname = ("hostname" in aQuery) ? aQuery.hostname : "";
|
||||
let formSubmitURL = ("formSubmitURL" in aQuery) ? aQuery.formSubmitURL : "";
|
||||
let httpRealm = ("httpRealm" in aQuery) ? aQuery.httpRealm : "";
|
||||
|
||||
// Test findLogins.
|
||||
let outCount = {};
|
||||
let logins = Services.logins.findLogins(outCount, hostname, formSubmitURL,
|
||||
httpRealm);
|
||||
do_check_eq(outCount.value, expectedLogins.length);
|
||||
LoginTestUtils.assertLoginListsMatches(logins, expectedLogins, true);
|
||||
|
||||
// Test countLogins.
|
||||
let count = Services.logins.countLogins(hostname, formSubmitURL, httpRealm)
|
||||
do_check_eq(count, expectedLogins.length);
|
||||
|
||||
// Test searchLogins.
|
||||
outCount = {};
|
||||
logins = Services.logins.searchLogins(outCount, newPropertyBag(expectedQuery));
|
||||
do_check_eq(outCount.value, expectedLogins.length);
|
||||
LoginTestUtils.assertLoginListsMatches(logins, expectedLogins, true);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//// Tests
|
||||
|
||||
@ -165,10 +116,10 @@ add_task(function test_initialize()
|
||||
add_task(function test_search_all_basic()
|
||||
{
|
||||
// Find all logins, using no filters in the search functions.
|
||||
checkAllSearches({}, 22);
|
||||
checkAllSearches({}, 23);
|
||||
|
||||
// Find all form logins, then all authentication logins.
|
||||
checkAllSearches({ httpRealm: null }, 13);
|
||||
checkAllSearches({ httpRealm: null }, 14);
|
||||
checkAllSearches({ formSubmitURL: null }, 9);
|
||||
|
||||
// Find all form logins on one host, then all authentication logins.
|
||||
@ -181,16 +132,18 @@ add_task(function test_search_all_basic()
|
||||
checkAllSearches({ hostname: "http://www.example.com" }, 1);
|
||||
checkAllSearches({ hostname: "https://www.example.com" }, 1);
|
||||
checkAllSearches({ hostname: "https://example.com" }, 1);
|
||||
checkAllSearches({ hostname: "http://www3.example.com" }, 2);
|
||||
checkAllSearches({ hostname: "http://www3.example.com" }, 3);
|
||||
|
||||
// Verify that scheme and subdomain are distinct in formSubmitURL.
|
||||
checkAllSearches({ formSubmitURL: "http://www.example.com" }, 2);
|
||||
checkAllSearches({ formSubmitURL: "https://www.example.com" }, 1);
|
||||
checkAllSearches({ formSubmitURL: "https://www.example.com" }, 2);
|
||||
checkAllSearches({ formSubmitURL: "http://example.com" }, 1);
|
||||
|
||||
// Find by formSubmitURL on a single host.
|
||||
checkAllSearches({ hostname: "http://www3.example.com",
|
||||
formSubmitURL: "http://www.example.com" }, 1);
|
||||
checkAllSearches({ hostname: "http://www3.example.com",
|
||||
formSubmitURL: "https://www.example.com" }, 1);
|
||||
checkAllSearches({ hostname: "http://www3.example.com",
|
||||
formSubmitURL: "http://example.com" }, 1);
|
||||
|
||||
@ -213,8 +166,8 @@ add_task(function test_search_all_basic()
|
||||
*/
|
||||
add_task(function test_searchLogins()
|
||||
{
|
||||
checkSearchLogins({ usernameField: "form_field_username" }, 11);
|
||||
checkSearchLogins({ passwordField: "form_field_password" }, 12);
|
||||
checkSearchLogins({ usernameField: "form_field_username" }, 12);
|
||||
checkSearchLogins({ passwordField: "form_field_password" }, 13);
|
||||
|
||||
// Find all logins with an empty usernameField, including for authentication.
|
||||
checkSearchLogins({ usernameField: "" }, 11);
|
||||
@ -250,6 +203,7 @@ add_task(function test_search_all_full_case_sensitive()
|
||||
checkAllSearches({ hostname: "example.com" }, 0);
|
||||
|
||||
checkAllSearches({ formSubmitURL: "http://www.example.com" }, 2);
|
||||
checkAllSearches({ formSubmitURL: "http://www.example.com/" }, 0);
|
||||
checkAllSearches({ formSubmitURL: "http://" }, 0);
|
||||
checkAllSearches({ formSubmitURL: "example.com" }, 0);
|
||||
|
||||
@ -272,19 +226,3 @@ add_task(function test_search_all_empty()
|
||||
checkSearchLogins({ hostname: "" }, 0);
|
||||
checkSearchLogins({ id: "1000" }, 0);
|
||||
});
|
||||
|
||||
|
||||
add_task(function test_search_different_formSubmitURL_scheme()
|
||||
{
|
||||
let aQuery = {
|
||||
formSubmitURL: "https://www.example.com",
|
||||
hostname: "http://www.example.com",
|
||||
};
|
||||
|
||||
let buildQuery = {
|
||||
formSubmitURL: "http://www.example.com",
|
||||
hostname: "http://www.example.com",
|
||||
}
|
||||
|
||||
checkAllSearchesTwoSets(aQuery, buildQuery, 1);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user