Skip to content

Commit

Permalink
Backed out changesets 48d6706662c0, 53236b4393f2, and 9125083b8dfe (b…
Browse files Browse the repository at this point in the history
…ug 1268912, bug 1244597) for test_clients_engine.js perma-timeouts.

CLOSED TREE
  • Loading branch information
rvandermeulen committed Jul 15, 2016
1 parent aaa81d5 commit fdcc28a
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ let gWhitelist = [{
file: "netErrorApp.dtd",
key: "securityOverride.warningContent",
type: "single-quote"
}, {
file: "sync.properties",
key: "client.name2",
type: "apostrophe"
}
];

Expand Down
69 changes: 17 additions & 52 deletions browser/components/nsBrowserGlue.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ BrowserGlue.prototype = {
case "fxaccounts:device_disconnected":
this._onDeviceDisconnected();
break;
case "weave:engine:clients:display-uris":
this._onDisplaySyncURIs(subject);
case "weave:engine:clients:display-uri":
this._onDisplaySyncURI(subject);
break;
case "session-save":
this._setPrefToSaveSession(true);
Expand Down Expand Up @@ -534,7 +534,7 @@ BrowserGlue.prototype = {
os.addObserver(this, "weave:service:ready", false);
os.addObserver(this, "fxaccounts:onverified", false);
os.addObserver(this, "fxaccounts:device_disconnected", false);
os.addObserver(this, "weave:engine:clients:display-uris", false);
os.addObserver(this, "weave:engine:clients:display-uri", false);
os.addObserver(this, "session-save", false);
os.addObserver(this, "places-init-complete", false);
this._isPlacesInitObserver = true;
Expand Down Expand Up @@ -601,7 +601,7 @@ BrowserGlue.prototype = {
os.removeObserver(this, "weave:service:ready");
os.removeObserver(this, "fxaccounts:onverified");
os.removeObserver(this, "fxaccounts:device_disconnected");
os.removeObserver(this, "weave:engine:clients:display-uris");
os.removeObserver(this, "weave:engine:clients:display-uri");
os.removeObserver(this, "session-save");
if (this._bookmarksBackupIdleTime) {
this._idleService.removeIdleObserver(this, this._bookmarksBackupIdleTime);
Expand Down Expand Up @@ -2434,59 +2434,24 @@ BrowserGlue.prototype = {
},

/**
* Called as an observer when Sync's "display URIs" notification is fired.
* Called as an observer when Sync's "display URI" notification is fired.
*
* We open the received URIs in background tabs.
* We open the received URI in a background tab.
*
* Eventually, this will likely be replaced by a more robust tab syncing
* feature. This functionality is considered somewhat evil by UX because it
* opens a new tab automatically without any prompting. However, it is a
* lesser evil than sending a tab to a specific device (from e.g. Fennec)
* and having nothing happen on the receiving end.
*/
_onDisplaySyncURIs: function _onDisplaySyncURIs(data) {
_onDisplaySyncURI: function _onDisplaySyncURI(data) {
try {
// The payload is wrapped weirdly because of how Sync does notifications.
const URIs = data.wrappedJSObject.object;

const findWindow = () => RecentWindow.getMostRecentBrowserWindow({private: false});

// win can be null, but it's ok, we'll assign it later in openTab()
let win = findWindow();

const openTab = URI => {
let tab;
if (!win) {
Services.appShell.hiddenDOMWindow.open(URI.uri);
win = findWindow();
tab = win.gBrowser.tabs[0];
} else {
tab = win.gBrowser.addTab(URI.uri);
}
tab.setAttribute("attention", true);
return tab;
};

const firstTab = openTab(URIs[0]);
URIs.slice(1).forEach(URI => openTab(URI));

let title, body;
const deviceName = Weave.Service.clientsEngine.getClientName(URIs[0].clientId);
const bundle = Services.strings.createBundle("chrome://browser/locale/accounts.properties");
if (URIs.length == 1) {
title = bundle.GetStringFromName("tabArrivingNotification.title");
const pageTitle = URIs[0].title || firstTab.linkedBrowser.contentTitle
|| URIs[0].uri;
body = bundle.formatStringFromName("tabArrivingNotification.body", [pageTitle, deviceName], 2);
} else {
title = bundle.GetStringFromName("tabsArrivingNotification.title");
const tabArrivingBody = URIs.every(URI => URI.clientId == URIs[0].clientId) ?
"tabsArrivingNotification.body" : "tabsArrivingNotificationMultiple.body";
body = bundle.formatStringFromName(tabArrivingBody, [URIs.length, deviceName], 2);
}
let tabbrowser = RecentWindow.getMostRecentBrowserWindow({private: false}).gBrowser;

const clickCallback = (subject, topic, data) => {
if (topic == "alertclickcallback") {
win.gBrowser.selectedTab = firstTab;
}
}
AlertsService.showAlertNotification(null, title, body, true, null, clickCallback);
// The payload is wrapped weirdly because of how Sync does notifications.
tabbrowser.addTab(data.wrappedJSObject.object.uri);
} catch (ex) {
Cu.reportError("Error displaying tab(s) received by Sync: " + ex);
Cu.reportError("Error displaying tab received by Sync: " + ex);
}
},

Expand Down
15 changes: 0 additions & 15 deletions browser/locales/en-US/chrome/browser/accounts.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,3 @@ deviceDisconnectedNotification.body = This computer has been successfully discon
# 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

# LOCALIZATION NOTE (tabArrivingNotification.title, tabArrivingNotification.body,
# tabsArrivingNotification.title, tabsArrivingNotification.body)
# These strings are used in a notification shown when we're opening tab(s) another device sent us to display.
tabArrivingNotification.title = Tab received
# LOCALIZATION NOTE (tabArrivingNotification.body) %1 is the title of the tab and %2 is the device name.
tabArrivingNotification.body = “%1$S” has arrived from %2$S.

tabsArrivingNotification.title = Multiple tabs received
# LOCALIZATION NOTE (tabsArrivingNotification.body) %1 is the number of tabs received and %2 is the device name.
tabsArrivingNotification.body = %1$S tabs have arrived from %2$S.
# LOCALIZATION NOTE (tabsArrivingNotificationMultiple.body)
# This string is used in a notification shown when we're opening tab(s) that several devices sent us to display.
# %S is the number of tabs received
tabsArrivingNotificationMultiple.body = %S tabs have arrived from your connected devices.
2 changes: 1 addition & 1 deletion services/cloudsync/CloudSyncLocal.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Local.prototype = {
// fall back on ua info string
Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;

return this.name = Str.sync.get("client.name3", [user, appName, system]);
return this.name = Str.sync.get("client.name2", [user, appName, system]);
},

set name(value) {
Expand Down
2 changes: 1 addition & 1 deletion services/sync/locales/en-US/sync.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

# %1: the user name (Ed), %2: the app name (Firefox), %3: the operating system (Android)
client.name3 = %1$Ss %2$S on %3$S
client.name2 = %1$S's %2$S on %3$S

# %S is the date and time at which the last sync successfully completed
lastSync2.label = Last sync: %S
Expand Down
31 changes: 14 additions & 17 deletions services/sync/modules/engines/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ ClientEngine.prototype = {
if (!commands) {
return true;
}
let URIsToDisplay = [];
for (let key in commands) {
let {command, args} = commands[key];
this._log.debug("Processing command: " + command + "(" + args + ")");
Expand All @@ -406,17 +405,13 @@ ClientEngine.prototype = {
this.service.logout();
return false;
case "displayURI":
let [uri, clientId, title] = args;
URIsToDisplay.push({ uri, clientId, title });
this._handleDisplayURI.apply(this, args);
break;
default:
this._log.debug("Received an unknown command: " + command);
break;
}
}
if (URIsToDisplay.length) {
this._handleDisplayURIs(URIsToDisplay);
}

return true;
})();
Expand Down Expand Up @@ -486,30 +481,32 @@ ClientEngine.prototype = {
},

/**
* Handle a bunch of received 'displayURI' commands.
* Handle a single received 'displayURI' command.
*
* Interested parties should observe the "weave:engine:clients:display-uris"
* topic. The callback will receive an array as the subject parameter
* containing objects with the following keys:
* Interested parties should observe the "weave:engine:clients:display-uri"
* topic. The callback will receive an object as the subject parameter with
* the following keys:
*
* uri URI (string) that is requested for display.
* clientId ID of client that sent the command.
* title Title of page that loaded URI (likely) corresponds to.
*
* The 'data' parameter to the callback will not be defined.
*
* @param uris
* An array containing URI objects to display
* @param uris[].uri
* @param uri
* String URI that was received
* @param uris[].clientId
* @param clientId
* ID of client that sent URI
* @param uris[].title
* @param title
* String title of page that URI corresponds to. Older clients may not
* send this.
*/
_handleDisplayURIs: function _handleDisplayURIs(uris) {
Svc.Obs.notify("weave:engine:clients:display-uris", uris);
_handleDisplayURI: function _handleDisplayURI(uri, clientId, title) {
this._log.info("Received a URI for display: " + uri + " (" + title +
") from " + clientId);

let subject = {uri: uri, client: clientId, title: title};
Svc.Obs.notify("weave:engine:clients:display-uri", subject);
},

_removeRemoteClient(id) {
Expand Down
2 changes: 1 addition & 1 deletion services/sync/modules/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ this.Utils = {
// fall back on ua info string
Cc["@mozilla.org/network/protocol;1?name=http"].getService(Ci.nsIHttpProtocolHandler).oscpu;

return Str.sync.get("client.name3", [user, appName, system]);
return Str.sync.get("client.name2", [user, appName, system]);
},

getDeviceName() {
Expand Down
10 changes: 0 additions & 10 deletions services/sync/tests/unit/head_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Cu.import("resource://services-common/async.js");
Cu.import("resource://testing-common/services/common/utils.js");
Cu.import("resource://testing-common/PlacesTestUtils.jsm");
Cu.import("resource://services-sync/util.js");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");

XPCOMUtils.defineLazyGetter(this, 'SyncPingSchema', function() {
Expand Down Expand Up @@ -391,12 +390,3 @@ function sync_engine_and_validate_telem(engine, allowErrorPings, onError) {
}
});
}

// Avoid an issue where `client.name3` containing unicode characters causes
// a number of tests to fail, due to them assuming that we do not need to utf-8
// encode or decode data sent through the mocked server (see bug 1268912).
Utils.getDefaultDeviceName = function() {
return "Test device name";
};


0 comments on commit fdcc28a

Please sign in to comment.