mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1547398 - Allow fxa_status when isPairing is sent. r=vladikoff
Differential Revision: https://phabricator.services.mozilla.com/D29082 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7798ff2db3
commit
ac739078cc
@ -185,7 +185,8 @@ this.FxAccountsWebChannel.prototype = {
|
||||
log.debug("fxa_status received");
|
||||
|
||||
const service = data && data.service;
|
||||
this._helpers.getFxaStatus(service, sendingContext)
|
||||
const isPairing = data && data.isPairing;
|
||||
this._helpers.getFxaStatus(service, sendingContext, isPairing)
|
||||
.then(fxaStatus => {
|
||||
let response = {
|
||||
command,
|
||||
@ -381,9 +382,10 @@ this.FxAccountsWebChannelHelpers.prototype = {
|
||||
/**
|
||||
* Check whether sending fxa_status data should be allowed.
|
||||
*/
|
||||
shouldAllowFxaStatus(service, sendingContext) {
|
||||
shouldAllowFxaStatus(service, sendingContext, isPairing) {
|
||||
// Return user data for any service in non-PB mode. In PB mode,
|
||||
// only return user data if service==="sync".
|
||||
// only return user data if service==="sync" or is in pairing mode
|
||||
// (as service will be equal to the OAuth client ID and not "sync").
|
||||
//
|
||||
// This behaviour allows users to click the "Manage Account"
|
||||
// link from about:preferences#sync while in PB mode and things
|
||||
@ -398,7 +400,7 @@ this.FxAccountsWebChannelHelpers.prototype = {
|
||||
// Sync is broken in PB mode, users will think Firefox is broken.
|
||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1323853
|
||||
log.debug("service", service);
|
||||
return !this.isPrivateBrowsingMode(sendingContext) || service === "sync";
|
||||
return !this.isPrivateBrowsingMode(sendingContext) || service === "sync" || isPairing;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -406,10 +408,10 @@ this.FxAccountsWebChannelHelpers.prototype = {
|
||||
* If returning status information is not allowed or no user is signed into
|
||||
* Sync, `user_data` will be null.
|
||||
*/
|
||||
async getFxaStatus(service, sendingContext) {
|
||||
async getFxaStatus(service, sendingContext, isPairing) {
|
||||
let signedInUser = null;
|
||||
|
||||
if (this.shouldAllowFxaStatus(service, sendingContext)) {
|
||||
if (this.shouldAllowFxaStatus(service, sendingContext, isPairing)) {
|
||||
const userData = await this._fxAccounts.getSignedInUser();
|
||||
if (userData) {
|
||||
signedInUser = {
|
||||
|
@ -636,7 +636,7 @@ add_task(async function test_helpers_shouldAllowFxaStatus_sync_service_not_priva
|
||||
return false;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("sync", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("sync", mockSendingContext, false);
|
||||
Assert.ok(shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
@ -653,7 +653,7 @@ add_task(async function test_helpers_shouldAllowFxaStatus_oauth_service_not_priv
|
||||
return false;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("dcdb5ae7add825d2", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("dcdb5ae7add825d2", mockSendingContext, false);
|
||||
Assert.ok(shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
@ -670,7 +670,7 @@ add_task(async function test_helpers_shouldAllowFxaStatus_no_service_not_private
|
||||
return false;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("", mockSendingContext, false);
|
||||
Assert.ok(shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
@ -687,7 +687,7 @@ add_task(async function test_helpers_shouldAllowFxaStatus_sync_service_private_b
|
||||
return true;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("sync", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("sync", mockSendingContext, false);
|
||||
Assert.ok(shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
@ -704,11 +704,28 @@ add_task(async function test_helpers_shouldAllowFxaStatus_oauth_service_private_
|
||||
return true;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("dcdb5ae7add825d2", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("dcdb5ae7add825d2", mockSendingContext, false);
|
||||
Assert.ok(!shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
|
||||
add_task(async function test_helpers_shouldAllowFxaStatus_oauth_service_pairing_private_browsing() {
|
||||
let wasCalled = {
|
||||
isPrivateBrowsingMode: false,
|
||||
};
|
||||
let helpers = new FxAccountsWebChannelHelpers({});
|
||||
|
||||
helpers.isPrivateBrowsingMode = (sendingContext) => {
|
||||
wasCalled.isPrivateBrowsingMode = true;
|
||||
Assert.equal(sendingContext, mockSendingContext);
|
||||
return true;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("dcdb5ae7add825d2", mockSendingContext, true);
|
||||
Assert.ok(shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
|
||||
add_task(async function test_helpers_shouldAllowFxaStatus_no_service_private_browsing() {
|
||||
let wasCalled = {
|
||||
isPrivateBrowsingMode: false,
|
||||
@ -721,7 +738,7 @@ add_task(async function test_helpers_shouldAllowFxaStatus_no_service_private_bro
|
||||
return true;
|
||||
};
|
||||
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("", mockSendingContext);
|
||||
let shouldAllowFxaStatus = helpers.shouldAllowFxaStatus("", mockSendingContext, false);
|
||||
Assert.ok(!shouldAllowFxaStatus);
|
||||
Assert.ok(wasCalled.isPrivateBrowsingMode);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user