From 94bc4d93816762129208fdb3249fbd308b5a28f1 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Thu, 4 Aug 2016 09:23:54 -0700 Subject: [PATCH] Bug 1289549 P1 socialapi remove status and marks, r=florian MozReview-Commit-ID: 5fT51pp97Tm --- browser/base/content/browser-context.inc | 8 - browser/base/content/browser-sets.inc | 3 +- browser/base/content/browser-social.js | 355 +---------------- browser/base/content/nsContextMenu.js | 26 -- browser/base/content/socialmarks.xml | 366 ------------------ browser/base/content/test/social/browser.ini | 8 - .../test/social/browser_social_contextmenu.js | 74 ---- .../test/social/browser_social_marks.js | 232 ----------- .../social/browser_social_marks_context.js | 106 ----- .../test/social/browser_social_status.js | 216 ----------- browser/base/content/test/social/checked.jpg | Bin 785 -> 0 bytes browser/base/content/test/social/head.js | 38 +- .../content/test/social/social_activate.html | 1 - .../base/content/test/social/social_mark.html | 41 -- .../base/content/test/social/unchecked.jpg | Bin 779 -> 0 bytes browser/base/jar.mn | 1 - .../customizableui/CustomizableWidgets.jsm | 2 +- browser/modules/Social.jsm | 169 +------- toolkit/components/social/SocialService.jsm | 6 +- 19 files changed, 9 insertions(+), 1643 deletions(-) delete mode 100644 browser/base/content/socialmarks.xml delete mode 100644 browser/base/content/test/social/browser_social_contextmenu.js delete mode 100644 browser/base/content/test/social/browser_social_marks.js delete mode 100644 browser/base/content/test/social/browser_social_marks_context.js delete mode 100644 browser/base/content/test/social/browser_social_status.js delete mode 100644 browser/base/content/test/social/checked.jpg delete mode 100644 browser/base/content/test/social/social_mark.html delete mode 100644 browser/base/content/test/social/unchecked.jpg diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index 0c9f2373f016..fa8b3a7ba900 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -93,10 +93,6 @@ label="&saveLinkCmd.label;" accesskey="&saveLinkCmd.accesskey;" oncommand="gContextMenu.saveLink();"/> - - - - - - - + @@ -316,7 +316,6 @@ #endif - 0; }, - canShareOrMarkPage: function(aURI) { + canSharePage: function(aURI) { return (aURI && (aURI.schemeIs('http') || aURI.schemeIs('https'))); }, @@ -228,7 +206,7 @@ SocialUI = { return; // customization mode gets buttons out of sync with command updating, fix // the disabled state - let canShare = this.canShareOrMarkPage(gBrowser.currentURI); + let canShare = this.canSharePage(gBrowser.currentURI); let shareButton = SocialShare.shareButton; if (shareButton) { if (canShare) { @@ -237,24 +215,12 @@ SocialUI = { shareButton.setAttribute("disabled", "true") } } - // update the disabled state of the button based on the command - for (let node of SocialMarks.nodes) { - if (canShare) { - node.removeAttribute("disabled") - } else { - node.setAttribute("disabled", "true") - } - } }, // called on tab/urlbar/location changes and after customization. Update // anything that is tab specific. updateState: function() { - goSetCommandEnabled("Social:PageShareOrMark", this.canShareOrMarkPage(gBrowser.currentURI)); - if (!SocialUI.enabled) - return; - // larger update that may change button icons - SocialMarks.update(); + goSetCommandEnabled("Social:PageShareable", this.canSharePage(gBrowser.currentURI)); } } @@ -646,7 +612,7 @@ SocialShare = { let pageData = graphData ? graphData : this.currentShare; let sharedURI = pageData ? Services.io.newURI(pageData.url, null, null) : gBrowser.currentURI; - if (!SocialUI.canShareOrMarkPage(sharedURI)) + if (!SocialUI.canSharePage(sharedURI)) return; // the point of this action type is that we can use existing share @@ -1097,317 +1063,4 @@ SocialSidebar = { } } -// this helper class is used by removable/customizable buttons to handle -// widget creation/destruction - -// When a provider is installed we show all their UI so the user will see the -// functionality of what they installed. The user can later customize the UI, -// moving buttons around or off the toolbar. -// -// On startup, we create the button widgets of any enabled provider. -// CustomizableUI handles placement and persistence of placement. -function ToolbarHelper(type, createButtonFn, listener) { - this._createButton = createButtonFn; - this._type = type; - - if (listener) { - CustomizableUI.addListener(listener); - // remove this listener on window close - window.addEventListener("unload", () => { - CustomizableUI.removeListener(listener); - }); - } -} - -ToolbarHelper.prototype = { - idFromOrigin: function(origin) { - // this id needs to pass the checks in CustomizableUI, so remove characters - // that wont pass. - return this._type + "-" + Services.io.newURI(origin, null, null).hostPort.replace(/[\.:]/g,'-'); - }, - - // should be called on disable of a provider - removeProviderButton: function(origin) { - CustomizableUI.destroyWidget(this.idFromOrigin(origin)); - }, - - clearPalette: function() { - for (let p of Social.providers) { - this.removeProviderButton(p.origin); - } - }, - - // should be called on enable of a provider - populatePalette: function() { - if (!Social.enabled) { - this.clearPalette(); - return; - } - - // create any buttons that do not exist yet if they have been persisted - // as a part of the UI (otherwise they belong in the palette). - for (let provider of Social.providers) { - let id = this.idFromOrigin(provider.origin); - this._createButton(id, provider); - } - } -} - -var SocialStatusWidgetListener = { - _getNodeOrigin: function(aWidgetId) { - // we rely on the button id being the same as the widget. - let node = document.getElementById(aWidgetId); - if (!node) - return null - if (!node.classList.contains("social-status-button")) - return null - return node.getAttribute("origin"); - }, - onWidgetAdded: function(aWidgetId, aArea, aPosition) { - let origin = this._getNodeOrigin(aWidgetId); - if (origin) - SocialStatus.updateButton(origin); - }, - onWidgetRemoved: function(aWidgetId, aPrevArea) { - let origin = this._getNodeOrigin(aWidgetId); - if (!origin) - return; - // When a widget is demoted to the palette ('removed'), it's visual - // style should change. - SocialStatus.updateButton(origin); - SocialStatus._removeFrame(origin); - } -} - -SocialStatus = { - populateToolbarPalette: function() { - this._toolbarHelper.populatePalette(); - - for (let provider of Social.providers) - this.updateButton(provider.origin); - }, - - removeProvider: function(origin) { - this._removeFrame(origin); - this._toolbarHelper.removeProviderButton(origin); - }, - - reloadProvider: function(origin) { - let button = document.getElementById(this._toolbarHelper.idFromOrigin(origin)); - if (button && button.getAttribute("open") == "true") - document.getElementById("social-notification-panel").hidePopup(); - this._removeFrame(origin); - }, - - _removeFrame: function(origin) { - let notificationFrameId = "social-status-" + origin; - let frame = document.getElementById(notificationFrameId); - if (frame) { - frame.parentNode.removeChild(frame); - } - }, - - get _toolbarHelper() { - delete this._toolbarHelper; - this._toolbarHelper = new ToolbarHelper("social-status-button", - CreateSocialStatusWidget, - SocialStatusWidgetListener); - return this._toolbarHelper; - }, - - updateButton: function(origin) { - let id = this._toolbarHelper.idFromOrigin(origin); - let widget = CustomizableUI.getWidget(id); - if (!widget) - return; - let button = widget.forWindow(window).node; - if (button) { - // we only grab the first notification, ignore all others - let provider = Social._getProviderFromOrigin(origin); - let icons = provider.ambientNotificationIcons; - let iconNames = Object.keys(icons); - let notif = icons[iconNames[0]]; - - // The image and tooltip need to be updated for - // ambient notification changes. - let iconURL = provider.icon32URL || provider.iconURL; - let tooltiptext; - if (!notif || !widget.areaType) { - button.style.listStyleImage = "url(" + iconURL + ")"; - button.setAttribute("badge", ""); - button.setAttribute("aria-label", ""); - button.setAttribute("tooltiptext", provider.name); - return; - } - button.style.listStyleImage = "url(" + (notif.iconURL || iconURL) + ")"; - button.setAttribute("tooltiptext", notif.label || provider.name); - - let badge = notif.counter || ""; - button.setAttribute("badge", badge); - let ariaLabel = notif.label; - // if there is a badge value, we must use a localizable string to insert it. - if (badge) - ariaLabel = gNavigatorBundle.getFormattedString("social.aria.toolbarButtonBadgeText", - [ariaLabel, badge]); - button.setAttribute("aria-label", ariaLabel); - } - }, - - _onclose: function(frame) { - frame.removeEventListener("close", this._onclose, true); - frame.removeEventListener("click", this._onclick, true); - }, - - _onclick: function() { - Services.telemetry.getHistogramById("SOCIAL_PANEL_CLICKS").add(1); - }, - - showPopup: function(aToolbarButton) { - // attach our notification panel if necessary - let origin = aToolbarButton.getAttribute("origin"); - let provider = Social._getProviderFromOrigin(origin); - - PanelFrame.showPopup(window, aToolbarButton, "social", origin, - provider.statusURL, provider.getPageSize("status"), - (frame) => { - frame.addEventListener("close", () => { SocialStatus._onclose(frame) }, true); - frame.addEventListener("click", this._onclick, true); - }); - Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(1); - } -}; - - -var SocialMarksWidgetListener = { - onWidgetAdded: function(aWidgetId, aArea, aPosition) { - let node = document.getElementById(aWidgetId); - if (!node || !node.classList.contains("social-mark-button")) - return; - node._receiveMessage = node.receiveMessage.bind(node); - messageManager.addMessageListener("Social:ErrorPageNotify", node._receiveMessage); - }, - onWidgetBeforeDOMChange: function(aNode, aNextNode, aContainer, isRemoval) { - if (!isRemoval || !aNode || !aNode.classList.contains("social-mark-button")) - return; - messageManager.removeMessageListener("Social:ErrorPageNotify", aNode._receiveMessage); - delete aNode._receiveMessage; - } -} - -/** - * SocialMarks - * - * Handles updates to toolbox and signals all buttons to update when necessary. - */ -SocialMarks = { - get nodes() { - for (let p of Social.providers.filter(p => p.markURL)) { - let widgetId = SocialMarks._toolbarHelper.idFromOrigin(p.origin); - let widget = CustomizableUI.getWidget(widgetId); - if (!widget) - continue; - let node = widget.forWindow(window).node; - if (node) - yield node; - } - }, - update: function() { - // querySelectorAll does not work on the menu panel, so we have to do this - // the hard way. - for (let node of this.nodes) { - // xbl binding is not complete on startup when buttons are not in toolbar, - // verify update is available - if (node.update) { - node.update(); - } - } - }, - - getProviders: function() { - // only rely on providers that the user has placed in the UI somewhere. This - // also means that populateToolbarPalette must be called prior to using this - // method, otherwise you get a big fat zero. For our use case with context - // menu's, this is ok. - return Social.providers.filter(p => p.markURL && - document.getElementById(this._toolbarHelper.idFromOrigin(p.origin))); - }, - - populateContextMenu: function() { - // only show a selection if enabled and there is more than one - let providers = this.getProviders(); - - // remove all previous entries by class - let menus = [...document.getElementsByClassName("context-socialmarks")]; - for (let m of menus) { - m.parentNode.removeChild(m); - } - - let contextMenus = [ - { - type: "link", - id: "context-marklinkMenu", - label: "social.marklinkMenu.label" - }, - { - type: "page", - id: "context-markpageMenu", - label: "social.markpageMenu.label" - } - ]; - for (let cfg of contextMenus) { - this._populateContextPopup(cfg, providers); - } - this.update(); - }, - - MENU_LIMIT: 3, // adjustable for testing - _populateContextPopup: function(menuInfo, providers) { - let menu = document.getElementById(menuInfo.id); - let popup = menu.firstChild; - for (let provider of providers) { - // We show up to MENU_LIMIT providers as single menuitems's at the top - // level of the context menu, if we have more than that, dump them *all* - // into the menu popup. - let mi = document.createElement("menuitem"); - mi.setAttribute("oncommand", "gContextMenu.markLink(this.getAttribute('origin'));"); - mi.setAttribute("origin", provider.origin); - mi.setAttribute("image", provider.iconURL); - if (providers.length <= this.MENU_LIMIT) { - // an extra class to make enable/disable easy - mi.setAttribute("class", "menuitem-iconic context-socialmarks context-mark"+menuInfo.type); - let menuLabel = gNavigatorBundle.getFormattedString(menuInfo.label, [provider.name]); - mi.setAttribute("label", menuLabel); - menu.parentNode.insertBefore(mi, menu); - } else { - mi.setAttribute("class", "menuitem-iconic context-socialmarks"); - mi.setAttribute("label", provider.name); - popup.appendChild(mi); - } - } - }, - - populateToolbarPalette: function() { - this._toolbarHelper.populatePalette(); - this.populateContextMenu(); - }, - - removeProvider: function(origin) { - this._toolbarHelper.removeProviderButton(origin); - }, - - get _toolbarHelper() { - delete this._toolbarHelper; - this._toolbarHelper = new ToolbarHelper("social-mark-button", - CreateSocialMarkWidget, - SocialMarksWidgetListener); - return this._toolbarHelper; - }, - - markLink: function(aOrigin, aUrl, aTarget) { - // find the button for this provider, and open it - let id = this._toolbarHelper.idFromOrigin(aOrigin); - document.getElementById(id).markLink(aUrl, aTarget); - } -}; - })(); diff --git a/browser/base/content/nsContextMenu.js b/browser/base/content/nsContextMenu.js index ffe27a48c8e7..436d38614259 100644 --- a/browser/base/content/nsContextMenu.js +++ b/browser/base/content/nsContextMenu.js @@ -350,28 +350,6 @@ nsContextMenu.prototype = { this.showItem("context-bidi-page-direction-toggle", !this.onTextInput && top.gBidiUI); - // SocialMarks. Marks does not work with text selections, only links. If - // there is more than MENU_LIMIT providers, we show a submenu for them, - // otherwise we have a menuitem per provider (added in SocialMarks class). - let markProviders = SocialMarks.getProviders(); - let enablePageMarks = markProviders.length > 0 && !(this.onLink || this.onImage - || this.onVideo || this.onAudio); - this.showItem("context-markpageMenu", enablePageMarks && markProviders.length > SocialMarks.MENU_LIMIT); - let enablePageMarkItems = enablePageMarks && markProviders.length <= SocialMarks.MENU_LIMIT; - let linkmenus = document.getElementsByClassName("context-markpage"); - for (let m of linkmenus) { - m.hidden = !enablePageMarkItems; - } - - let enableLinkMarks = markProviders.length > 0 && - ((this.onLink && !this.onMailtoLink) || this.onPlainTextLink); - this.showItem("context-marklinkMenu", enableLinkMarks && markProviders.length > SocialMarks.MENU_LIMIT); - let enableLinkMarkItems = enableLinkMarks && markProviders.length <= SocialMarks.MENU_LIMIT; - linkmenus = document.getElementsByClassName("context-marklink"); - for (let m of linkmenus) { - m.hidden = !enableLinkMarkItems; - } - // SocialShare let shareButton = SocialShare.shareButton; let shareEnabled = shareButton && !shareButton.disabled && !this.onSocial; @@ -1732,10 +1710,6 @@ nsContextMenu.prototype = { mm.sendAsyncMessage("ContextMenu:BookmarkFrame", null, { target: this.target }); }, - markLink: function CM_markLink(origin) { - // send link to social, if it is the page url linkURI will be null - SocialMarks.markLink(origin, this.linkURI ? this.linkURI.spec : null, this.target); - }, shareLink: function CM_shareLink() { SocialShare.sharePage(null, { url: this.linkURI.spec }, this.target); }, diff --git a/browser/base/content/socialmarks.xml b/browser/base/content/socialmarks.xml deleted file mode 100644 index 9429662070b3..000000000000 --- a/browser/base/content/socialmarks.xml +++ /dev/null @@ -1,366 +0,0 @@ - - - - - - - - - - - // if we overflow, we have to reset the button. unfortunately we cannot - // use a widget listener because we need to do this *after* the node is - // moved, and the event happens before the node is moved. - this.update(); - - - - let widgetGroup = CustomizableUI.getWidget(this.getAttribute("id")); - return widgetGroup.forWindow(window).anchor; - - - - - let provider = Social._getProviderFromOrigin(this.getAttribute("origin")); - return !provider.getPageSize("marks"); - - - - - - return document.getAnonymousElementByAttribute(this, "anonid", "panel"); - - - - - - - - - - return this.content.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader.messageManager; - - - - - - return this.content.contentWindow; - - - - - - return this.content.contentDocument; - - - - - - return Social._getProviderFromOrigin(this.getAttribute("origin")); - - - - - - - return this._isMarked; - - - - - { - this.isMarked = isMarked; - }); - } - - this.content.setAttribute("origin", provider.origin); - - let panel = this.panel; - // if customization is currently happening, we may not have a panel - // that we can hide - if (panel.hidePopup) { - panel.hidePopup(); - } - this.pageData = null; - ]]> - - - - - - - - - - - { - messageManager.removeMessageListener("PageMetadata:PageDataResult", _dataFn); - this.loadPanel(msg.json, target); - }); - gBrowser.selectedBrowser.messageManager.sendAsyncMessage("PageMetadata:GetPageData", null, { target }); - return; - } - // if this is a share of a selected item, get any microformats - if (!pageData.microformats && target) { - messageManager.addMessageListener("PageMetadata:MicroformatsResult", _dataFn = (msg) => { - messageManager.removeMessageListener("PageMetadata:MicroformatsResult", _dataFn); - pageData.microformats = msg.data; - this.loadPanel(pageData, target); - }); - gBrowser.selectedBrowser.messageManager.sendAsyncMessage("PageMetadata:GetMicroformats", null, { target }); - return; - } - this.pageData = pageData; - - let endpoint = OpenGraphBuilder.generateEndpointURL(URLTemplate, this.pageData); - // setup listeners - let DOMContentLoaded = (event) => { - this._loading = false; - this.messageManager.removeMessageListener("DOMContentLoaded", DOMContentLoaded); - // add our resizer after the dom is ready - if (this._useDynamicResizer) { - let DynamicResizeWatcher = Cu.import("resource:///modules/Social.jsm", {}).DynamicResizeWatcher; - this._dynamicResizer = new DynamicResizeWatcher(); - this._dynamicResizer.start(this.panel, this.content); - } else if (this._dynamicResizer) { - this._dynamicResizer.stop(); - this._dynamicResizer = null; - } - - let contentWindow = this.contentWindow; - let markUpdate = function(event) { - // update the annotation based on this event, then update the - // icon as well - this.isMarked = JSON.parse(event.detail).marked; - if (this.isMarked) { - Social.markURI(provider.origin, gBrowser.currentURI); - } else { - Social.unmarkURI(provider.origin, gBrowser.currentURI, () => { - this.update(); - }); - } - }.bind(this); - let unload = () => { - contentWindow.removeEventListener("unload", unload); - contentWindow.removeEventListener("socialMarkUpdate", markUpdate); - } - contentWindow.addEventListener("socialMarkUpdate", markUpdate); - contentWindow.addEventListener("unload", unload); - - // send the opengraph data - this.messageManager.sendAsyncMessage("Social:OpenGraphData", pageData); - } - this.messageManager.addMessageListener("DOMContentLoaded", DOMContentLoaded); - this._loading = true; - this.content.setAttribute("src", endpoint); - ]]> - - - - - { - panel.openPopup(anchor, "bottomcenter topright", 0, 0, false, false); - }, 0); - Services.telemetry.getHistogramById("SOCIAL_TOOLBAR_BUTTONS").add(2); - ]]> - - - - - - - - - - - - - - - - - - - - { - if (message.target != this.content) - return; - this.messageManager.removeMessageListener("PageVisibility:Show", panelBrowserOnload, true); - sizeSocialPanelToContent(this.panel, this.content); - }; - this.messageManager.addMessageListener("PageVisibility:Show", panelBrowserOnload); - } - ]]> - - - - - - - - - - - - - - - - - diff --git a/browser/base/content/test/social/browser.ini b/browser/base/content/test/social/browser.ini index 855cb1331db1..f68f14b520f5 100644 --- a/browser/base/content/test/social/browser.ini +++ b/browser/base/content/test/social/browser.ini @@ -2,7 +2,6 @@ skip-if = buildapp == "mulet" support-files = blocklist.xml - checked.jpg head.js opengraph/og_invalid_url.html opengraph/opengraph.html @@ -18,12 +17,10 @@ support-files = social_chat.html social_crash_content_helper.js social_flyout.html - social_mark.html social_panel.html social_postActivation.html social_sidebar.html social_sidebar_empty.html - unchecked.jpg !/browser/base/content/test/plugins/blockNoPlugins.xml [browser_aboutHome_activation.js] @@ -34,15 +31,10 @@ support-files = [browser_social_chatwindow.js] [browser_social_chatwindow_resize.js] [browser_social_chatwindowfocus.js] -skip-if = asan # Bug 1260177 -[browser_social_contextmenu.js] skip-if = (os == 'linux' && e10s) # Bug 1072669 context menu relies on target element [browser_social_errorPage.js] [browser_social_flyout.js] [browser_social_isVisible.js] -[browser_social_marks.js] -[browser_social_marks_context.js] [browser_social_multiprovider.js] [browser_social_sidebar.js] -[browser_social_status.js] [browser_social_window.js] diff --git a/browser/base/content/test/social/browser_social_contextmenu.js b/browser/base/content/test/social/browser_social_contextmenu.js deleted file mode 100644 index 6d66d73d2412..000000000000 --- a/browser/base/content/test/social/browser_social_contextmenu.js +++ /dev/null @@ -1,74 +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/. */ - -var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService; - -var manifest = { // used for testing install - name: "provider test1", - origin: "https://test1.example.com", - markURL: "https://test1.example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}", - markedIcon: "https://test1.example.com/browser/browser/base/content/test/social/unchecked.jpg", - unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg", - - iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" -}; - -function test() { - waitForExplicitFinish(); - let frameScript = "data:,(" + function frame_script() { - addEventListener("OpenGraphData", function (aEvent) { - sendAsyncMessage("sharedata", aEvent.detail); - }, true, true); - }.toString() + ")();"; - let mm = getGroupMessageManager("social"); - mm.loadFrameScript(frameScript, true); - - runSocialTestWithProvider(manifest, function (finishcb) { - runSocialTests(tests, undefined, undefined, function () { - mm.removeDelayedFrameScript(frameScript); - finishcb(); - }); - }); -} - -var tests = { - testMarkMicroformats: function(next) { - // emulates context menu action using target element, calling SocialMarks.markLink - let provider = Social._getProviderFromOrigin(manifest.origin); - let target, testTab; - - // browser_share tests microformats on the full page, this is testing a - // specific target element. - let expecting = JSON.stringify({ - "url": "https://example.com/browser/browser/base/content/test/social/microformats.html", - "microformats": { - "items": [{ - "type": ["h-review"], - "properties": { - "rating": ["4.5"] - } - } - ], - "rels": {}, - "rel-urls": {} - } - }); - - let mm = getGroupMessageManager("social"); - mm.addMessageListener("sharedata", function handler(msg) { - is(msg.data, expecting, "microformats data ok"); - mm.removeMessageListener("sharedata", handler); - BrowserTestUtils.removeTab(testTab).then(next); - }); - - let url = "https://example.com/browser/browser/base/content/test/social/microformats.html" - BrowserTestUtils.openNewForegroundTab(gBrowser, url).then(tab => { - testTab = tab; - let doc = tab.linkedBrowser.contentDocument; - target = doc.getElementById("test-review"); - SocialMarks.markLink(manifest.origin, url, target); - }); - } -} diff --git a/browser/base/content/test/social/browser_social_marks.js b/browser/base/content/test/social/browser_social_marks.js deleted file mode 100644 index 081ba51d7815..000000000000 --- a/browser/base/content/test/social/browser_social_marks.js +++ /dev/null @@ -1,232 +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/. */ - -var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService; - -var manifest2 = { // used for testing install - name: "provider test1", - origin: "https://test1.example.com", - markURL: "https://test1.example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}", - markedIcon: "https://test1.example.com/browser/browser/base/content/test/social/unchecked.jpg", - unmarkedIcon: "https://test1.example.com/browser/browser/base/content/test/social/checked.jpg", - - iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" -}; -var manifest3 = { // used for testing install - name: "provider test2", - origin: "https://test2.example.com", - sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html", - iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" -}; - -function test() { - waitForExplicitFinish(); - - let frameScript = "data:,(" + function frame_script() { - addEventListener("visibilitychange", function() { - sendAsyncMessage("visibility", content.document.hidden ? "hidden" : "shown"); - }); - }.toString() + ")();"; - let mm = getGroupMessageManager("social"); - mm.loadFrameScript(frameScript, true); - - PopupNotifications.panel.setAttribute("animate", "false"); - registerCleanupFunction(function () { - PopupNotifications.panel.removeAttribute("animate"); - mm.removeDelayedFrameScript(frameScript); - }); - - runSocialTests(tests, undefined, undefined, finish); -} - -var tests = { - testButtonDisabledOnActivate: function(next) { - // starting on about:blank page, share should be visible but disabled when - // adding provider - is(gBrowser.selectedBrowser.currentURI.spec, "about:blank"); - SocialService.addProvider(manifest2, function(provider) { - is(provider.origin, manifest2.origin, "provider is installed"); - let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id).forWindow(window) - ok(widget.node, "button added to widget set"); - - // bypass widget go directly to dom, check attribute states - let button = document.getElementById(id); - is(button.disabled, true, "mark button is disabled"); - // verify the attribute for proper css - is(button.getAttribute("disabled"), "true", "mark button attribute is disabled"); - // button should be visible - is(button.hidden, false, "mark button is visible"); - - checkSocialUI(window); - SocialService.disableProvider(manifest2.origin, next); - }); - }, - testNoButtonOnEnable: function(next) { - // we expect the addon install dialog to appear, we need to accept the - // install from the dialog. - let panel = document.getElementById("servicesInstall-notification"); - BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => { - info("servicesInstall-notification panel opened"); - panel.button.click(); - }); - - let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html" - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - let doc = tab.linkedBrowser.contentDocument; - let data = { - origin: doc.nodePrincipal.origin, - url: doc.location.href, - manifest: manifest3, - window: window - } - - Social.installProvider(data, function(addonManifest) { - // enable the provider so we know the button would have appeared - SocialService.enableProvider(manifest3.origin, function(provider) { - is(provider.origin, manifest3.origin, "provider is installed"); - let id = SocialMarks._toolbarHelper.idFromOrigin(provider.origin); - let widget = CustomizableUI.getWidget(id); - ok(!widget || !widget.forWindow(window).node, "no button added to widget set"); - Social.uninstallProvider(manifest3.origin, function() { - BrowserTestUtils.removeTab(tab).then(next); - }); - }); - }); - }); - }, - - testButtonOnEnable: function(next) { - let panel = document.getElementById("servicesInstall-notification"); - BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => { - info("servicesInstall-notification panel opened"); - panel.button.click(); - }); - - // enable the provider now - let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html" - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - let doc = tab.linkedBrowser.contentDocument; - let data = { - origin: doc.nodePrincipal.origin, - url: doc.location.href, - manifest: manifest2, - window: window - } - - Social.installProvider(data, function(addonManifest) { - SocialService.enableProvider(manifest2.origin, function(provider) { - is(provider.origin, manifest2.origin, "provider is installed"); - let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id).forWindow(window) - ok(widget.node, "button added to widget set"); - - // bypass widget go directly to dom, check attribute states - let button = document.getElementById(id); - is(button.disabled, false, "mark button is disabled"); - // verify the attribute for proper css - ok(!button.hasAttribute("disabled"), "mark button attribute is disabled"); - // button should be visible - is(button.hidden, false, "mark button is visible"); - - checkSocialUI(window); - BrowserTestUtils.removeTab(tab).then(next); - }); - }); - }); - }, - - testMarkPanel: 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 = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id); - let btn = widget.forWindow(window).node; - ok(btn, "got a mark button"); - let ourTab; - - BrowserTestUtils.waitForEvent(btn.panel, "popupshown").then(() => { - info("marks panel shown"); - let doc = btn.contentDocument; - let unmarkBtn = doc.getElementById("unmark"); - ok(unmarkBtn, "testMarkPanel - got the panel unmark button"); - EventUtils.sendMouseEvent({type: "click"}, unmarkBtn, btn.contentWindow); - }); - - BrowserTestUtils.waitForEvent(btn.panel, "popuphidden").then(() => { - BrowserTestUtils.removeTab(ourTab).then(() => { - ok(btn.disabled, "button is disabled"); - next(); - }); - }); - - // 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" - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - ourTab = tab; - ok(!btn.disabled, "button is enabled"); - // first click marks the page, second click opens the page. We have to - // synthesize so the command event happens - EventUtils.synthesizeMouseAtCenter(btn, {}); - // wait for the button to be marked, click to open panel - is(btn.panel.state, "closed", "panel should not be visible yet"); - BrowserTestUtils.waitForCondition(() => btn.isMarked, "button is marked").then(() => { - EventUtils.synthesizeMouseAtCenter(btn, {}); - }); - }); - }, - - testMarkPanelOffline: 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 = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id); - let btn = widget.forWindow(window).node; - ok(btn, "got a mark button"); - - // 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"; - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - ok(!btn.disabled, "button is enabled"); - goOffline().then(function() { - info("testing offline error page"); - // wait for popupshown - BrowserTestUtils.waitForEvent(btn.panel, "popupshown").then(() => { - info("marks panel is open"); - ensureFrameLoaded(btn.content).then(() => { - is(btn.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly"), 0, "social error page is showing "+btn.contentDocument.documentURI); - // cleanup after the page has been unmarked - BrowserTestUtils.removeTab(tab).then(() => { - ok(btn.disabled, "button is disabled"); - goOnline().then(next); - }); - }); - }); - btn.markCurrentPage(); - }); - }); - }, - - testButtonOnDisable: function(next) { - // enable the provider now - let provider = Social._getProviderFromOrigin(manifest2.origin); - ok(provider, "provider is installed"); - SocialService.disableProvider(manifest2.origin, function() { - let id = SocialMarks._toolbarHelper.idFromOrigin(manifest2.origin); - BrowserTestUtils.waitForCondition(() => { - // getWidget now returns null since we've destroyed the widget - return !CustomizableUI.getWidget(id) - }, "button does not exist after disabling the provider").then(() => { - checkSocialUI(window); - Social.uninstallProvider(manifest2.origin, next); - }); - }); - } -} diff --git a/browser/base/content/test/social/browser_social_marks_context.js b/browser/base/content/test/social/browser_social_marks_context.js deleted file mode 100644 index 06bd242746eb..000000000000 --- a/browser/base/content/test/social/browser_social_marks_context.js +++ /dev/null @@ -1,106 +0,0 @@ -var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService; - -function makeMarkProvider(origin) { - return { // used for testing install - name: "mark provider " + origin, - origin: "https://" + origin + ".example.com", - markURL: "https://" + origin + ".example.com/browser/browser/base/content/test/social/social_mark.html?url=%{url}", - markedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/unchecked.jpg", - unmarkedIcon: "https://" + origin + ".example.com/browser/browser/base/content/test/social/checked.jpg", - iconURL: "https://" + origin + ".example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" - } -} - -function test() { - waitForExplicitFinish(); - PopupNotifications.panel.setAttribute("animate", "false"); - registerCleanupFunction(function () { - PopupNotifications.panel.removeAttribute("animate"); - }); - - runSocialTests(tests, undefined, undefined, finish); -} - -var tests = { - testContextSubmenu: function(next) { - // install 4 providers to test that the menu's are added as submenus - let manifests = [ - makeMarkProvider("sub1.test1"), - makeMarkProvider("sub2.test1"), - makeMarkProvider("sub1.test2"), - makeMarkProvider("sub2.test2") - ]; - let installed = []; - let markLinkMenu = document.getElementById("context-marklinkMenu").firstChild; - let markPageMenu = document.getElementById("context-markpageMenu").firstChild; - - function addProviders(callback) { - let manifest = manifests.pop(); - if (!manifest) { - info("INSTALLATION FINISHED"); - executeSoon(callback); - return; - } - info("INSTALLING " + manifest.origin); - let panel = document.getElementById("servicesInstall-notification"); - BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => { - info("servicesInstall-notification panel opened"); - panel.button.click(); - }); - - let activationURL = manifest.origin + "/browser/browser/base/content/test/social/social_activate.html" - let id = SocialMarks._toolbarHelper.idFromOrigin(manifest.origin); - let toolbar = document.getElementById("nav-bar"); - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - let doc = tab.linkedBrowser.contentDocument; - let data = { - origin: doc.nodePrincipal.origin, - url: doc.location.href, - manifest: manifest, - window: window - } - - Social.installProvider(data, function(addonManifest) { - // enable the provider so we know the button would have appeared - SocialService.enableProvider(manifest.origin, function(provider) { - BrowserTestUtils.waitForCondition(() => { return CustomizableUI.getWidget(id) }, - "button exists after enabling social").then(() => { - BrowserTestUtils.removeTab(tab).then(() => { - installed.push(manifest.origin); - // checkSocialUI will properly check where the menus are located - checkSocialUI(window); - executeSoon(function() { - addProviders(callback); - }); - }); - }); - }); - }); - }); - } - - function removeProviders(callback) { - let origin = installed.pop(); - if (!origin) { - executeSoon(callback); - return; - } - Social.uninstallProvider(origin, function(provider) { - executeSoon(function() { - removeProviders(callback); - }); - }); - } - - addProviders(function() { - removeProviders(function() { - is(SocialMarks.getProviders().length, 0, "mark providers removed"); - is(markLinkMenu.childNodes.length, 0, "marklink menu ok"); - is(markPageMenu.childNodes.length, 0, "markpage menu ok"); - checkSocialUI(window); - next(); - }); - }); - } -} \ No newline at end of file diff --git a/browser/base/content/test/social/browser_social_status.js b/browser/base/content/test/social/browser_social_status.js deleted file mode 100644 index 835bc60cbd9a..000000000000 --- a/browser/base/content/test/social/browser_social_status.js +++ /dev/null @@ -1,216 +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/. */ - -var SocialService = Cu.import("resource://gre/modules/SocialService.jsm", {}).SocialService; - -var manifest = { // builtin provider - name: "provider example.com", - origin: "https://example.com", - sidebarURL: "https://example.com/browser/browser/base/content/test/social/social_sidebar.html", - iconURL: "https://example.com/browser/browser/base/content/test/general/moz.png" -}; -var manifest2 = { // used for testing install - name: "provider test1", - origin: "https://test1.example.com", - statusURL: "https://test1.example.com/browser/browser/base/content/test/social/social_panel.html", - iconURL: "https://test1.example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" -}; -var manifest3 = { // used for testing install - name: "provider test2", - origin: "https://test2.example.com", - sidebarURL: "https://test2.example.com/browser/browser/base/content/test/social/social_sidebar.html", - iconURL: "https://test2.example.com/browser/browser/base/content/test/general/moz.png", - version: "1.0" -}; - - -function openWindowAndWaitForInit(callback) { - let topic = "browser-delayed-startup-finished"; - let w = OpenBrowserWindow(); - Services.obs.addObserver(function providerSet(subject, topic, data) { - Services.obs.removeObserver(providerSet, topic); - executeSoon(() => callback(w)); - }, topic, false); -} - -function test() { - waitForExplicitFinish(); - - let frameScript = "data:,(" + function frame_script() { - addMessageListener("socialTest-sendEvent", function(msg) { - let data = msg.data; - let evt = content.document.createEvent("CustomEvent"); - evt.initCustomEvent(data.name, true, true, JSON.stringify(data.data)); - content.document.documentElement.dispatchEvent(evt); - }); - }.toString() + ")();"; - let mm = getGroupMessageManager("social"); - mm.loadFrameScript(frameScript, true); - - PopupNotifications.panel.setAttribute("animate", "false"); - registerCleanupFunction(function () { - PopupNotifications.panel.removeAttribute("animate"); - mm.removeDelayedFrameScript(frameScript); - }); - - runSocialTestWithProvider(manifest, function (finishcb) { - runSocialTests(tests, undefined, undefined, function () { - Services.prefs.clearUserPref("social.remote-install.enabled"); - // just in case the tests failed, clear these here as well - Services.prefs.clearUserPref("social.whitelist"); - CustomizableUI.reset(); - finishcb(); - }); - }); -} - -var tests = { - testNoButtonOnEnable: function(next) { - // we expect the addon install dialog to appear, we need to accept the - // install from the dialog. - let panel = document.getElementById("servicesInstall-notification"); - BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => { - info("servicesInstall-notification panel opened"); - panel.button.click(); - }) - - let activationURL = manifest3.origin + "/browser/browser/base/content/test/social/social_activate.html" - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - let doc = tab.linkedBrowser.contentDocument; - let data = { - origin: doc.nodePrincipal.origin, - url: doc.location.href, - manifest: manifest3, - window: window - } - Social.installProvider(data, function(addonManifest) { - // enable the provider so we know the button would have appeared - SocialService.enableProvider(manifest3.origin, function(provider) { - is(provider.origin, manifest3.origin, "provider is installed"); - let id = SocialStatus._toolbarHelper.idFromOrigin(provider.origin); - let widget = CustomizableUI.getWidget(id); - ok(!widget || !widget.forWindow(window).node, "no button added to widget set"); - Social.uninstallProvider(manifest3.origin, function() { - BrowserTestUtils.removeTab(tab).then(next); - }); - }); - }); - }); - }, - testButtonOnEnable: function(next) { - let panel = document.getElementById("servicesInstall-notification"); - BrowserTestUtils.waitForEvent(PopupNotifications.panel, "popupshown").then(() => { - info("servicesInstall-notification panel opened"); - panel.button.click(); - }); - - // enable the provider now - let activationURL = manifest2.origin + "/browser/browser/base/content/test/social/social_activate.html" - BrowserTestUtils.openNewForegroundTab(gBrowser, activationURL).then(tab => { - let doc = tab.linkedBrowser.contentDocument; - let data = { - origin: doc.nodePrincipal.origin, - url: doc.location.href, - manifest: manifest2, - window: window - } - - Social.installProvider(data, function(addonManifest) { - SocialService.enableProvider(manifest2.origin, function(provider) { - is(provider.origin, manifest2.origin, "provider is installed"); - let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id).forWindow(window); - ok(widget.node, "button added to widget set"); - checkSocialUI(window); - BrowserTestUtils.removeTab(tab).then(next); - }); - }); - }); - }, - testStatusPanel: function(next) { - let icon = { - name: "testIcon", - iconURL: "chrome://browser/skin/Info.png", - counter: 1 - }; - - // click on panel to open and wait for visibility - let provider = Social._getProviderFromOrigin(manifest2.origin); - let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id); - let btn = widget.forWindow(window).node; - - // Disable the transition - let panel = document.getElementById("social-notification-panel"); - panel.setAttribute("animate", "false"); - BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => { - ensureFrameLoaded(panel.firstChild).then(() => { - let mm = panel.firstChild.messageManager; - mm.sendAsyncMessage("socialTest-sendEvent", { name: "Social:Notification", data: icon }); - BrowserTestUtils.waitForCondition( - () => { return btn.getAttribute("badge"); }, "button updated by notification").then(() => { - is(btn.style.listStyleImage, "url(\"" + icon.iconURL + "\")", "notification icon updated"); - panel.hidePopup(); - }); - }); - }); - BrowserTestUtils.waitForEvent(panel, "popuphidden").then(() => { - panel.removeAttribute("animate"); - next(); - }); - btn.click(); // open the panel - }, - - testPanelOffline: 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 = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin); - let widget = CustomizableUI.getWidget(id); - let btn = widget.forWindow(window).node; - ok(btn, "got a status button"); - let frameId = btn.getAttribute("notificationFrameId"); - let frame = document.getElementById(frameId); - - goOffline().then(function() { - info("testing offline error page"); - // wait for popupshown - let panel = document.getElementById("social-notification-panel"); - BrowserTestUtils.waitForEvent(panel, "popupshown").then(() => { - ensureFrameLoaded(frame).then(() => { - is(frame.contentDocument.documentURI.indexOf("about:socialerror?mode=tryAgainOnly"), 0, "social error page is showing "+frame.contentDocument.documentURI); - // We got our error page, reset to avoid test leak. - BrowserTestUtils.waitForEvent(frame, "load", true).then(() => { - is(frame.contentDocument.documentURI, "about:blank", "closing error panel"); - BrowserTestUtils.waitForEvent(panel, "popuphidden").then(next); - panel.hidePopup(); - }); - goOnline().then(() => { - info("resetting error panel"); - frame.setAttribute("src", "about:blank"); - }); - }); - }); - // reload after going offline, wait for unload to open panel - BrowserTestUtils.waitForEvent(frame, "unload", true).then(() => { - btn.click(); - }); - frame.contentDocument.location.reload(); - }); - }, - - testButtonOnDisable: function(next) { - // enable the provider now - let provider = Social._getProviderFromOrigin(manifest2.origin); - ok(provider, "provider is installed"); - SocialService.disableProvider(manifest2.origin, function() { - let id = SocialStatus._toolbarHelper.idFromOrigin(manifest2.origin); - BrowserTestUtils.waitForCondition(() => { return !document.getElementById(id) }, - "button does not exist after disabling the provider").then(() => { - Social.uninstallProvider(manifest2.origin, next); - }); - }); - } -} diff --git a/browser/base/content/test/social/checked.jpg b/browser/base/content/test/social/checked.jpg deleted file mode 100644 index 4cbbe18e6125b6591a6a5eb38b036e38b97b235a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 785 zcmV+s1Md8ZP)T)V`; z@ckRZ^-BvFRDz=zUcdbe(z^ph00a<=;QwFJOuv}fB<6R`S)M^|L|BcNUeogIRcpKyM|I+$37dS1glimmkFD}})gW=zwzYMS5d<5y+4Kn~B zfLOK&$X(K!+@vG^?F;8Wpujsuj^CH~#mOBKAAHV@X05Or0^WMD&r@*7gVgLa|tO3(EZadC!`|i`}AU3iDK!5=N56SIJ3p?Tv P00000NkvXXu0mjf%wuI) diff --git a/browser/base/content/test/social/head.js b/browser/base/content/test/social/head.js index d7afa16ed22f..7ff2a108199b 100644 --- a/browser/base/content/test/social/head.js +++ b/browser/base/content/test/social/head.js @@ -66,7 +66,7 @@ function runSocialTestWithProvider(manifest, callback, finishcallback) { SessionStore.setWindowValue(window, "socialSidebar", ""); for (let i = 0; i < manifests.length; i++) { let m = manifests[i]; - for (let what of ['sidebarURL', 'iconURL', 'shareURL', 'markURL']) { + for (let what of ['sidebarURL', 'iconURL', 'shareURL']) { if (m[what]) { yield promiseSocialUrlNotRemembered(m[what]); } @@ -232,42 +232,6 @@ function checkSocialUI(win) { } isbool(win.SocialSidebar.canShow, sidebarEnabled, "social sidebar active?"); - let contextMenus = [ - { - type: "link", - id: "context-marklinkMenu", - label: "social.marklinkMenu.label" - }, - { - type: "page", - id: "context-markpageMenu", - label: "social.markpageMenu.label" - } - ]; - - for (let c of contextMenus) { - let leMenu = document.getElementById(c.id); - let parent, menus; - let markProviders = SocialMarks.getProviders(); - if (markProviders.length > SocialMarks.MENU_LIMIT) { - // menus should be in a submenu, not in the top level of the context menu - parent = leMenu.firstChild; - menus = document.getElementsByClassName("context-mark" + c.type); - _is(menus.length, 0, "menu's are not in main context menu\n"); - menus = parent.childNodes; - _is(menus.length, markProviders.length, c.id + " menu exists for each mark provider"); - } else { - // menus should be in the top level of the context menu, not in a submenu - parent = leMenu.parentNode; - menus = document.getElementsByClassName("context-mark" + c.type); - _is(menus.length, markProviders.length, c.id + " menu exists for each mark provider"); - menus = leMenu.firstChild.childNodes; - _is(menus.length, 0, "menu's are not in context submenu\n"); - } - for (let m of menus) - _is(m.parentNode, parent, "menu has correct parent"); - } - // and for good measure, check all the social commands. isbool(!doc.getElementById("Social:ToggleSidebar").hidden, sidebarEnabled, "Social:ToggleSidebar visible?"); isbool(!doc.getElementById("Social:ToggleNotifications").hidden, enabled, "Social:ToggleNotifications visible?"); diff --git a/browser/base/content/test/social/social_activate.html b/browser/base/content/test/social/social_activate.html index b0ff0225f58b..6229d5feced2 100644 --- a/browser/base/content/test/social/social_activate.html +++ b/browser/base/content/test/social/social_activate.html @@ -14,7 +14,6 @@ var data = { // at least one of these must be defined "sidebarURL": "/browser/browser/base/content/test/social/social_sidebar.html", - "statusURL": "/browser/browser/base/content/test/social/social_panel.html", "postActivationURL": "/browser/browser/base/content/test/social/social_postActivation.html", // should be available for display purposes diff --git a/browser/base/content/test/social/social_mark.html b/browser/base/content/test/social/social_mark.html deleted file mode 100644 index 88c7ad05a213..000000000000 --- a/browser/base/content/test/social/social_mark.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - Demo Mark Window - - - - -
-

This window shows the mark data

-
Page Marked:
- - -
- - diff --git a/browser/base/content/test/social/unchecked.jpg b/browser/base/content/test/social/unchecked.jpg deleted file mode 100644 index 4d3e72b8018ea0be59ca08a45c2ab7c1b6dcd73c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 779 zcmV+m1N8ifP)JNRCwBA z{Qv(y10?_;fLL%z*k!g$ed1M`{)1n};NP$R|JlC2xElMZ^Tq$qFOz`MTYz|a#qvkn z00M{s4JiySk906PN%6Eg$DG&^R7pQleUJU{x3 z;pMv@AV;nT5dZxr! z4v0b0Krj7yagAS0OoZXZ?UNvVS78PK1Q5#?E;(IpRz~iFFBlkp0{v?&!oZ*cbh;QP z1H*yGfB$X0_wDCTMt0T&?td%{9~c;3zWD+VKo9^3Ag2EuJmSCp{$~zWWMGI?Vqh>6 z{m;;I_7{WC^0)uj9J+MDT81-8_}81ot=ZWO|Ni`Cc=hHZNZ)Rl0RRESBKK^|rKXiy zI$t=&IT`-{W8nDr?zh;7OJ_g#gjz8$2!j=MbXdH$@e@mAVqs=@`|cAc01v?o00ETTZHj-D{xL`4O#rdWUgVj?oh`%8)oVwC_0AYu(r=i%mLc=75z12iAN z0YCsTk&^S?y$7ejqsU?a0Yt0;(>HEA&T#wg)9D~KvIIbY0RX^P>0zF&!}|aL002ov JPDHLkV1h 0) { - PlacesUtils.annotations.setPageAnnotation( - aURI, "social/mark", JSON.stringify(providerList), 0, - PlacesUtils.annotations.EXPIRE_WITH_HISTORY); - } else { - PlacesUtils.annotations.removePageAnnotation(aURI, "social/mark"); - } - } catch(e) { - Cu.reportError("SocialAnnotation failed: " + e); - } - deferred.resolve(); - }, Ci.nsIThread.DISPATCH_NORMAL); - - return deferred.promise; -} - -function promiseGetAnnotation(aURI) { - let deferred = Promise.defer(); - - // Delaying to catch issues with asynchronous behavior while waiting - // to implement asynchronous annotations in bug 699844. - Services.tm.mainThread.dispatch(function() { - let val = null; - try { - val = PlacesUtils.annotations.getPageAnnotation(aURI, "social/mark"); - } catch (ex) { } - - deferred.resolve(val); - }, Ci.nsIThread.DISPATCH_NORMAL); - - return deferred.promise; -} - this.Social = { initialized: false, lastEventReceived: 0, @@ -180,65 +139,6 @@ this.Social = { // It's OK if the provider has already been activated - we still get called // back with it. SocialService.enableProvider(origin, callback); - }, - - // Page Marking functionality - isURIMarked: function(origin, aURI, aCallback) { - promiseGetAnnotation(aURI).then(function(val) { - if (val) { - let providerList = JSON.parse(val); - val = providerList.indexOf(origin) >= 0; - } - aCallback(!!val); - }).then(null, Cu.reportError); - }, - - markURI: function(origin, aURI, aCallback) { - // update or set our annotation - promiseGetAnnotation(aURI).then(function(val) { - - let providerList = val ? JSON.parse(val) : []; - let marked = providerList.indexOf(origin) >= 0; - if (marked) - return; - providerList.push(origin); - // we allow marking links in a page that may not have been visited yet. - // make sure there is a history entry for the uri, then annotate it. - let place = { - uri: aURI, - visits: [{ - visitDate: Date.now() + 1000, - transitionType: Ci.nsINavHistoryService.TRANSITION_LINK - }] - }; - PlacesUtils.asyncHistory.updatePlaces(place, { - handleError: () => Cu.reportError("couldn't update history for socialmark annotation"), - handleResult: function () {}, - handleCompletion: function () { - promiseSetAnnotation(aURI, providerList).then(function() { - if (aCallback) - schedule(function() { aCallback(true); } ); - }).then(null, Cu.reportError); - } - }); - }).then(null, Cu.reportError); - }, - - unmarkURI: function(origin, aURI, aCallback) { - // this should not be called if this.provider or the port is null - // set our annotation - promiseGetAnnotation(aURI).then(function(val) { - let providerList = val ? JSON.parse(val) : []; - let marked = providerList.indexOf(origin) >= 0; - if (marked) { - // remove the annotation - providerList.splice(providerList.indexOf(origin), 1); - promiseSetAnnotation(aURI, providerList).then(function() { - if (aCallback) - schedule(function() { aCallback(false); } ); - }).then(null, Cu.reportError); - } - }).then(null, Cu.reportError); } }; @@ -246,73 +146,6 @@ function schedule(callback) { Services.tm.mainThread.dispatch(callback, Ci.nsIThread.DISPATCH_NORMAL); } -function CreateSocialStatusWidget(aId, aProvider) { - if (!aProvider.statusURL) - return; - let widget = CustomizableUI.getWidget(aId); - // The widget is only null if we've created then destroyed the widget. - // Once we've actually called createWidget the provider will be set to - // PROVIDER_API. - if (widget && widget.provider == CustomizableUI.PROVIDER_API) - return; - - CustomizableUI.createWidget({ - id: aId, - type: "custom", - removable: true, - defaultArea: CustomizableUI.AREA_NAVBAR, - onBuild: function(aDocument) { - let node = aDocument.createElement("toolbarbutton"); - node.id = this.id; - node.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional social-status-button badged-button"); - node.style.listStyleImage = "url(" + (aProvider.icon32URL || aProvider.iconURL) + ")"; - node.setAttribute("origin", aProvider.origin); - node.setAttribute("label", aProvider.name); - node.setAttribute("tooltiptext", aProvider.name); - node.setAttribute("oncommand", "SocialStatus.showPopup(this);"); - node.setAttribute("constrain-size", "true"); - - return node; - } - }); -} - -function CreateSocialMarkWidget(aId, aProvider) { - if (!aProvider.markURL) - return; - let widget = CustomizableUI.getWidget(aId); - // The widget is only null if we've created then destroyed the widget. - // Once we've actually called createWidget the provider will be set to - // PROVIDER_API. - if (widget && widget.provider == CustomizableUI.PROVIDER_API) - return; - - CustomizableUI.createWidget({ - id: aId, - type: "custom", - removable: true, - defaultArea: CustomizableUI.AREA_NAVBAR, - onBuild: function(aDocument) { - let node = aDocument.createElement("toolbarbutton"); - node.id = this.id; - node.setAttribute("class", "toolbarbutton-1 chromeclass-toolbar-additional social-mark-button"); - node.setAttribute("type", "socialmark"); - node.setAttribute("constrain-size", "true"); - node.style.listStyleImage = "url(" + (aProvider.unmarkedIcon || aProvider.icon32URL || aProvider.iconURL) + ")"; - node.setAttribute("origin", aProvider.origin); - - let window = aDocument.defaultView; - let menuLabel = window.gNavigatorBundle.getFormattedString("social.markpageMenu.label", [aProvider.name]); - node.setAttribute("label", menuLabel); - node.setAttribute("tooltiptext", menuLabel); - node.setAttribute("observes", "Social:PageShareOrMark"); - - return node; - } - }); -} - - function sizeSocialPanelToContent(panel, iframe, requestedSize) { let doc = iframe.contentDocument; if (!doc || !doc.body) { diff --git a/toolkit/components/social/SocialService.jsm b/toolkit/components/social/SocialService.jsm index d4e707bf3a1c..707a3f393665 100644 --- a/toolkit/components/social/SocialService.jsm +++ b/toolkit/components/social/SocialService.jsm @@ -503,7 +503,7 @@ this.SocialService = { }, _manifestFromData: function(type, data, installOrigin) { - let featureURLs = ['sidebarURL', 'shareURL', 'statusURL', 'markURL']; + let featureURLs = ['sidebarURL', 'shareURL']; let resolveURLs = featureURLs.concat(['postActivationURL']); if (type == 'directory' || type == 'internal') { @@ -706,10 +706,6 @@ function SocialProvider(input) { this.icon64URL = input.icon64URL; this.sidebarURL = input.sidebarURL; this.shareURL = input.shareURL; - this.statusURL = input.statusURL; - this.markURL = input.markURL; - this.markedIcon = input.markedIcon; - this.unmarkedIcon = input.unmarkedIcon; this.postActivationURL = input.postActivationURL; this.origin = input.origin; let originUri = Services.io.newURI(input.origin, null, null);