Backout 545cb0d6b5c6 (bug 811490), 4fd6fc029bbe (bug 722977) for xpcshell failures

This commit is contained in:
Ed Morley 2012-11-16 19:15:18 +00:00
parent a1e96510b2
commit ee93273e84
5 changed files with 23 additions and 95 deletions

View File

@ -54,13 +54,9 @@ sync_engine_modules := \
history.js \
passwords.js \
prefs.js \
tabs.js \
$(NULL)
# Preprocess engine files.
SYNC_PP_ENGINE := modules/engines/tabs.js
SYNC_PP_ENGINE_PATH = $(FINAL_TARGET)/modules/services-sync/engines
PP_TARGETS += SYNC_PP_ENGINE
sync_stage_modules := \
cluster.js \
enginesync.js \

View File

@ -18,8 +18,13 @@ Cu.import("resource://services-sync/util.js");
Cu.import("resource://services-sync/constants.js");
Cu.import("resource://services-common/preferences.js");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
// It is safer to inspect the private browsing preferences rather than
// the flags of nsIPrivateBrowsingService. The user may have turned on
// "Never remember history" in the same session, or Firefox was started
// with the -private command line argument. In both cases, the
// "autoStarted" flag of nsIPrivateBrowsingService will be wrong.
const PBPrefs = new Preferences("browser.privatebrowsing.");
this.TabSetRecord = function TabSetRecord(collection, id) {
CryptoWrapper.call(this, collection, id);
@ -123,9 +128,6 @@ TabStore.prototype = {
let currentState = JSON.parse(Svc.Session.getBrowserState());
let tabLastUsed = this.tabLastUsed;
currentState.windows.forEach(function(window) {
if (window.isPrivate) {
return;
}
window.tabs.forEach(function(tab) {
// Make sure there are history entries to look at.
if (!tab.entries.length)
@ -157,6 +159,12 @@ TabStore.prototype = {
let record = new TabSetRecord(collection, id);
record.clientName = this.engine.service.clientsEngine.localName;
// Don't provide any tabs to compare against and ignore the update later.
if (Svc.Private && Svc.Private.privateBrowsingEnabled && !PBPrefs.get("autostart")) {
record.tabs = [];
return record;
}
// Sort tabs in descending-used order to grab the most recently used
let tabs = this.getAllTabs(true).sort(function(a, b) {
return b.lastUsed - a.lastUsed;
@ -187,21 +195,10 @@ TabStore.prototype = {
},
getAllIDs: function TabStore_getAllIds() {
// Don't report any tabs if all windows are in private browsing for
// first syncs.
// Don't report any tabs if we're in private browsing for first syncs.
let ids = {};
let allWindowsArePrivate = true;
let wins = Services.wm.getEnumerator("navigator:browser");
while (wins.hasMoreElements()) {
if (!PrivateBrowsingUtils.isWindowPrivate(wins.getNext())) {
allWindowsArePrivate = false;
break;
}
}
if (allWindowsArePrivate) {
if (Svc.Private && Svc.Private.privateBrowsingEnabled && !PBPrefs.get("autostart"))
return ids;
}
ids[this.engine.service.clientsEngine.localID] = true;
return ids;
@ -283,9 +280,7 @@ TabTracker.prototype = {
switch (aTopic) {
case "weave:engine:start-tracking":
if (!this._enabled) {
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
Svc.Obs.add("private-browsing", this);
#endif
Svc.Obs.add("domwindowopened", this);
let wins = Services.wm.getEnumerator("navigator:browser");
while (wins.hasMoreElements())
@ -295,9 +290,7 @@ TabTracker.prototype = {
break;
case "weave:engine:stop-tracking":
if (this._enabled) {
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
Svc.Obs.remove("private-browsing", this);
#endif
Svc.Obs.remove("domwindowopened", this);
let wins = Services.wm.getEnumerator("navigator:browser");
while (wins.hasMoreElements())
@ -314,22 +307,16 @@ TabTracker.prototype = {
self._registerListenersForWindow(aSubject);
}, false);
break;
#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
case "private-browsing":
if (aData == "enter" && !PrivateBrowsingUtils.permanentPrivateBrowsing)
if (aData == "enter" && !PBPrefs.get("autostart"))
this.modified = false;
#endif
}
},
onTab: function onTab(event) {
if (event.originalTarget.linkedBrowser) {
let win = event.originalTarget.linkedBrowser.contentWindow;
if (PrivateBrowsingUtils.isWindowPrivate(win) &&
!PrivateBrowsingUtils.permanentPrivateBrowsing) {
this._log.trace("Ignoring tab event from private browsing.");
return;
}
if (Svc.Private && Svc.Private.privateBrowsingEnabled && !PBPrefs.get("autostart")) {
this._log.trace("Ignoring tab event from private browsing.");
return;
}
this._log.trace("onTab event: " + event.type);

View File

@ -58,6 +58,7 @@ var tabs3 = [
}
];
/*
* Test phases
*/
@ -76,7 +77,7 @@ Phase('phase2', [
Phase('phase3', [
[Sync],
[Windows.add, { private: true }],
[SetPrivateBrowsing, true],
[Tabs.add, tabs3],
[Sync]
]);
@ -85,3 +86,4 @@ Phase('phase4', [
[Sync],
[Tabs.verifyNot, tabs3]
]);

View File

@ -25,7 +25,6 @@ CU.import("resource://tps/history.jsm");
CU.import("resource://tps/forms.jsm");
CU.import("resource://tps/prefs.jsm");
CU.import("resource://tps/tabs.jsm");
CU.import("resource://tps/windows.jsm");
var hh = CC["@mozilla.org/network/protocol;1?name=http"]
.getService(CI.nsIHttpProtocolHandler);
@ -164,20 +163,6 @@ let TPS = {
this.goQuitApplication();
},
HandleWindows: function (aWindow, action) {
Logger.logInfo("executing action " + action.toUpperCase() +
" on window " + JSON.stringify(aWindow));
switch(action) {
case ACTION_ADD:
BrowserWindows.Add(aWindow.private, function(win) {
Logger.logInfo("window finished loading");
this.FinishAsyncOperation();
}.bind(this));
break;
}
Logger.logPass("executing action " + action.toUpperCase() + " on windows");
},
HandleTabs: function (tabs, action) {
this._tabsAdded = tabs.length;
this._tabsFinished = 0;
@ -942,9 +927,3 @@ var Tabs = {
}
};
var Windows = {
add: function Window__add(aWindow) {
TPS.StartAsyncOperation();
TPS.HandleWindows(aWindow, ACTION_ADD);
},
};

View File

@ -1,36 +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/. */
"use strict";
/* This is a JavaScript module (JSM) to be imported via
Components.utils.import() and acts as a singleton.
Only the following listed symbols will exposed on import, and only when
and where imported. */
const EXPORTED_SYMBOLS = ["BrowserWindows"];
const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
Cu.import("resource://services-sync/main.js");
let BrowserWindows = {
/**
* Add
*
* Opens a new window. Throws on error.
*
* @param aPrivate The private option.
* @return nothing
*/
Add: function(aPrivate, fn) {
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let mainWindow = wm.getMostRecentWindow("navigator:browser");
let win = mainWindow.OpenBrowserWindow({private: aPrivate});
win.addEventListener("load", function onLoad() {
win.removeEventListener("load", onLoad, false);
fn.call(win);
}, false);
}
};