Backed out changeset 46231d51ba66 (bug 677372)

This commit is contained in:
Carsten "Tomcat" Book 2016-07-14 14:12:30 +02:00
parent fb7cf735a1
commit 1f0b20817c
13 changed files with 15 additions and 270 deletions

View File

@ -1106,12 +1106,6 @@ pref("services.sync.prefs.sync.xpinstall.whitelist.required", true);
// user's tabs and bookmarks. Note this pref is also synced.
pref("services.sync.syncedTabs.showRemoteIcons", true);
#ifdef NIGHTLY_BUILD
pref("services.sync.sendTabToDevice.enabled", true);
#else
pref("services.sync.sendTabToDevice.enabled", false);
#endif
// Developer edition preferences
#ifdef MOZ_DEV_EDITION
sticky_pref("lightweightThemes.selectedThemeID", "firefox-devedition@mozilla.org");

View File

@ -283,14 +283,6 @@
label="&savePageCmd.label;"
accesskey="&savePageCmd.accesskey2;"
oncommand="gContextMenu.savePageAs();"/>
<menuseparator id="context-sep-sendpagetodevice" hidden="true"/>
<menu id="context-sendpagetodevice"
label="&sendPageToDevice.label;"
accesskey="&sendPageToDevice.accesskey;"
hidden="true">
<menupopup id="context-sendpagetodevice-popup"
onpopupshowing="gFxAccounts.populateSendTabToDevicesMenu(event.target, gBrowser.currentURI.spec, gBrowser.contentTitle);"/>
</menu>
<menu id="context-markpageMenu" label="&social.markpageMenu.label;"
accesskey="&social.markpageMenu.accesskey;">
<menupopup/>
@ -334,14 +326,6 @@
oncommand="AddKeywordForSearchField();"/>
<menuitem id="context-searchselect"
oncommand="BrowserSearch.loadSearchFromContext(this.searchTerms);"/>
<menuseparator id="context-sep-sendlinktodevice" hidden="true"/>
<menu id="context-sendlinktodevice"
label="&sendLinkToDevice.label;"
accesskey="&sendLinkToDevice.accesskey;"
hidden="true">
<menupopup id="context-sendlinktodevice-popup"
onpopupshowing="gFxAccounts.populateSendTabToDevicesMenu(event.target, gContextMenu.linkURL, gContextMenu.linkTextStr);"/>
</menu>
<menuitem id="context-shareselect"
label="&shareSelect.label;"
accesskey="&shareSelect.accesskey;"

View File

@ -78,15 +78,6 @@ var gFxAccounts = {
return Weave.Status.login == Weave.LOGIN_FAILED_LOGIN_REJECTED;
},
get sendTabToDeviceEnabled() {
return Services.prefs.getBoolPref("services.sync.sendTabToDevice.enabled");
},
get remoteClients() {
return Weave.Service.clientsEngine.remoteClients
.sort((a, b) => a.name.localeCompare(b.name));
},
init: function () {
// Bail out if we're already initialized and for pop-up windows.
if (this._initialized || !window.toolbar.visible) {
@ -370,81 +361,6 @@ var gFxAccounts = {
openSignInAgainPage: function (entryPoint) {
this.openAccountsPage("reauth", { entrypoint: entryPoint });
},
sendTabToDevice: function (url, clientId, title) {
Weave.Service.clientsEngine.sendURIToClientForDisplay(url, clientId, title);
},
populateSendTabToDevicesMenu: function (devicesPopup, url, title) {
// remove existing menu items
while (devicesPopup.hasChildNodes()) {
devicesPopup.removeChild(devicesPopup.firstChild);
}
const fragment = document.createDocumentFragment();
const onTargetDeviceCommand = (event) => {
const clientId = event.target.getAttribute("clientId");
const clients = clientId
? [clientId]
: this.remoteClients.map(client => client.id);
clients.forEach(clientId => this.sendTabToDevice(url, clientId, title));
}
function addTargetDevice(clientId, name) {
const targetDevice = document.createElement("menuitem");
targetDevice.addEventListener("command", onTargetDeviceCommand, true);
targetDevice.setAttribute("class", "sendtab-target");
targetDevice.setAttribute("clientId", clientId);
targetDevice.setAttribute("label", name);
fragment.appendChild(targetDevice);
}
const clients = this.remoteClients;
for (let client of clients) {
addTargetDevice(client.id, client.name);
}
// "All devices" menu item
const separator = document.createElement("menuseparator");
fragment.appendChild(separator);
const allDevicesLabel = this.strings.GetStringFromName("sendTabToAllDevices.menuitem");
addTargetDevice("", allDevicesLabel);
devicesPopup.appendChild(fragment);
},
updateTabContextMenu: function (aPopupMenu) {
if (!this.sendTabToDeviceEnabled) {
return;
}
const remoteClientPresent = this.remoteClients.length > 0;
["context_sendTabToDevice", "context_sendTabToDevice_separator"]
.forEach(id => { document.getElementById(id).hidden = !remoteClientPresent });
},
initPageContextMenu: function (contextMenu) {
if (!this.sendTabToDeviceEnabled) {
return;
}
const remoteClientPresent = this.remoteClients.length > 0;
// showSendLink and showSendPage are mutually exclusive
const showSendLink = remoteClientPresent
&& (contextMenu.onSaveableLink || contextMenu.onPlainTextLink);
const showSendPage = !showSendLink && remoteClientPresent
&& !(contextMenu.isContentSelected ||
contextMenu.onImage || contextMenu.onCanvas ||
contextMenu.onVideo || contextMenu.onAudio ||
contextMenu.onLink || contextMenu.onTextInput);
["context-sendpagetodevice", "context-sep-sendpagetodevice"]
.forEach(id => contextMenu.showItem(id, showSendPage));
["context-sendlinktodevice", "context-sep-sendlinktodevice"]
.forEach(id => contextMenu.showItem(id, showSendLink));
}
};
XPCOMUtils.defineLazyGetter(gFxAccounts, "FxAccountsCommon", function () {

View File

@ -7621,8 +7621,6 @@ var TabContextMenu = {
this.contextTab.addEventListener("TabAttrModified", this, false);
aPopupMenu.addEventListener("popuphiding", this, false);
gFxAccounts.updateTabContextMenu(aPopupMenu);
},
handleEvent(aEvent) {
switch (aEvent.type) {

View File

@ -104,12 +104,6 @@
hidden="true"
oncommand="gBrowser.openNonRemoteWindow(TabContextMenu.contextTab);"/>
#endif
<menuseparator id="context_sendTabToDevice_separator" hidden="true"/>
<menu id="context_sendTabToDevice" label="&sendTabToDevice.label;"
accesskey="&sendTabToDevice.accesskey;" hidden="true">
<menupopup id="context_sendTabToDevicePopupMenu"
onpopupshowing="gFxAccounts.populateSendTabToDevicesMenu(event.target, TabContextMenu.contextTab.linkedBrowser.currentURI.spec, TabContextMenu.contextTab.linkedBrowser.contentTitle);"/>
</menu>
<menuseparator/>
<menuitem id="context_reloadAllTabs" label="&reloadAllTabs.label;" accesskey="&reloadAllTabs.accesskey;"
tbattr="tabbrowser-multiple-visible"

View File

@ -117,7 +117,6 @@ nsContextMenu.prototype = {
this.initLeaveDOMFullScreenItems();
this.initClickToPlayItems();
this.initPasswordManagerItems();
this.initSyncItems();
},
initPageMenuSeparator: function CM_initPageMenuSeparator() {
@ -577,10 +576,6 @@ nsContextMenu.prototype = {
popup.insertBefore(fragment, insertBeforeElement);
},
initSyncItems: function() {
gFxAccounts.initPageContextMenu(this);
},
openPasswordManager: function() {
LoginHelper.openPasswordManager(window, gContextMenuContentData.documentURIObject.host);
},

View File

@ -852,80 +852,6 @@ add_task(function* test_input_spell_false() {
);
});
const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ];
add_task(function* test_plaintext_sendpagetodevice() {
if (!gFxAccounts.sendTabToDeviceEnabled) {
return;
}
const oldGetter = setupRemoteClientsFixture(remoteClientsFixture);
let plainTextItems = ["context-navigation", null,
["context-back", false,
"context-forward", false,
"context-reload", true,
"context-bookmarkpage", true], null,
"---", null,
"context-savepage", true,
...(hasPocket ? ["context-pocket", true] : []),
"---", null,
"context-sendpagetodevice", true,
["*Foo", true,
"*Bar", true,
"---", null,
"*All Devices", true], null,
"---", null,
"context-viewbgimage", false,
"context-selectall", true,
"---", null,
"context-viewsource", true,
"context-viewinfo", true
];
yield test_contextmenu("#test-text", plainTextItems, {
onContextMenuShown() {
yield openMenuItemSubmenu("context-sendpagetodevice");
}
});
restoreRemoteClients(oldGetter);
});
add_task(function* test_link_sendlinktodevice() {
if (!gFxAccounts.sendTabToDeviceEnabled) {
return;
}
const oldGetter = setupRemoteClientsFixture(remoteClientsFixture);
yield test_contextmenu("#test-link",
["context-openlinkintab", true,
...(hasContainers ? ["context-openlinkinusercontext-menu", true] : []),
// We need a blank entry here because the containers submenu is
// dynamically generated with no ids.
...(hasContainers ? ["", null] : []),
"context-openlink", true,
"context-openlinkprivate", true,
"---", null,
"context-bookmarklink", true,
"context-savelink", true,
...(hasPocket ? ["context-savelinktopocket", true] : []),
"context-copylink", true,
"context-searchselect", true,
"---", null,
"context-sendlinktodevice", true,
["*Foo", true,
"*Bar", true,
"---", null,
"*All Devices", true], null,
],
{
onContextMenuShown() {
yield openMenuItemSubmenu("context-sendlinktodevice");
}
});
restoreRemoteClients(oldGetter);
});
add_task(function* test_cleanup() {
gBrowser.removeCurrentTab();
});

View File

@ -2,8 +2,6 @@
* 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/. */
const remoteClientsFixture = [ { id: 1, name: "Foo"}, { id: 2, name: "Bar"} ];
add_task(function* test() {
// There should be one tab when we start the test
let [origTab] = gBrowser.visibleTabs;
@ -16,21 +14,6 @@ add_task(function* test() {
is(document.getElementById("context_closeTab").disabled, false, "Close Tab is enabled");
is(document.getElementById("context_reloadAllTabs").disabled, false, "Reload All Tabs is enabled");
if (gFxAccounts.sendTabToDeviceEnabled) {
// Check the send tab to device menu item
const oldGetter = setupRemoteClientsFixture(remoteClientsFixture);
yield updateTabContextMenu(origTab, function* () {
yield openMenuItemSubmenu("context_sendTabToDevice");
});
is(document.getElementById("context_sendTabToDevice").hidden, false, "Send tab to device is shown");
let targets = document.getElementById("context_sendTabToDevicePopupMenu").childNodes;
is(targets[0].getAttribute("label"), "Foo", "Foo target is present");
is(targets[1].getAttribute("label"), "Bar", "Bar target is present");
is(targets[3].getAttribute("label"), "All Devices", "All Devices target is present");
restoreRemoteClients(oldGetter);
}
// Hide the original tab.
gBrowser.selectedTab = testTab;
gBrowser.showOnlyTheseTabs([testTab]);

View File

@ -41,24 +41,23 @@ function getVisibleMenuItems(aMenu, aData) {
if (key)
key = key.toLowerCase();
var isPageMenuItem = item.hasAttribute("generateditemid");
var isGenerated = item.hasAttribute("generateditemid");
if (item.nodeName == "menuitem") {
var isGenerated = item.className == "spell-suggestion"
|| item.className == "sendtab-target";
if (isGenerated) {
is(item.id, "", "child menuitem #" + i + " is generated");
} else if (isPageMenuItem) {
is(item.id, "", "child menuitem #" + i + " is a generated page menu item");
var isSpellSuggestion = item.className == "spell-suggestion";
if (isSpellSuggestion) {
is(item.id, "", "child menuitem #" + i + " is a spelling suggestion");
} else if (isGenerated) {
is(item.id, "", "child menuitem #" + i + " is a generated item");
} else {
ok(item.id, "child menuitem #" + i + " has an ID");
}
var label = item.getAttribute("label");
ok(label.length, "menuitem " + item.id + " has a label");
if (isGenerated) {
is(key, "", "Generated items shouldn't have an access key");
if (isSpellSuggestion) {
is(key, "", "Spell suggestions shouldn't have an access key");
items.push("*" + label);
} else if (isPageMenuItem) {
} else if (isGenerated) {
items.push("+" + label);
} else if (item.id.indexOf("spell-check-dictionary-") != 0 &&
item.id != "spell-no-suggestions" &&
@ -72,10 +71,10 @@ function getVisibleMenuItems(aMenu, aData) {
else
accessKeys[key] = item.id;
}
if (!isGenerated && !isPageMenuItem) {
if (!isSpellSuggestion && !isGenerated) {
items.push(item.id);
}
if (isPageMenuItem) {
if (isGenerated) {
var p = {};
p.type = item.getAttribute("type");
p.icon = item.getAttribute("image");
@ -90,11 +89,11 @@ function getVisibleMenuItems(aMenu, aData) {
items.push("---");
items.push(null);
} else if (item.nodeName == "menu") {
if (isPageMenuItem) {
if (isGenerated) {
item.id = "generated-submenu-" + aData.generatedSubmenuId++;
}
ok(item.id, "child menu #" + i + " has an ID");
if (!isPageMenuItem) {
if (!isGenerated) {
ok(key, "menu has an access key");
if (accessKeys[key])
ok(false, "menu " + item.id + " has same accesskey as " + accessKeys[key]);

View File

@ -61,7 +61,7 @@ function whenDelayedStartupFinished(aWindow, aCallback) {
}, "browser-delayed-startup-finished", false);
}
function updateTabContextMenu(tab, onOpened) {
function updateTabContextMenu(tab) {
let menu = document.getElementById("tabContextMenu");
if (!tab)
tab = gBrowser.selectedTab;
@ -69,15 +69,7 @@ function updateTabContextMenu(tab, onOpened) {
tab.dispatchEvent(evt);
menu.openPopup(tab, "end_after", 0, 0, true, false, evt);
is(TabContextMenu.contextTab, tab, "TabContextMenu context is the expected tab");
const onFinished = () => menu.hidePopup();
if (onOpened) {
return Task.spawn(function*() {
yield onOpened();
onFinished();
});
} else {
onFinished();
}
menu.hidePopup();
}
function openToolbarCustomizationUI(aCallback, aBrowserWin) {
@ -1167,25 +1159,3 @@ function getCertExceptionDialog(aLocation) {
}
}
function setupRemoteClientsFixture(fixture) {
let oldRemoteClientsGetter =
Object.getOwnPropertyDescriptor(gFxAccounts, "remoteClients").get;
Object.defineProperty(gFxAccounts, "remoteClients", {
get: function() { return fixture; }
});
return oldRemoteClientsGetter;
}
function restoreRemoteClients(getter) {
Object.defineProperty(gFxAccounts, "remoteClients", {
get: getter
});
}
function* openMenuItemSubmenu(id) {
let menuPopup = document.getElementById(id).menupopup;
let menuPopupPromise = BrowserTestUtils.waitForEvent(menuPopup, "popupshown");
menuPopup.showPopup();
yield menuPopupPromise;
}

View File

@ -33,7 +33,3 @@ syncStartNotification.body = Firefox will begin syncing momentarily.
# These strings are used in a notification shown after Sync was disconnected remotely.
deviceDisconnectedNotification.title = Sync disconnected
deviceDisconnectedNotification.body = This computer has been successfully disconnected from Firefox Sync.
# LOCALIZATION NOTE (sendTabToAllDevices.menuitem)
# Displayed in the Send Tabs context menu when right clicking a tab, a page or a link.
sendTabToAllDevices.menuitem = All Devices

View File

@ -40,12 +40,6 @@ can reach it easily. -->
<!ENTITY pinTab.accesskey "P">
<!ENTITY unpinTab.label "Unpin Tab">
<!ENTITY unpinTab.accesskey "b">
<!ENTITY sendTabToDevice.label "Send Tab to Device">
<!ENTITY sendTabToDevice.accesskey "D">
<!ENTITY sendPageToDevice.label "Send Page to Device">
<!ENTITY sendPageToDevice.accesskey "D">
<!ENTITY sendLinkToDevice.label "Send Link to Device">
<!ENTITY sendLinkToDevice.accesskey "D">
<!ENTITY moveToNewWindow.label "Move to New Window">
<!ENTITY moveToNewWindow.accesskey "W">
<!ENTITY bookmarkAllTabs.label "Bookmark All Tabs…">

View File

@ -75,10 +75,6 @@ ClientEngine.prototype = {
Svc.Prefs.set(this.name + ".lastRecordUpload", Math.floor(value));
},
get remoteClients() {
return Object.values(this._store._remoteClients);
},
// Aggregate some stats on the composition of clients on this account
get stats() {
let stats = {