Backout f79e4c7902a1 (Bug 780987) due to talos being angry and red-faced
@ -293,12 +293,6 @@ let SocialFlyout = {
|
||||
}
|
||||
|
||||
let SocialShareButton = {
|
||||
// promptImages and promptMessages being null means we are yet to get the
|
||||
// message back from the provider with the images and icons (or that we got
|
||||
// the response but determined it was invalid.)
|
||||
promptImages: null,
|
||||
promptMessages: null,
|
||||
|
||||
// Called once, after window load, when the Social.provider object is initialized
|
||||
init: function SSB_init() {
|
||||
this.updateButtonHiddenState();
|
||||
@ -317,59 +311,6 @@ let SocialShareButton = {
|
||||
} else {
|
||||
profileRow.hidden = true;
|
||||
}
|
||||
// XXX - this shouldn't be done as part of updateProfileInfo, but instead
|
||||
// whenever we notice the provider has changed - but the concept of
|
||||
// "provider changed" will only exist once bug 774520 lands.
|
||||
this.promptImages = null;
|
||||
this.promptMessages = null;
|
||||
// get the recommend-prompt info.
|
||||
let port = Social.provider._getWorkerPort();
|
||||
port.onmessage = function(evt) {
|
||||
if (evt.data.topic == "social.user-recommend-prompt-response") {
|
||||
port.close();
|
||||
this.acceptRecommendInfo(evt.data.data);
|
||||
this.updateButtonHiddenState();
|
||||
this.updateShareState();
|
||||
}
|
||||
}.bind(this);
|
||||
port.postMessage({topic: "social.user-recommend-prompt"});
|
||||
},
|
||||
|
||||
acceptRecommendInfo: function SSB_acceptRecommendInfo(data) {
|
||||
// Accept *and validate* the user-recommend-prompt-response message.
|
||||
let promptImages = {};
|
||||
let promptMessages = {};
|
||||
function reportError(reason) {
|
||||
Cu.reportError("Invalid recommend data from provider: " + reason + ": sharing is disabled for this provider");
|
||||
return false;
|
||||
}
|
||||
if (!data ||
|
||||
!data.images || typeof data.images != "object" ||
|
||||
!data.messages || typeof data.messages != "object") {
|
||||
return reportError("data is missing valid 'images' or 'messages' elements");
|
||||
}
|
||||
for (let sub of ["share", "unshare"]) {
|
||||
let url = data.images[sub];
|
||||
if (!url || typeof url != "string" || url.length == 0) {
|
||||
return reportError('images["' + sub + '"] is missing or not a non-empty string');
|
||||
}
|
||||
// resolve potentially relative URLs then check the scheme is acceptable.
|
||||
url = Services.io.newURI(Social.provider.origin, null, null).resolve(url);
|
||||
let uri = Services.io.newURI(url, null, null);
|
||||
if (!uri.schemeIs("http") && !uri.schemeIs("https") && !uri.schemeIs("data")) {
|
||||
return reportError('images["' + sub + '"] does not have a valid scheme');
|
||||
}
|
||||
promptImages[sub] = url;
|
||||
}
|
||||
for (let sub of ["shareTooltip", "unshareTooltip", "sharedLabel", "unsharedLabel"]) {
|
||||
if (typeof data.messages[sub] != "string" || data.messages[sub].length == 0) {
|
||||
return reportError('messages["' + sub + '"] is not a valid string');
|
||||
}
|
||||
promptMessages[sub] = data.messages[sub];
|
||||
}
|
||||
this.promptImages = promptImages;
|
||||
this.promptMessages = promptMessages;
|
||||
return true;
|
||||
},
|
||||
|
||||
get shareButton() {
|
||||
@ -386,7 +327,7 @@ let SocialShareButton = {
|
||||
updateButtonHiddenState: function SSB_updateButtonHiddenState() {
|
||||
let shareButton = this.shareButton;
|
||||
if (shareButton)
|
||||
shareButton.hidden = !Social.uiVisible || this.promptImages == null;
|
||||
shareButton.hidden = !Social.uiVisible;
|
||||
},
|
||||
|
||||
onClick: function SSB_onClick(aEvent) {
|
||||
@ -429,33 +370,23 @@ let SocialShareButton = {
|
||||
// Provide a11y-friendly notification of share.
|
||||
let status = document.getElementById("share-button-status");
|
||||
if (status) {
|
||||
// XXX - this should also be capable of reflecting that the page was
|
||||
// unshared (ie, it needs to manage three-states: (1) nothing done, (2)
|
||||
// shared, (3) shared then unshared)
|
||||
// Note that we *do* have an appropriate string from the provider for
|
||||
// this (promptMessages['unsharedLabel'] but currently lack a way of
|
||||
// tracking this state)
|
||||
let statusString = currentPageShared ?
|
||||
this.promptMessages['sharedLabel'] : "";
|
||||
gNavigatorBundle.getString("social.pageShared.label") : "";
|
||||
status.setAttribute("value", statusString);
|
||||
}
|
||||
|
||||
// Update the share button, if present
|
||||
let shareButton = this.shareButton;
|
||||
if (!shareButton || shareButton.hidden)
|
||||
if (!shareButton)
|
||||
return;
|
||||
|
||||
let imageURL;
|
||||
if (currentPageShared) {
|
||||
shareButton.setAttribute("shared", "true");
|
||||
shareButton.setAttribute("tooltiptext", this.promptMessages['unshareTooltip']);
|
||||
imageURL = this.promptImages["unshare"]
|
||||
shareButton.setAttribute("tooltiptext", gNavigatorBundle.getString("social.shareButton.sharedtooltip"));
|
||||
} else {
|
||||
shareButton.removeAttribute("shared");
|
||||
shareButton.setAttribute("tooltiptext", this.promptMessages['shareTooltip']);
|
||||
imageURL = this.promptImages["share"]
|
||||
shareButton.setAttribute("tooltiptext", gNavigatorBundle.getString("social.shareButton.tooltip"));
|
||||
}
|
||||
shareButton.style.backgroundImage = 'url("' + encodeURI(imageURL) + '")';
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -268,7 +268,6 @@ _BROWSER_FILES = \
|
||||
browser_social_isVisible.js \
|
||||
browser_social_chatwindow.js \
|
||||
social_panel.html \
|
||||
social_share_image.png \
|
||||
social_sidebar.html \
|
||||
social_chat.html \
|
||||
social_flyout.html \
|
||||
|
@ -48,12 +48,11 @@ function testInitial(finishcb) {
|
||||
|
||||
let okButton = document.getElementById("editSharePopupOkButton");
|
||||
let undoButton = document.getElementById("editSharePopupUndoButton");
|
||||
let shareStatusLabel = document.getElementById("share-button-status");
|
||||
|
||||
// ensure the worker initialization and handshakes are all done and we
|
||||
// have a profile and the worker has responsed to the recommend-prompt msg.
|
||||
waitForCondition(function() Social.provider.profile && SocialShareButton.promptImages != null, function() {
|
||||
is(shareButton.hasAttribute("shared"), false, "Share button should not have 'shared' attribute before share button is clicked");
|
||||
// have a profile.
|
||||
waitForCondition(function() Social.provider.profile, function() {
|
||||
is(shareButton.hidden, false, "share button should be visible");
|
||||
// check dom values
|
||||
let profile = Social.provider.profile;
|
||||
let portrait = document.getElementById("socialUserPortrait").getAttribute("src");
|
||||
@ -62,24 +61,14 @@ function testInitial(finishcb) {
|
||||
is(displayName.label, profile.displayName, "display name is set");
|
||||
ok(!document.getElementById("editSharePopupHeader").hidden, "user profile is visible");
|
||||
|
||||
// Check the strings from our worker actually ended up on the button.
|
||||
is(shareButton.getAttribute("tooltiptext"), "Share this page", "check tooltip text is correct");
|
||||
is(shareStatusLabel.getAttribute("value"), "", "check status label text is blank");
|
||||
// Check the relative URL was resolved correctly (note this image has offsets of zero...)
|
||||
is(shareButton.style.backgroundImage, 'url("https://example.com/browser/browser/base/content/test/social_share_image.png")', "check image url is correct");
|
||||
|
||||
// Test clicking the share button
|
||||
shareButton.addEventListener("click", function listener() {
|
||||
shareButton.removeEventListener("click", listener);
|
||||
is(shareButton.hasAttribute("shared"), true, "Share button should have 'shared' attribute after share button is clicked");
|
||||
is(shareButton.getAttribute("tooltiptext"), "Unshare this page", "check tooltip text is correct");
|
||||
is(shareStatusLabel.getAttribute("value"), "This page has been shared", "check status label text is correct");
|
||||
// Check the URL and offsets were applied correctly
|
||||
is(shareButton.style.backgroundImage, 'url("https://example.com/browser/browser/base/content/test/social_share_image.png")', "check image url is correct");
|
||||
executeSoon(testSecondClick.bind(window, testPopupOKButton));
|
||||
});
|
||||
EventUtils.synthesizeMouseAtCenter(shareButton, {});
|
||||
}, "provider didn't provide user-recommend-prompt response");
|
||||
}, "provider didn't provide a profile");
|
||||
}
|
||||
|
||||
function testSecondClick(nextTest) {
|
||||
|
@ -134,15 +134,6 @@ function runSocialTestWithProvider(manifest, callback) {
|
||||
Services.prefs.setBoolPref("social.enabled", true);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
// if one test happens to fail, it is likely finishSocialTest will not
|
||||
// be called, causing most future social tests to also fail as they
|
||||
// attempt to add a provider which already exists - so work
|
||||
// around that by also attempting to remove the test provider.
|
||||
try {
|
||||
SocialService.removeProvider(provider.origin, finish);
|
||||
} catch (ex) {
|
||||
;
|
||||
}
|
||||
Social.provider = oldProvider;
|
||||
Services.prefs.clearUserPref("social.enabled");
|
||||
});
|
||||
|
Before Width: | Height: | Size: 934 B |
@ -87,25 +87,6 @@ onconnect = function(e) {
|
||||
case "test-isVisible-response":
|
||||
testPort.postMessage({topic: "got-isVisible-response", result: event.data.result});
|
||||
break;
|
||||
case "social.user-recommend-prompt":
|
||||
port.postMessage({
|
||||
topic: "social.user-recommend-prompt-response",
|
||||
data: {
|
||||
images: {
|
||||
// this one is relative to test we handle relative ones.
|
||||
share: "browser/browser/base/content/test/social_share_image.png",
|
||||
// absolute to check we handle them too.
|
||||
unshare: "https://example.com/browser/browser/base/content/test/social_share_image.png"
|
||||
},
|
||||
messages: {
|
||||
shareTooltip: "Share this page",
|
||||
unshareTooltip: "Unshare this page",
|
||||
sharedLabel: "This page has been shared",
|
||||
unsharedLabel: "This page is no longer shared",
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -372,6 +372,10 @@ fullscreen.entered=%S is now fullscreen.
|
||||
# LOCALIZATION NOTE (fullscreen.rememberDecision): displayed when we enter HTML5 fullscreen mode, %S is the domain name of the focused website (e.g. mozilla.com).
|
||||
fullscreen.rememberDecision=Remember decision for %S
|
||||
|
||||
social.shareButton.tooltip=Share this
|
||||
social.shareButton.sharedtooltip=You shared this
|
||||
social.pageShared.label=Page shared
|
||||
|
||||
# LOCALIZATION NOTE (social.toggle.label): %1$S is the name of the social provider, %2$S is brandShortName (e.g. Firefox)
|
||||
social.toggle.label=%1$S for %2$S
|
||||
social.toggle.accesskey=f
|
||||
|
@ -1373,8 +1373,15 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
|
||||
/* social recommending panel */
|
||||
|
||||
#share-button {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: url(chrome://browser/skin/share-button.png);
|
||||
}
|
||||
|
||||
#share-button:not([shared]):not([disabled]):hover {
|
||||
list-style-image: url(chrome://browser/skin/share-button-active.png);
|
||||
}
|
||||
|
||||
#share-button[shared] {
|
||||
list-style-image: url(chrome://browser/skin/share-button-shared.png);
|
||||
}
|
||||
|
||||
#socialUserPortrait {
|
||||
|
@ -39,6 +39,9 @@ browser.jar:
|
||||
skin/classic/browser/Secure.png
|
||||
skin/classic/browser/Security-broken.png
|
||||
skin/classic/browser/setDesktopBackground.css
|
||||
skin/classic/browser/share-button.png
|
||||
skin/classic/browser/share-button-active.png
|
||||
skin/classic/browser/share-button-shared.png
|
||||
skin/classic/browser/Toolbar.png
|
||||
skin/classic/browser/Toolbar-small.png
|
||||
skin/classic/browser/urlbar-arrow.png
|
||||
|
BIN
browser/themes/gnomestripe/share-button-active.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
browser/themes/gnomestripe/share-button-shared.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
browser/themes/gnomestripe/share-button.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
@ -1245,8 +1245,15 @@ window[tabsontop="false"] richlistitem[type~="action"][actiontype="switchtab"][s
|
||||
/* social recommending panel */
|
||||
|
||||
#share-button {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: url(chrome://browser/skin/share-button.png);
|
||||
}
|
||||
|
||||
#share-button:not([shared]):not([disabled]):hover {
|
||||
list-style-image: url(chrome://browser/skin/share-button-active.png);
|
||||
}
|
||||
|
||||
#share-button[shared] {
|
||||
list-style-image: url(chrome://browser/skin/share-button-shared.png);
|
||||
}
|
||||
|
||||
#socialUserPortrait {
|
||||
|
@ -64,6 +64,9 @@ browser.jar:
|
||||
skin/classic/browser/newtab/controls.png (newtab/controls.png)
|
||||
skin/classic/browser/newtab/noise.png (newtab/noise.png)
|
||||
skin/classic/browser/setDesktopBackground.css
|
||||
skin/classic/browser/share-button.png
|
||||
skin/classic/browser/share-button-active.png
|
||||
skin/classic/browser/share-button-shared.png
|
||||
skin/classic/browser/monitor.png
|
||||
skin/classic/browser/monitor_16-10.png
|
||||
skin/classic/browser/places/allBookmarks.png (places/allBookmarks.png)
|
||||
|
BIN
browser/themes/pinstripe/share-button-active.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
browser/themes/pinstripe/share-button-shared.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
browser/themes/pinstripe/share-button.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
@ -1636,8 +1636,15 @@ richlistitem[type~="action"][actiontype="switchtab"] > .ac-url-box > .ac-action-
|
||||
/* social recommending panel */
|
||||
|
||||
#share-button {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
list-style-image: url(chrome://browser/skin/share-button.png);
|
||||
}
|
||||
|
||||
#share-button:not([shared]):not([disabled]):hover {
|
||||
list-style-image: url(chrome://browser/skin/share-button-active.png);
|
||||
}
|
||||
|
||||
#share-button[shared] {
|
||||
list-style-image: url(chrome://browser/skin/share-button-shared.png);
|
||||
}
|
||||
|
||||
#socialUserPortrait {
|
||||
|
@ -50,6 +50,9 @@ browser.jar:
|
||||
skin/classic/browser/searchbar.css (searchbar.css)
|
||||
skin/classic/browser/searchbar-dropdown-arrow.png
|
||||
skin/classic/browser/setDesktopBackground.css
|
||||
skin/classic/browser/share-button.png
|
||||
skin/classic/browser/share-button-active.png
|
||||
skin/classic/browser/share-button-shared.png
|
||||
skin/classic/browser/menu-back.png (menu-back.png)
|
||||
skin/classic/browser/menu-forward.png (menu-forward.png)
|
||||
skin/classic/browser/monitor.png
|
||||
@ -251,6 +254,9 @@ browser.jar:
|
||||
skin/classic/aero/browser/searchbar.css (searchbar.css)
|
||||
skin/classic/aero/browser/searchbar-dropdown-arrow.png (searchbar-dropdown-arrow-aero.png)
|
||||
skin/classic/aero/browser/setDesktopBackground.css
|
||||
skin/classic/aero/browser/share-button.png
|
||||
skin/classic/aero/browser/share-button-active.png
|
||||
skin/classic/aero/browser/share-button-shared.png
|
||||
skin/classic/aero/browser/menu-back.png (menu-back-aero.png)
|
||||
skin/classic/aero/browser/menu-forward.png (menu-forward-aero.png)
|
||||
skin/classic/aero/browser/monitor.png
|
||||
|
BIN
browser/themes/winstripe/share-button-active.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
browser/themes/winstripe/share-button-shared.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
browser/themes/winstripe/share-button.png
Normal file
After Width: | Height: | Size: 1.2 KiB |