bug 936712 open marks panel on first click if user not logged in, r=markh

This commit is contained in:
Shane Caraveo 2013-11-22 11:05:06 -08:00
parent 779f3c9324
commit 32a0353553
2 changed files with 65 additions and 4 deletions

View File

@ -145,11 +145,10 @@
<body><![CDATA[
// we always set the src on click if it has not been set for this tab,
// but we only want to open the panel if it was previously annotated.
let openPanel = this.isMarked || aOpenPanel;
let openPanel = this.isMarked || aOpenPanel || !this.provider.haveLoggedInUser();
let src = this.getAttribute("src");
if (!src || src == "about:blank") {
this.loadPanel();
this.isMarked = true;
}
if (openPanel)
this.panel.openPopup(this, "bottomcenter topright", 0, 0, false, false);
@ -170,7 +169,6 @@
// previous url when it is closed.
this.setAttribute("src", "about:blank");
this.loadPanel({ url: aUrl });
this.isMarked = true;
this.panel.openPopup(this, "bottomcenter topright", 0, 0, false, false);
this.panel.addEventListener("popuphidden", function _hidden() {
this.panel.removeEventListener("popuphidden", _hidden);

View File

@ -199,6 +199,7 @@ var tests = {
EventUtils.synthesizeMouseAtCenter(btn, {});
// wait for the button to be marked, click to open panel
waitForCondition(function() btn.isMarked, function() {
is(btn.panel.state, "closed", "panel should not be visible yet");
EventUtils.synthesizeMouseAtCenter(btn, {});
}, "button is marked");
break;
@ -214,7 +215,69 @@ var tests = {
// page should no longer be marked
port.close();
waitForCondition(function() !btn.isMarked, function() {
// after closing the addons tab, verify provider is still installed
// cleanup after the page has been unmarked
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
executeSoon(function () {
ok(btn.disabled, "button is disabled");
next();
});
});
gBrowser.removeTab(tab);
}, "button unmarked");
}
break;
}
};
port.postMessage({topic: "test-init"});
});
},
testMarkPanelLoggedOut: function(next) {
// click on panel to open and wait for visibility
let provider = Social._getProviderFromOrigin(manifest2.origin);
ok(provider.enabled, "provider is enabled");
let id = "social-mark-button-" + provider.origin;
let btn = document.getElementById(id)
ok(btn, "got a mark button");
let port = provider.getWorkerPort();
ok(port, "got a port");
// verify markbutton is disabled when there is no browser url
ok(btn.disabled, "button is disabled");
let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html"
addTab(activationURL, function(tab) {
ok(!btn.disabled, "button is enabled");
port.onmessage = function (e) {
let topic = e.data.topic;
switch (topic) {
case "test-init-done":
ok(true, "test-init-done received");
ok(provider.profile.userName, "profile was set by test worker");
port.postMessage({topic: "test-logout"});
waitForCondition(function() !provider.profile.userName,
function() {
// when the provider has not indicated to us that a user is
// logged in, the first click opens the page.
EventUtils.synthesizeMouseAtCenter(btn, {});
},
"profile was unset by test worker");
break;
case "got-social-panel-visibility":
ok(true, "got the panel message " + e.data.result);
if (e.data.result == "shown") {
// our test marks the page during the load event (see
// social_mark.html) regardless of login state, unmark the page
// via the button in the page
let doc = btn.contentDocument;
let unmarkBtn = doc.getElementById("unmark");
ok(unmarkBtn, "got the panel unmark button");
EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow);
} else {
// page should no longer be marked
port.close();
waitForCondition(function() !btn.isMarked, function() {
// cleanup after the page has been unmarked
gBrowser.tabContainer.addEventListener("TabClose", function onTabClose() {
gBrowser.tabContainer.removeEventListener("TabClose", onTabClose);
executeSoon(function () {