Merge birch to m-c.

This commit is contained in:
Ryan VanderMeulen 2013-05-01 15:29:18 -04:00
commit 4274bb3099
3 changed files with 75 additions and 2 deletions

View File

@ -136,7 +136,7 @@ Pipe.prototype = {
Services.obs.addObserver(this, "identity-controller-unwatch", false);
},
uninit: function pipe_init() {
uninit: function pipe_uninit() {
Services.obs.removeObserver(this, "identity-child-process-shutdown");
Services.obs.removeObserver(this, "identity-controller-unwatch");
},

View File

@ -106,6 +106,7 @@ function test_watch() {
let mockedDoc = mockDoc({loggedInUser: null}, function(action, params) {
do_check_eq(action, 'ready');
controller.uninit();
MinimalIDService.RP.unwatch(mockedDoc.id);
do_test_finished();
run_next_test();
});
@ -130,6 +131,7 @@ function test_request_login() {
do_check_eq(action, 'login');
do_check_eq(params, TEST_CERT);
controller.uninit();
MinimalIDService.RP.unwatch(mockedDoc.id);
do_test_finished();
run_next_test();
}
@ -156,6 +158,7 @@ function test_request_logout() {
do_check_eq(action, 'logout');
do_check_eq(params, undefined);
controller.uninit();
MinimalIDService.RP.unwatch(mockedDoc.id);
do_test_finished();
run_next_test();
}
@ -186,6 +189,7 @@ function test_request_login_logout() {
do_check_eq(action, 'logout');
do_check_eq(params, undefined);
controller.uninit();
MinimalIDService.RP.unwatch(mockedDoc.id);
do_test_finished();
run_next_test();
}
@ -198,6 +202,60 @@ function test_request_login_logout() {
});
}
function test_logout_everywhere() {
do_test_pending();
let logouts = 0;
setup_test_identity("fugu@food.gov", TEST_CERT, function() {
let controller = SignInToWebsiteController;
let mockedDoc1 = mockDoc({loggedInUser: null}, call_sequentially(
function(action, params) {
do_check_eq(action, 'ready');
},
function(action, params) {
do_check_eq(action, 'login');
},
function(action, params) {
// Result of logout from doc2.
// We don't know what order the logouts will occur in.
do_check_eq(action, 'logout');
if (++logouts === 2) {
do_test_finished();
run_next_test();
}
}
));
let mockedDoc2 = mockDoc({loggedInUser: null}, call_sequentially(
function(action, params) {
do_check_eq(action, 'ready');
},
function(action, params) {
do_check_eq(action, 'login');
},
function(action, params) {
do_check_eq(action, 'logout');
if (++logouts === 2) {
do_test_finished();
run_next_test();
}
}
));
controller.init({pipe: mockReceivingPipe()});
MinimalIDService.RP.watch(mockedDoc1, {});
MinimalIDService.RP.request(mockedDoc1.id, {});
MinimalIDService.RP.watch(mockedDoc2, {});
MinimalIDService.RP.request(mockedDoc2.id, {});
// Logs out of both docs because they share the
// same origin.
MinimalIDService.RP.logout(mockedDoc2.id, {});
});
}
function test_options_pass_through() {
do_test_pending();
@ -230,6 +288,8 @@ function test_options_pass_through() {
break;
case "identity-delegate-logout":
do_test_finished();
controller.uninit();
MinimalIDService.RP.unwatch(mockedDoc.id);
run_next_test();
break;
}
@ -250,6 +310,7 @@ let TESTS = [
test_request_login,
test_request_logout,
test_request_login_logout,
test_logout_everywhere,
test_options_pass_through
];

View File

@ -134,6 +134,8 @@ IDService.prototype = {
// store the caller structure and notify the UI observers
this._rpFlows[aRpCaller.id] = aRpCaller;
log("flows:", Object.keys(this._rpFlows).join(', '));
let options = makeMessageObject(aRpCaller);
log("sending identity-controller-watch:", options);
Services.obs.notifyObservers({wrappedJSObject: options},"identity-controller-watch", null);
@ -152,6 +154,9 @@ IDService.prototype = {
});
log("sending identity-controller-unwatch for id", options.id, options.origin);
Services.obs.notifyObservers({wrappedJSObject: options}, "identity-controller-unwatch", null);
// Stop sending messages to this window
delete this._rpFlows[aRpId];
},
/**
@ -223,7 +228,14 @@ IDService.prototype = {
return;
}
rp.doLogout();
// Logout from every site with the same origin
let origin = rp.origin;
Object.keys(this._rpFlows).forEach(function(key) {
let rp = this._rpFlows[key];
if (rp.origin === origin) {
rp.doLogout();
}
}.bind(this));
},
doReady: function doReady(aRpCallerId) {