mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1069920 - Firefox Accounts auth dialog does not wait for password. r=spenrose
This commit is contained in:
parent
716950a231
commit
dabda379b7
@ -566,6 +566,10 @@ this.FxAccountsManager = {
|
||||
} else if (permission == Ci.nsIPermissionManager.DENY_ACTION &&
|
||||
!this._refreshing) {
|
||||
return this._error(ERROR_PERMISSION_DENIED);
|
||||
} else if (this._refreshing) {
|
||||
// If we are blocked asking for a password we should not continue
|
||||
// the getAssertion process.
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
return this._getAssertion(aAudience, principal);
|
||||
}
|
||||
|
@ -395,6 +395,127 @@ add_test(function(test_getAssertion_refreshAuth) {
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_getAssertion_no_permissions) {
|
||||
do_print("= getAssertion no permissions =");
|
||||
|
||||
let noPermissionsPrincipal = {origin: 'app://dummy', appId: 28};
|
||||
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let uri = Services.io.newURI(noPermissionsPrincipal.origin, null, null);
|
||||
let _principal = secMan.getAppCodebasePrincipal(uri,
|
||||
noPermissionsPrincipal.appId, false);
|
||||
let permMan = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
permMan.addFromPrincipal(_principal, FXACCOUNTS_PERMISSION,
|
||||
Ci.nsIPermissionManager.DENY_ACTION);
|
||||
|
||||
FxAccountsUIGlue._activeSession = {
|
||||
email: "user@domain.org",
|
||||
verified: true,
|
||||
sessionToken: "1234"
|
||||
};
|
||||
|
||||
FxAccountsManager.getAssertion("audience", noPermissionsPrincipal).then(
|
||||
result => {
|
||||
do_throw("Unexpected success");
|
||||
},
|
||||
error => {
|
||||
do_check_false(FxAccountsUIGlue._signInFlowCalled);
|
||||
do_check_false(FxAccountsUIGlue._refreshAuthCalled);
|
||||
FxAccountsManager._fxAccounts._reset();
|
||||
FxAccountsUIGlue._reset();
|
||||
run_next_test();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_getAssertion_permission_prompt_action) {
|
||||
do_print("= getAssertion PROMPT_ACTION permission =");
|
||||
|
||||
let promptPermissionsPrincipal = {origin: 'app://dummy-prompt', appId: 29};
|
||||
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let uri = Services.io.newURI(promptPermissionsPrincipal.origin, null, null);
|
||||
let _principal = secMan.getAppCodebasePrincipal(uri,
|
||||
promptPermissionsPrincipal.appId, false);
|
||||
let permMan = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
permMan.addFromPrincipal(_principal, FXACCOUNTS_PERMISSION,
|
||||
Ci.nsIPermissionManager.PROMPT_ACTION);
|
||||
|
||||
FxAccountsUIGlue._activeSession = {
|
||||
email: "user@domain.org",
|
||||
verified: true,
|
||||
sessionToken: "1234"
|
||||
};
|
||||
|
||||
FxAccountsManager.getAssertion("audience", promptPermissionsPrincipal).then(
|
||||
result => {
|
||||
do_check_false(FxAccountsUIGlue._signInFlowCalled);
|
||||
do_check_true(FxAccountsUIGlue._refreshAuthCalled);
|
||||
do_check_eq(result, "assertion");
|
||||
|
||||
let permission = permMan.testPermissionFromPrincipal(
|
||||
_principal,
|
||||
FXACCOUNTS_PERMISSION
|
||||
);
|
||||
do_check_eq(permission, Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
FxAccountsManager._fxAccounts._reset();
|
||||
FxAccountsUIGlue._reset();
|
||||
run_next_test();
|
||||
},
|
||||
error => {
|
||||
do_throw("Unexpected error: " + error);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_getAssertion_permission_prompt_action_refreshing) {
|
||||
do_print("= getAssertion PROMPT_ACTION permission already refreshing =");
|
||||
|
||||
let promptPermissionsPrincipal = {origin: 'app://dummy-prompt-2', appId: 30};
|
||||
let secMan = Cc["@mozilla.org/scriptsecuritymanager;1"]
|
||||
.getService(Ci.nsIScriptSecurityManager);
|
||||
let uri = Services.io.newURI(promptPermissionsPrincipal.origin, null, null);
|
||||
let _principal = secMan.getAppCodebasePrincipal(uri,
|
||||
promptPermissionsPrincipal.appId, false);
|
||||
let permMan = Cc["@mozilla.org/permissionmanager;1"]
|
||||
.getService(Ci.nsIPermissionManager);
|
||||
permMan.addFromPrincipal(_principal, FXACCOUNTS_PERMISSION,
|
||||
Ci.nsIPermissionManager.PROMPT_ACTION);
|
||||
|
||||
FxAccountsUIGlue._activeSession = {
|
||||
email: "user@domain.org",
|
||||
verified: true,
|
||||
sessionToken: "1234"
|
||||
};
|
||||
|
||||
FxAccountsManager._refreshing = true;
|
||||
|
||||
FxAccountsManager.getAssertion("audience", promptPermissionsPrincipal).then(
|
||||
result => {
|
||||
do_check_false(FxAccountsUIGlue._signInFlowCalled);
|
||||
do_check_false(FxAccountsUIGlue._refreshAuthCalled);
|
||||
do_check_null(result);
|
||||
|
||||
let permission = permMan.testPermissionFromPrincipal(
|
||||
_principal,
|
||||
FXACCOUNTS_PERMISSION
|
||||
);
|
||||
do_check_eq(permission, Ci.nsIPermissionManager.PROMPT_ACTION);
|
||||
|
||||
FxAccountsManager._refreshing = false;
|
||||
|
||||
FxAccountsManager._fxAccounts._reset();
|
||||
FxAccountsUIGlue._reset();
|
||||
run_next_test();
|
||||
},
|
||||
error => {
|
||||
do_throw("Unexpected error: " + error);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
add_test(function(test_getAssertion_server_state_change) {
|
||||
FxAccountsManager._fxAccounts._signedInUser.verified = true;
|
||||
FxAccountsManager._activeSession.verified = true;
|
||||
|
Loading…
Reference in New Issue
Block a user