Bug 1079656 - Make the Loop Account menu item work after a restart. r=jaws

--HG--
extra : rebase_source : 2eaec891d86c1920fd25eac99c6126f9308f8d2a
This commit is contained in:
Matthew Noorenberghe 2014-10-13 22:47:47 -07:00
parent 77bfc5d2c3
commit f248dc6633
2 changed files with 53 additions and 5 deletions

View File

@ -1605,11 +1605,21 @@ this.MozLoopService = {
MozLoopServiceInternal.clearError("profile");
}),
openFxASettings: function() {
let url = new URL("/settings", gFxAOAuthClient.parameters.content_uri);
let win = Services.wm.getMostRecentWindow("navigator:browser");
win.switchToTabHavingURI(url.toString(), true);
},
openFxASettings: Task.async(function() {
try {
let fxAOAuthClient = yield MozLoopServiceInternal.promiseFxAOAuthClient();
if (!fxAOAuthClient) {
log.error("Could not get the OAuth client");
return;
}
let url = new URL("/settings", fxAOAuthClient.parameters.content_uri);
let win = Services.wm.getMostRecentWindow("navigator:browser");
win.switchToTabHavingURI(url.toString(), true);
} catch (ex) {
log.error("Error opening FxA settings", ex);
}
}),
/**
* Performs a hawk based request to the loop server.

View File

@ -391,3 +391,41 @@ add_task(function* loginWithRegistration401() {
yield checkFxA401();
});
add_task(function* openFxASettings() {
yield resetFxA();
// Since the default b-c window has a blank tab, open a new non-blank tab to
// force switchToTabHavingURI to open a new tab instead of reusing the current
// blank tab.
gBrowser.selectedTab = gBrowser.addTab(BASE_URL);
let params = {
client_id: "client_id",
content_uri: BASE_URL + "/content",
oauth_uri: BASE_URL + "/oauth",
profile_uri: BASE_URL + "/profile",
state: "state",
test_error: "token_401",
};
yield promiseOAuthParamsSetup(BASE_URL, params);
let deferredTab = Promise.defer();
let progressListener = {
onLocationChange: function onLocationChange(aBrowser) {
gBrowser.removeTabsProgressListener(progressListener);
let contentURI = Services.io.newURI(params.content_uri, null, null);
is(aBrowser.currentURI.spec, Services.io.newURI("/settings", null, contentURI).spec,
"Check settings tab URL");
deferredTab.resolve();
},
};
gBrowser.addTabsProgressListener(progressListener);
MozLoopService.openFxASettings();
yield deferredTab.promise;
while (gBrowser.tabs.length > 1) {
gBrowser.removeTab(gBrowser.tabs[1]);
}
});