mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
bug 891219 new social bookmarks, part 1, remove old socialmarks code
This commit is contained in:
parent
ed5743c2f7
commit
cd4e6438ae
@ -37,9 +37,6 @@
|
||||
label="&bookmarkThisLinkCmd.label;"
|
||||
accesskey="&bookmarkThisLinkCmd.accesskey;"
|
||||
oncommand="gContextMenu.bookmarkLink();"/>
|
||||
<menuitem id="context-marklink"
|
||||
accesskey="&social.marklink.accesskey;"
|
||||
oncommand="gContextMenu.markLink();"/>
|
||||
<menuitem id="context-sharelink"
|
||||
label="&shareLinkCmd.label;"
|
||||
accesskey="&shareLinkCmd.accesskey;"
|
||||
@ -242,9 +239,6 @@
|
||||
label="&bookmarkPageCmd2.label;"
|
||||
accesskey="&bookmarkPageCmd2.accesskey;"
|
||||
oncommand="gContextMenu.bookmarkThisPage();"/>
|
||||
<menuitem id="context-markpage"
|
||||
accesskey="&social.markpage.accesskey;"
|
||||
command="Social:TogglePageMark"/>
|
||||
<menuitem id="context-sharepage"
|
||||
label="&sharePageCmd.label;"
|
||||
accesskey="&sharePageCmd.accesskey;"
|
||||
|
@ -110,7 +110,6 @@
|
||||
<command id="History:UndoCloseTab" oncommand="undoCloseTab();"/>
|
||||
<command id="History:UndoCloseWindow" oncommand="undoCloseWindow();"/>
|
||||
<command id="Browser:ToggleAddonBar" oncommand="toggleAddonBar();"/>
|
||||
<command id="Social:TogglePageMark" oncommand="SocialMark.togglePageMark();" disabled="true"/>
|
||||
<command id="Social:SharePage" oncommand="SocialShare.sharePage();" disabled="true"/>
|
||||
<command id="Social:ToggleSidebar" oncommand="Social.toggleSidebar();" hidden="true"/>
|
||||
<command id="Social:ToggleNotifications" oncommand="Social.toggleNotifications();" hidden="true"/>
|
||||
@ -367,7 +366,7 @@
|
||||
<key id="viewBookmarksSidebarWinKb" key="&bookmarksWinCmd.commandkey;" command="viewBookmarksSidebar" modifiers="accel"/>
|
||||
#endif
|
||||
|
||||
<key id="markPage" key="&markPageCmd.commandkey;" command="Social:TogglePageMark" modifiers="accel,shift"/>
|
||||
<!--<key id="markPage" key="&markPageCmd.commandkey;" command="Social:TogglePageMark" modifiers="accel,shift"/>-->
|
||||
<key id="focusChatBar" key="&social.chatBar.commandkey;" command="Social:FocusChat" modifiers="accel,shift"/>
|
||||
|
||||
<key id="key_stop" keycode="VK_ESCAPE" command="Browser:Stop"/>
|
||||
|
@ -6,7 +6,6 @@
|
||||
let SocialUI,
|
||||
SocialChatBar,
|
||||
SocialFlyout,
|
||||
SocialMark,
|
||||
SocialShare,
|
||||
SocialMenu,
|
||||
SocialToolbar,
|
||||
@ -32,7 +31,6 @@ SocialUI = {
|
||||
init: function SocialUI_init() {
|
||||
Services.obs.addObserver(this, "social:ambient-notification-changed", false);
|
||||
Services.obs.addObserver(this, "social:profile-changed", false);
|
||||
Services.obs.addObserver(this, "social:page-mark-config", false);
|
||||
Services.obs.addObserver(this, "social:frameworker-error", false);
|
||||
Services.obs.addObserver(this, "social:provider-set", false);
|
||||
Services.obs.addObserver(this, "social:providers-changed", false);
|
||||
@ -61,7 +59,6 @@ SocialUI = {
|
||||
uninit: function SocialUI_uninit() {
|
||||
Services.obs.removeObserver(this, "social:ambient-notification-changed");
|
||||
Services.obs.removeObserver(this, "social:profile-changed");
|
||||
Services.obs.removeObserver(this, "social:page-mark-config");
|
||||
Services.obs.removeObserver(this, "social:frameworker-error");
|
||||
Services.obs.removeObserver(this, "social:provider-set");
|
||||
Services.obs.removeObserver(this, "social:providers-changed");
|
||||
@ -116,7 +113,6 @@ SocialUI = {
|
||||
SocialChatBar.update();
|
||||
SocialShare.update();
|
||||
SocialSidebar.update();
|
||||
SocialMark.update();
|
||||
SocialToolbar.update();
|
||||
SocialStatus.populateToolbarPalette();
|
||||
SocialMenu.populate();
|
||||
@ -141,15 +137,9 @@ SocialUI = {
|
||||
case "social:profile-changed":
|
||||
if (this._matchesCurrentProvider(data)) {
|
||||
SocialToolbar.updateProvider();
|
||||
SocialMark.update();
|
||||
SocialChatBar.update();
|
||||
}
|
||||
break;
|
||||
case "social:page-mark-config":
|
||||
if (this._matchesCurrentProvider(data)) {
|
||||
SocialMark.updateMarkState();
|
||||
}
|
||||
break;
|
||||
case "social:frameworker-error":
|
||||
if (this.enabled && Social.provider.origin == data) {
|
||||
SocialSidebar.setSidebarErrorMessage();
|
||||
@ -861,81 +851,6 @@ SocialShare = {
|
||||
}
|
||||
};
|
||||
|
||||
SocialMark = {
|
||||
get button() {
|
||||
return document.getElementById("social-mark-button");
|
||||
},
|
||||
|
||||
canMarkPage: function SSB_canMarkPage(aURI) {
|
||||
// We only allow sharing of http or https
|
||||
return aURI && (aURI.schemeIs('http') || aURI.schemeIs('https'));
|
||||
},
|
||||
|
||||
// Called when the Social.provider changes
|
||||
update: function SSB_updateButtonState() {
|
||||
let markButton = this.button;
|
||||
// always show button if provider supports marks
|
||||
markButton.hidden = !SocialUI.enabled || Social.provider.pageMarkInfo == null;
|
||||
markButton.disabled = markButton.hidden || !this.canMarkPage(gBrowser.currentURI);
|
||||
|
||||
// also update the relevent command's disabled state so the keyboard
|
||||
// shortcut only works when available.
|
||||
let cmd = document.getElementById("Social:TogglePageMark");
|
||||
cmd.setAttribute("disabled", markButton.disabled ? "true" : "false");
|
||||
},
|
||||
|
||||
togglePageMark: function(aCallback) {
|
||||
if (this.button.disabled)
|
||||
return;
|
||||
this.toggleURIMark(gBrowser.currentURI, aCallback)
|
||||
},
|
||||
|
||||
toggleURIMark: function(aURI, aCallback) {
|
||||
let update = function(marked) {
|
||||
this._updateMarkState(marked);
|
||||
if (aCallback)
|
||||
aCallback(marked);
|
||||
}.bind(this);
|
||||
Social.isURIMarked(aURI, function(marked) {
|
||||
if (marked) {
|
||||
Social.unmarkURI(aURI, update);
|
||||
} else {
|
||||
Social.markURI(aURI, update);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
updateMarkState: function SSB_updateMarkState() {
|
||||
this.update();
|
||||
if (!this.button.hidden)
|
||||
Social.isURIMarked(gBrowser.currentURI, this._updateMarkState.bind(this));
|
||||
},
|
||||
|
||||
_updateMarkState: function(currentPageMarked) {
|
||||
// callback for isURIMarked
|
||||
let markButton = this.button;
|
||||
let pageMarkInfo = SocialUI.enabled ? Social.provider.pageMarkInfo : null;
|
||||
|
||||
// Update the mark button, if present
|
||||
if (!markButton || markButton.hidden || !pageMarkInfo)
|
||||
return;
|
||||
|
||||
let imageURL;
|
||||
if (!markButton.disabled && currentPageMarked) {
|
||||
markButton.setAttribute("marked", "true");
|
||||
markButton.setAttribute("label", pageMarkInfo.messages.markedLabel);
|
||||
markButton.setAttribute("tooltiptext", pageMarkInfo.messages.markedTooltip);
|
||||
imageURL = pageMarkInfo.images.marked;
|
||||
} else {
|
||||
markButton.removeAttribute("marked");
|
||||
markButton.setAttribute("label", pageMarkInfo.messages.unmarkedLabel);
|
||||
markButton.setAttribute("tooltiptext", pageMarkInfo.messages.unmarkedTooltip);
|
||||
imageURL = pageMarkInfo.images.unmarked;
|
||||
}
|
||||
markButton.style.listStyleImage = "url(" + imageURL + ")";
|
||||
}
|
||||
};
|
||||
|
||||
SocialMenu = {
|
||||
populate: function SocialMenu_populate() {
|
||||
let submenu = document.getElementById("menu_social-statusarea-popup");
|
||||
@ -1021,13 +936,11 @@ SocialToolbar = {
|
||||
parent.removeChild(frame);
|
||||
}
|
||||
|
||||
let tbi = document.getElementById("social-toolbar-item");
|
||||
let tbi = document.getElementById("social-provider-button");
|
||||
if (tbi) {
|
||||
// SocialMark is the last button allways
|
||||
let next = SocialMark.button.previousSibling;
|
||||
while (next != this.button) {
|
||||
tbi.removeChild(next);
|
||||
next = SocialMark.button.previousSibling;
|
||||
// buttons after social-provider-button are ambient icons
|
||||
while (tbi.nextSibling) {
|
||||
tbi.parentNode.removeChild(tbi.nextSibling);
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -1183,7 +1096,7 @@ SocialToolbar = {
|
||||
toolbarButton.setAttribute("aria-label", ariaLabel);
|
||||
}
|
||||
let socialToolbarItem = document.getElementById("social-toolbar-item");
|
||||
socialToolbarItem.insertBefore(toolbarButtons, SocialMark.button);
|
||||
socialToolbarItem.appendChild(toolbarButtons);
|
||||
|
||||
for (let frame of createdFrames) {
|
||||
if (frame.socialErrorListener)
|
||||
|
@ -3445,7 +3445,6 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) {
|
||||
URLBarSetURI();
|
||||
XULBrowserWindow.asyncUpdateUI();
|
||||
BookmarkingUI.updateStarState();
|
||||
SocialMark.updateMarkState();
|
||||
SocialShare.update();
|
||||
}
|
||||
|
||||
@ -3915,7 +3914,6 @@ var XULBrowserWindow = {
|
||||
// Update starring UI
|
||||
BookmarkingUI.updateStarState();
|
||||
if (SocialUI.enabled) {
|
||||
SocialMark.updateMarkState();
|
||||
SocialShare.update();
|
||||
}
|
||||
}
|
||||
|
@ -744,11 +744,6 @@
|
||||
oncommand="SocialUI.showLearnMore();"/>
|
||||
</menupopup>
|
||||
</toolbarbutton>
|
||||
<toolbarbutton id="social-mark-button"
|
||||
class="toolbarbutton-1"
|
||||
hidden="true"
|
||||
disabled="true"
|
||||
command="Social:TogglePageMark"/>
|
||||
</toolbaritem>
|
||||
|
||||
<hbox id="window-controls" hidden="true" pack="end">
|
||||
|
@ -308,32 +308,6 @@ nsContextMenu.prototype = {
|
||||
this.onTextInput && top.gBidiUI);
|
||||
this.showItem("context-bidi-page-direction-toggle",
|
||||
!this.onTextInput && top.gBidiUI);
|
||||
|
||||
// SocialMarks
|
||||
let marksEnabled = SocialUI.enabled && Social.provider.pageMarkInfo;
|
||||
let enablePageMark = marksEnabled && !(this.isContentSelected ||
|
||||
this.onTextInput || this.onLink || this.onImage ||
|
||||
this.onVideo || this.onAudio || this.onSocial);
|
||||
let enableLinkMark = marksEnabled && ((this.onLink && !this.onMailtoLink &&
|
||||
!this.onSocial) || this.onPlainTextLink);
|
||||
if (enablePageMark) {
|
||||
Social.isURIMarked(gBrowser.currentURI, function(marked) {
|
||||
let label = marked ? "social.unmarkpage.label" : "social.markpage.label";
|
||||
let provider = Social.provider || Social.defaultProvider;
|
||||
let menuLabel = gNavigatorBundle.getFormattedString(label, [provider.name]);
|
||||
this.setItemAttr("context-markpage", "label", menuLabel);
|
||||
}.bind(this));
|
||||
}
|
||||
this.showItem("context-markpage", enablePageMark);
|
||||
if (enableLinkMark) {
|
||||
Social.isURIMarked(this.linkURI, function(marked) {
|
||||
let label = marked ? "social.unmarklink.label" : "social.marklink.label";
|
||||
let provider = Social.provider || Social.defaultProvider;
|
||||
let menuLabel = gNavigatorBundle.getFormattedString(label, [provider.name]);
|
||||
this.setItemAttr("context-marklink", "label", menuLabel);
|
||||
}.bind(this));
|
||||
}
|
||||
this.showItem("context-marklink", enableLinkMark);
|
||||
|
||||
// SocialShare
|
||||
let shareButton = SocialShare.shareButton;
|
||||
@ -1597,12 +1571,6 @@ nsContextMenu.prototype = {
|
||||
}, window.top);
|
||||
}
|
||||
},
|
||||
|
||||
markLink: function CM_markLink() {
|
||||
// send link to social
|
||||
SocialMark.toggleURIMark(this.linkURI);
|
||||
},
|
||||
|
||||
shareLink: function CM_shareLink() {
|
||||
SocialShare.sharePage(null, { url: this.linkURI.spec });
|
||||
},
|
||||
|
@ -12,7 +12,6 @@ MOCHITEST_BROWSER_FILES = \
|
||||
browser_social_activation.js \
|
||||
browser_social_perwindowPB.js \
|
||||
browser_social_toolbar.js \
|
||||
browser_social_markButton.js \
|
||||
browser_social_sidebar.js \
|
||||
browser_social_flyout.js \
|
||||
browser_social_mozSocial_API.js \
|
||||
|
@ -1,187 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
let prefName = "social.enabled",
|
||||
gFinishCB;
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
|
||||
// Need to load a http/https/ftp/ftps page for the social mark button to appear
|
||||
let tab = gBrowser.selectedTab = gBrowser.addTab("https://test1.example.com", {skipAnimation: true});
|
||||
tab.linkedBrowser.addEventListener("load", function tabLoad(event) {
|
||||
tab.linkedBrowser.removeEventListener("load", tabLoad, true);
|
||||
executeSoon(tabLoaded);
|
||||
}, true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
Services.prefs.clearUserPref(prefName);
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
}
|
||||
|
||||
function tabLoaded() {
|
||||
ok(Social, "Social module loaded");
|
||||
|
||||
let manifest = { // normal provider
|
||||
name: "provider 1",
|
||||
origin: "https://example.com",
|
||||
sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",
|
||||
workerURL: "https://example.com/browser/browser/base/content/test/social/social_worker.js",
|
||||
iconURL: "https://example.com/browser/browser/base/content/test/moz.png"
|
||||
};
|
||||
runSocialTestWithProvider(manifest, function (finishcb) {
|
||||
gFinishCB = finishcb;
|
||||
testInitial();
|
||||
});
|
||||
}
|
||||
|
||||
function testInitial(finishcb) {
|
||||
ok(Social.provider, "Social provider is active");
|
||||
ok(Social.provider.enabled, "Social provider is enabled");
|
||||
let port = Social.provider.getWorkerPort();
|
||||
ok(port, "Social provider has a port to its FrameWorker");
|
||||
port.close();
|
||||
|
||||
let markButton = SocialMark.button;
|
||||
ok(markButton, "mark button exists");
|
||||
|
||||
// ensure the worker initialization and handshakes are all done and we
|
||||
// have a profile and the worker has sent a page-mark-config msg.
|
||||
waitForCondition(function() Social.provider.pageMarkInfo != null, function() {
|
||||
is(markButton.hasAttribute("marked"), false, "SocialMark button should not have 'marked' attribute before mark button is clicked");
|
||||
// Check the strings from our worker actually ended up on the button.
|
||||
is(markButton.getAttribute("tooltiptext"), "Mark this page", "check tooltip text is correct");
|
||||
// Check the relative URL was resolved correctly (note this image has offsets of zero...)
|
||||
is(markButton.style.listStyleImage, 'url("https://example.com/browser/browser/base/content/test/social/social_mark_image.png")', "check image url is correct");
|
||||
|
||||
// Test the mark button command handler
|
||||
SocialMark.togglePageMark(function() {
|
||||
is(markButton.hasAttribute("marked"), true, "mark button should have 'marked' attribute after mark button is clicked");
|
||||
is(markButton.getAttribute("tooltiptext"), "Unmark this page", "check tooltip text is correct");
|
||||
// Check the URL and offsets were applied correctly
|
||||
is(markButton.style.listStyleImage, 'url("https://example.com/browser/browser/base/content/test/social/social_mark_image.png")', "check image url is correct");
|
||||
SocialMark.togglePageMark(function() {
|
||||
is(markButton.hasAttribute("marked"), false, "mark button should not be marked");
|
||||
executeSoon(function() {
|
||||
testStillMarkedIn2Tabs();
|
||||
});
|
||||
});
|
||||
});
|
||||
}, "provider didn't provide page-mark-config");
|
||||
}
|
||||
|
||||
function testStillMarkedIn2Tabs() {
|
||||
let toMark = "http://test2.example.com";
|
||||
let markUri = Services.io.newURI(toMark, null, null);
|
||||
let markButton = SocialMark.button;
|
||||
let initialTab = gBrowser.selectedTab;
|
||||
info("initialTab has loaded " + gBrowser.currentURI.spec);
|
||||
is(markButton.hasAttribute("marked"), false, "SocialMark button should not have 'marked' for the initial tab");
|
||||
|
||||
addTab(toMark, function(tab1) {
|
||||
addTab(toMark, function(tab2) {
|
||||
// should start without either page being marked.
|
||||
is(markButton.hasAttribute("marked"), false, "SocialMark button should not have 'marked' before we've done anything");
|
||||
Social.isURIMarked(markUri, function(marked) {
|
||||
ok(!marked, "page is unmarked in annotations");
|
||||
markButton.click();
|
||||
waitForCondition(function() markButton.hasAttribute("marked"), function() {
|
||||
Social.isURIMarked(markUri, function(marked) {
|
||||
ok(marked, "page is marked in annotations");
|
||||
// and switching to the first tab (with the same URL) should still reflect marked.
|
||||
selectBrowserTab(tab1, function() {
|
||||
is(markButton.hasAttribute("marked"), true, "SocialMark button should reflect the marked state");
|
||||
// wait for tabselect
|
||||
selectBrowserTab(initialTab, function() {
|
||||
waitForCondition(function() !markButton.hasAttribute("marked"), function() {
|
||||
gBrowser.selectedTab = tab1;
|
||||
|
||||
SocialMark.togglePageMark(function() {
|
||||
Social.isURIMarked(gBrowser.currentURI, function(marked) {
|
||||
ok(!marked, "page is unmarked in annotations");
|
||||
is(markButton.hasAttribute("marked"), false, "mark button should not be marked");
|
||||
gBrowser.removeTab(tab1);
|
||||
gBrowser.removeTab(tab2);
|
||||
executeSoon(testStillMarkedAfterReopen);
|
||||
});
|
||||
});
|
||||
}, "button has been unmarked");
|
||||
});
|
||||
});
|
||||
});
|
||||
}, "button has been marked");
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testStillMarkedAfterReopen() {
|
||||
let toMark = "http://test2.example.com";
|
||||
let markButton = SocialMark.button;
|
||||
|
||||
is(markButton.hasAttribute("marked"), false, "Reopen: SocialMark button should not have 'marked' for the initial tab");
|
||||
addTab(toMark, function(tab) {
|
||||
SocialMark.togglePageMark(function() {
|
||||
is(markButton.hasAttribute("marked"), true, "SocialMark button should reflect the marked state");
|
||||
gBrowser.removeTab(tab);
|
||||
// should be on the initial unmarked tab now.
|
||||
waitForCondition(function() !markButton.hasAttribute("marked"), function() {
|
||||
// now open the same URL - should be back to Marked.
|
||||
addTab(toMark, function(tab) {
|
||||
is(markButton.hasAttribute("marked"), true, "New tab to previously marked URL should reflect marked state");
|
||||
SocialMark.togglePageMark(function() {
|
||||
gBrowser.removeTab(tab);
|
||||
executeSoon(testOnlyMarkCertainUrlsTabSwitch);
|
||||
});
|
||||
});
|
||||
}, "button is now unmarked");
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testOnlyMarkCertainUrlsTabSwitch() {
|
||||
let toMark = "http://test2.example.com";
|
||||
let notSharable = "about:blank";
|
||||
let markButton = SocialMark.button;
|
||||
addTab(toMark, function(tab) {
|
||||
ok(!markButton.hidden, "SocialMark button not hidden for http url");
|
||||
addTab(notSharable, function(tab2) {
|
||||
ok(markButton.disabled, "SocialMark button disabled for about:blank");
|
||||
selectBrowserTab(tab, function() {
|
||||
ok(!markButton.disabled, "SocialMark button re-shown when switching back to http: url");
|
||||
selectBrowserTab(tab2, function() {
|
||||
ok(markButton.disabled, "SocialMark button re-hidden when switching back to about:blank");
|
||||
gBrowser.removeTab(tab);
|
||||
gBrowser.removeTab(tab2);
|
||||
executeSoon(testOnlyMarkCertainUrlsSameTab);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testOnlyMarkCertainUrlsSameTab() {
|
||||
let toMark = "http://test2.example.com";
|
||||
let notSharable = "about:blank";
|
||||
let markButton = SocialMark.button;
|
||||
addTab(toMark, function(tab) {
|
||||
ok(!markButton.disabled, "SocialMark button not disabled for http url");
|
||||
loadIntoTab(tab, notSharable, function() {
|
||||
ok(markButton.disabled, "SocialMark button disabled for about:blank");
|
||||
loadIntoTab(tab, toMark, function() {
|
||||
ok(!markButton.disabled, "SocialMark button re-enabled http url");
|
||||
gBrowser.removeTab(tab);
|
||||
executeSoon(testDisable);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testDisable() {
|
||||
let markButton = SocialMark.button;
|
||||
Services.prefs.setBoolPref(prefName, false);
|
||||
is(markButton.hidden, true, "SocialMark button should be hidden when pref is disabled");
|
||||
gFinishCB();
|
||||
}
|
@ -35,15 +35,14 @@ var tests = {
|
||||
}
|
||||
|
||||
function triggerIconPanel() {
|
||||
let pButton = document.getElementById("social-provider-button");
|
||||
waitForCondition(function() {
|
||||
let mButton = document.getElementById("social-mark-button");
|
||||
let pButton = document.getElementById("social-provider-button");
|
||||
// wait for a new button to be inserted inbetween the provider and mark
|
||||
// button
|
||||
return pButton.nextSibling != mButton;
|
||||
return !!pButton.nextSibling;
|
||||
}, function() {
|
||||
// Click the button to trigger its contentPanel
|
||||
let statusIcon = document.getElementById("social-provider-button").nextSibling;
|
||||
let statusIcon = pButton.nextSibling;
|
||||
EventUtils.synthesizeMouseAtCenter(statusIcon, {});
|
||||
}, "Status icon didn't become non-hidden");
|
||||
}
|
||||
|
@ -124,12 +124,11 @@ var tests = {
|
||||
let numIcons = Object.keys(Social.provider.ambientNotificationIcons).length;
|
||||
ok(numIcons == 3, "prevent adding more than 3 ambient notification icons");
|
||||
|
||||
let mButton = document.getElementById("social-mark-button");
|
||||
let pButton = document.getElementById("social-provider-button");
|
||||
waitForCondition(function() {
|
||||
// wait for a new button to be inserted inbetween the provider and mark
|
||||
// button
|
||||
return pButton.nextSibling != mButton;
|
||||
return !!pButton.nextSibling;
|
||||
}, function () {
|
||||
let statusIcon = pButton.nextSibling;
|
||||
let badge = statusIcon.getAttribute("badge");
|
||||
|
@ -235,10 +235,6 @@ function checkSocialUI(win) {
|
||||
isbool(win.SocialChatBar.isAvailable, enabled, "chatbar available?");
|
||||
isbool(!win.SocialChatBar.chatbar.hidden, enabled, "chatbar visible?");
|
||||
|
||||
let markVisible = enabled && provider.pageMarkInfo;
|
||||
let canMark = markVisible && win.SocialMark.canMarkPage(win.gBrowser.currentURI);
|
||||
isbool(!win.SocialMark.button.hidden, markVisible, "SocialMark button visible?");
|
||||
isbool(!win.SocialMark.button.disabled, canMark, "SocialMark button enabled?");
|
||||
isbool(!doc.getElementById("social-toolbar-item").hidden, active, "toolbar items visible?");
|
||||
if (active) {
|
||||
if (!enabled) {
|
||||
@ -259,7 +255,6 @@ function checkSocialUI(win) {
|
||||
isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Social:ToggleNotifications visible?");
|
||||
isbool(!doc.getElementById("Social:FocusChat").hidden, enabled, "Social:FocusChat visible?");
|
||||
isbool(doc.getElementById("Social:FocusChat").getAttribute("disabled"), enabled ? "false" : "true", "Social:FocusChat disabled?");
|
||||
_is(doc.getElementById("Social:TogglePageMark").getAttribute("disabled"), canMark ? "false" : "true", "Social:TogglePageMark enabled?");
|
||||
|
||||
// broadcasters.
|
||||
isbool(!doc.getElementById("socialActiveBroadcaster").hidden, active, "socialActiveBroadcaster hidden?");
|
||||
|
@ -100,23 +100,6 @@ onconnect = function(e) {
|
||||
};
|
||||
}
|
||||
port.postMessage({topic: "social.user-profile", data: profile});
|
||||
port.postMessage({
|
||||
topic: "social.page-mark-config",
|
||||
data: {
|
||||
images: {
|
||||
// this one is relative to test we handle relative ones.
|
||||
marked: "/browser/browser/base/content/test/social/social_mark_image.png",
|
||||
// absolute to check we handle them too.
|
||||
unmarked: "https://example.com/browser/browser/base/content/test/social/social_mark_image.png"
|
||||
},
|
||||
messages: {
|
||||
unmarkedTooltip: "Mark this page",
|
||||
markedTooltip: "Unmark this page",
|
||||
unmarkedLabel: "Mark",
|
||||
markedLabel: "Unmark",
|
||||
}
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "test-ambient-notification":
|
||||
apiPort.postMessage({topic: "social.ambient-notification", data: event.data.data});
|
||||
|
@ -645,10 +645,6 @@ just addresses the organization to follow, e.g. "This site is run by " -->
|
||||
<!ENTITY social.chatBar.label "Focus chats">
|
||||
<!ENTITY social.chatBar.accesskey "c">
|
||||
|
||||
<!-- labels are set dynamically, see browser.properties -->
|
||||
<!ENTITY social.markpage.accesskey "m">
|
||||
<!ENTITY social.marklink.accesskey "M">
|
||||
|
||||
<!ENTITY getUserMedia.selectCamera.label "Camera to share:">
|
||||
<!ENTITY getUserMedia.selectCamera.accesskey "C">
|
||||
<!ENTITY getUserMedia.selectMicrophone.label "Microphone to share:">
|
||||
|
@ -429,13 +429,6 @@ social.turnOff.accesskey=T
|
||||
social.turnOn.label=Turn on %S
|
||||
social.turnOn.accesskey=T
|
||||
|
||||
# LOCALIZATION NOTE (social.markpage.label): %S is the name of the social provider
|
||||
social.markpage.label=Send Page to %S
|
||||
social.unmarkpage.label=Remove Page from %S
|
||||
# LOCALIZATION NOTE (social.marklink.label): %S is the name of the social provider
|
||||
social.marklink.label=Send Link to %S
|
||||
social.unmarklink.label=Remove Link from %S
|
||||
|
||||
# LOCALIZATION NOTE (social.error.message): %1$S is brandShortName (e.g. Firefox), %2$S is the name of the social provider
|
||||
social.error.message=%1$S is unable to connect with %2$S right now.
|
||||
social.error.tryAgain.label=Try Again
|
||||
|
@ -797,60 +797,6 @@ SocialProvider.prototype = {
|
||||
// values aren't to be used as the user is logged out'.
|
||||
profile: undefined,
|
||||
|
||||
// Contains the information necessary to support our page mark feature.
|
||||
// null means no info yet provided (which includes the case of the provider
|
||||
// not supporting the feature) or the provided data is invalid. Updated via
|
||||
// the 'pageMarkInfo' setter and returned via the getter.
|
||||
_pageMarkInfo: null,
|
||||
get pageMarkInfo() {
|
||||
return this._pageMarkInfo;
|
||||
},
|
||||
set pageMarkInfo(data) {
|
||||
// Accept *and validate* the page-mark-config message from the provider.
|
||||
let promptImages = {};
|
||||
let promptMessages = {};
|
||||
let self = this;
|
||||
function reportError(reason) {
|
||||
Cu.reportError("Invalid page-mark data from provider: " + reason + ": marking is disabled for this provider");
|
||||
// and we explicitly reset the page-mark data to null to avoid stale
|
||||
// data being used and notify our observers.
|
||||
self._pageMarkInfo = null;
|
||||
Services.obs.notifyObservers(null, "social:page-mark-config", self.origin);
|
||||
}
|
||||
if (!data ||
|
||||
!data.images || typeof data.images != "object" ||
|
||||
!data.messages || typeof data.messages != "object") {
|
||||
reportError("data is missing valid 'images' or 'messages' elements");
|
||||
return;
|
||||
}
|
||||
for (let sub of ["marked", "unmarked"]) {
|
||||
let url = data.images[sub];
|
||||
if (!url || typeof url != "string" || url.length == 0) {
|
||||
reportError('images["' + sub + '"] is not a valid string');
|
||||
return;
|
||||
}
|
||||
// resolve potentially relative URLs but there is no same-origin check
|
||||
// for images to help providers utilize content delivery networks...
|
||||
// Also note no scheme checks are necessary - even a javascript: URL
|
||||
// is safe as gecko evaluates them in a sandbox.
|
||||
let imgUri = this.resolveUri(url);
|
||||
if (!imgUri) {
|
||||
reportError('images["' + sub + '"] is an invalid URL');
|
||||
return;
|
||||
}
|
||||
promptImages[sub] = imgUri.spec;
|
||||
}
|
||||
for (let sub of ["markedTooltip", "unmarkedTooltip", "markedLabel", "unmarkedLabel"]) {
|
||||
if (typeof data.messages[sub] != "string" || data.messages[sub].length == 0) {
|
||||
reportError('messages["' + sub + '"] is not a valid string');
|
||||
return;
|
||||
}
|
||||
promptMessages[sub] = data.messages[sub];
|
||||
}
|
||||
this._pageMarkInfo = {images: promptImages, messages: promptMessages};
|
||||
Services.obs.notifyObservers(null, "social:page-mark-config", this.origin);
|
||||
},
|
||||
|
||||
// Map of objects describing the provider's notification icons, whose
|
||||
// properties include:
|
||||
// name, iconURL, counter, contentPanel
|
||||
|
@ -72,9 +72,6 @@ WorkerAPI.prototype = {
|
||||
"social.ambient-notification": function (data) {
|
||||
this._provider.setAmbientNotification(data);
|
||||
},
|
||||
"social.page-mark-config": function(data) {
|
||||
this._provider.pageMarkInfo = data;
|
||||
},
|
||||
"social.cookies-get": function(data) {
|
||||
// We don't want to trust provider.origin etc, just incase the provider
|
||||
// redirected away or something else bad is going on. So we want to
|
||||
|
Loading…
Reference in New Issue
Block a user