Backout 6e26bb277c64 (bug 799780), cb395ed2de20 (bug 799664), cd5679486c7b (bug 799526) for causing frequent failures in browser_bug400731.js

This commit is contained in:
Ed Morley 2012-10-11 15:00:05 +01:00
parent ea651152aa
commit 9b9179d8dc
61 changed files with 122 additions and 206 deletions

View File

@ -7068,6 +7068,9 @@ function getNavToolbox() gNavToolbox;
# make it work in both modes, the amount of duplicated code is small and the
# code is much more readable this way.
let gPrivateBrowsingUI = {
_inited: false,
_initCallbacks: [],
init: function PBUI_init() {
// Do nothing for normal windows
if (!PrivateBrowsingUtils.isWindowPrivate(window)) {
@ -7088,6 +7091,26 @@ let gPrivateBrowsingUI = {
docElement.setAttribute("privatebrowsingmode", "temporary");
gBrowser.updateTitlebar();
}
this._inited = true;
this._initCallbacks.forEach(function (callback) callback.apply());
this._initCallbacks = [];
},
get autoStarted() {
return false; // auto-started PB not supported for now
},
get initialized() {
return this._inited;
},
addInitializationCallback: function PBUI_addInitializationCallback(aCallback) {
if (this._inited)
return;
this._initCallbacks.push(aCallback);
}
};
@ -7098,6 +7121,7 @@ let gPrivateBrowsingUI = {
_searchBarValue: null,
_findBarValue: null,
_inited: false,
_initCallbacks: [],
init: function PBUI_init() {
Services.obs.addObserver(this, "private-browsing", false);
@ -7110,6 +7134,9 @@ let gPrivateBrowsingUI = {
this.onEnterPrivateBrowsing(true);
this._inited = true;
this._initCallbacks.forEach(function (callback) callback.apply());
this._initCallbacks = [];
},
uninit: function PBUI_unint() {
@ -7120,6 +7147,17 @@ let gPrivateBrowsingUI = {
Services.obs.removeObserver(this, "private-browsing-transition-complete");
},
get initialized() {
return this._inited;
},
addInitializationCallback: function PBUI_addInitializationCallback(aCallback) {
if (this._inited)
return;
this._initCallbacks.push(aCallback);
},
get _disableUIOnToggle() {
if (this._privateBrowsingService.autoStarted)
return false;
@ -7322,6 +7360,10 @@ let gPrivateBrowsingUI = {
!this.privateBrowsingEnabled;
},
get autoStarted() {
return this._privateBrowsingService.autoStarted;
},
get privateBrowsingEnabled() {
return this._privateBrowsingService.privateBrowsingEnabled;
}

View File

@ -13,9 +13,14 @@ XPCOMUtils.defineLazyGetter(this, "BROWSER_NEW_TAB_URL", function () {
const TOPIC = "private-browsing-transition-complete";
function getNewTabPageURL() {
if (!Services.prefs.prefHasUserValue(PREF)) {
if (PrivateBrowsingUtils.isWindowPrivate(window) &&
!PrivateBrowsingUtils.permanentPrivateBrowsing)
if (("gPrivateBrowsingUI" in window) &&
!Services.prefs.prefHasUserValue(PREF)) {
// gPrivateBrowsingUI may not be initialized yet, in that case we'll
// update BROWSER_NEW_TAB_URL when it gets initialized.
if (!gPrivateBrowsingUI.initialized)
gPrivateBrowsingUI.addInitializationCallback(update);
else if (PrivateBrowsingUtils.isWindowPrivate(window) &&
!gPrivateBrowsingUI.autoStarted)
return "about:privatebrowsing";
}
return Services.prefs.getCharPref(PREF) || "about:blank";

View File

@ -12,14 +12,7 @@ include $(DEPTH)/config/autoconf.mk
MODULE = test_privatebrowsing
# Most xpcshell PB tests use the global PB service, which means that we should
# not attempt to run them in regular builds. We should look at the list and
# decide which ones of them should be ported to the browser/perwindow suite
# in the future.
ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
XPCSHELL_TESTS = unit
endif
DIRS += browser \
$(NULL)

View File

@ -10,23 +10,65 @@ relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = test_privatebrowsing
MOCHITEST_BROWSER_FILES = \
head.js \
browser_console_clear.js \
browser_privatebrowsing_certexceptionsui.js \
browser_privatebrowsing_commandline_toggle.js \
browser_privatebrowsing_concurrent.js \
browser_privatebrowsing_concurrent_page.html \
browser_privatebrowsing_crh.js \
browser_privatebrowsing_fastswitch.js \
browser_privatebrowsing_findbar.js \
browser_privatebrowsing_forgetthissite.js \
browser_privatebrowsing_geoprompt.js \
browser_privatebrowsing_geoprompt_page.html \
browser_privatebrowsing_import.js \
browser_privatebrowsing_lastpbcontextexited.js \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_before_after.js \
browser_privatebrowsing_localStorage_before_after_page.html \
browser_privatebrowsing_localStorage_before_after_page2.html \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \
browser_privatebrowsing_newwindow_stopcmd.js \
browser_privatebrowsing_opendir.js \
browser_privatebrowsing_openlocation.js \
browser_privatebrowsing_openLocationLastURL.js \
browser_privatebrowsing_pageinfo.js \
browser_privatebrowsing_placestitle.js \
browser_privatebrowsing_popupblocker.js \
browser_privatebrowsing_popupmode.js \
browser_privatebrowsing_protocolhandler.js \
browser_privatebrowsing_protocolhandler_page.html \
browser_privatebrowsing_searchbar.js \
browser_privatebrowsing_sslsite_transition.js \
browser_privatebrowsing_theming.js \
browser_privatebrowsing_transition.js \
browser_privatebrowsing_ui.js \
browser_privatebrowsing_urlbarfocus.js \
browser_privatebrowsing_urlbarundo.js \
browser_privatebrowsing_viewsource.js \
browser_privatebrowsing_windowtitle.js \
browser_privatebrowsing_windowtitle_page.html \
browser_privatebrowsing_zoom.js \
browser_privatebrowsing_zoomrestore.js \
ctxmenu.html \
ctxmenu-image.png \
popup.html \
staller.sjs \
title.sjs \
$(NULL)
# We have three category of browser-chrome tests:
# global: these tests focus on the global PB service implementation.
# perwindow: these tests focus on the per-window PB implementation.
# obsolete: these tests focus on the global mode, but the functionality
# that they are testing is specific to the global mode, and
# will never have a per-window counterpart.
#
# As a transition plan, we have divided the existing tests into the
# global and obsolete categories, and we'll then focus on rewriting the
# global tests to test the per-window mode.
# Disabled until bug 564934 is fixed:
# browser_privatebrowsing_downloadmonitor.js \
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
DIRS += perwindow
else
DIRS += global obsolete
# Turn off private browsing tests that perma-timeout on Linux.
ifneq (Linux,$(OS_ARCH))
MOCHITEST_BROWSER_FILES += \
browser_privatebrowsing_beforeunload.js \
browser_privatebrowsing_cookieacceptdialog.js \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -12,7 +12,7 @@
// Step 4: load a page in the tab from step 2 that checks the value of test is value and the total count in private storage is 1
function test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/perwindow/browser_privatebrowsing_concurrent_page.html';
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_concurrent_page.html';
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
let non_private_tab = gBrowser.selectedBrowser;

View File

@ -115,7 +115,7 @@ function addDownload(dm, aParams)
aParams.targetFile.append(aParams.resultFileName);
}
if (!("sourceURI" in aParams))
aParams.sourceURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/staller.sjs";
aParams.sourceURI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/staller.sjs";
if (!("downloadName" in aParams))
aParams.downloadName = null;
if (!("runBeforeStart" in aParams))

View File

@ -11,7 +11,7 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
const testPageURL = "http://mochi.test:8888/browser/" +
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_geoprompt_page.html";
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_geoprompt_page.html";
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();

View File

@ -5,6 +5,8 @@
// This test makes sure that the "Import and Backup->Import From Another Browser"
// menu item in the Places Organizer is disabled inside private browsing mode.
// TEST_PATH=browser/components/privatebrowsing/test/browser/browser_privatebrowsing_import.js make -C $(OBJDIR) mochitest-browser-chrome
let pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);

View File

@ -12,7 +12,7 @@ function test() {
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
let tab2 = gBrowser.selectedTab = gBrowser.addTab();
browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' +
browser.contentWindow.location = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page2.html';
browser.addEventListener('load', function() {
browser.removeEventListener('load', arguments.callee, true);
@ -21,6 +21,6 @@ function test() {
finish();
}, true);
}, true);
browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/' +
browser.loadURI('http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/' +
'browser_privatebrowsing_localStorage_page1.html');
}

View File

@ -11,7 +11,7 @@
// existing.
function test() {
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/';
let prefix = 'http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/';
waitForExplicitFinish();
// We wait for a GC to ensure that all previous PB docshells in this test suite are destroyed

View File

@ -14,7 +14,7 @@ function test() {
waitForExplicitFinish();
ignoreAllUncaughtExceptions();
const TEST_URL = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/title.sjs";
const TEST_URL = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/title.sjs";
function waitForCleanup(aCallback) {
// delete all cookies

View File

@ -13,7 +13,7 @@ function test() {
let oldPopupPolicy = gPrefService.getBoolPref("dom.disable_open_during_load");
gPrefService.setBoolPref("dom.disable_open_during_load", true);
const TEST_URI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/global/popup.html";
const TEST_URI = "http://mochi.test:8888/browser/browser/components/privatebrowsing/test/browser/popup.html";
waitForExplicitFinish();

View File

@ -11,7 +11,7 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
const testPageURL = "http://example.com/browser/" +
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_protocolhandler_page.html";
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_protocolhandler_page.html";
waitForExplicitFinish();
const notificationValue = "Protocol Registration: testprotocol";

View File

@ -12,7 +12,7 @@ function test() {
getService(Ci.nsIPrivateBrowsingService);
const testPageURL = "http://mochi.test:8888/browser/" +
"browser/components/privatebrowsing/test/browser/global/browser_privatebrowsing_windowtitle_page.html";
"browser/components/privatebrowsing/test/browser/browser_privatebrowsing_windowtitle_page.html";
waitForExplicitFinish();
requestLongerTimeout(2);

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -1,53 +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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_BROWSER_FILES = \
head.js \
browser_privatebrowsing_certexceptionsui.js \
browser_privatebrowsing_crh.js \
browser_privatebrowsing_geoprompt.js \
browser_privatebrowsing_geoprompt_page.html \
browser_privatebrowsing_localStorage.js \
browser_privatebrowsing_localStorage_before_after.js \
browser_privatebrowsing_localStorage_before_after_page.html \
browser_privatebrowsing_localStorage_before_after_page2.html \
browser_privatebrowsing_localStorage_page1.html \
browser_privatebrowsing_localStorage_page2.html \
browser_privatebrowsing_opendir.js \
browser_privatebrowsing_openlocation.js \
browser_privatebrowsing_openLocationLastURL.js \
browser_privatebrowsing_placestitle.js \
browser_privatebrowsing_popupblocker.js \
browser_privatebrowsing_protocolhandler.js \
browser_privatebrowsing_protocolhandler_page.html \
browser_privatebrowsing_sslsite_transition.js \
browser_privatebrowsing_theming.js \
browser_privatebrowsing_ui.js \
browser_privatebrowsing_urlbarfocus.js \
browser_privatebrowsing_windowtitle.js \
browser_privatebrowsing_windowtitle_page.html \
browser_privatebrowsing_zoom.js \
browser_privatebrowsing_zoomrestore.js \
ctxmenu.html \
ctxmenu-image.png \
popup.html \
title.sjs \
$(NULL)
# Turn off private browsing tests that perma-timeout on Linux.
ifneq (Linux,$(OS_ARCH))
MOCHITEST_BROWSER_FILES += \
browser_privatebrowsing_cookieacceptdialog.js \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,41 +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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_BROWSER_FILES = \
head.js \
browser_console_clear.js \
browser_privatebrowsing_commandline_toggle.js \
browser_privatebrowsing_fastswitch.js \
browser_privatebrowsing_findbar.js \
browser_privatebrowsing_forgetthissite.js \
browser_privatebrowsing_import.js \
browser_privatebrowsing_newwindow_stopcmd.js \
browser_privatebrowsing_pageinfo.js \
browser_privatebrowsing_popupmode.js \
browser_privatebrowsing_searchbar.js \
browser_privatebrowsing_transition.js \
browser_privatebrowsing_urlbarundo.js \
browser_privatebrowsing_viewsource.js \
staller.sjs \
$(NULL)
# Disabled until bug 564934 is fixed:
# browser_privatebrowsing_downloadmonitor.js \
# Turn off private browsing tests that perma-timeout on Linux.
ifneq (Linux,$(OS_ARCH))
MOCHITEST_BROWSER_FILES += \
browser_privatebrowsing_beforeunload.js \
$(NULL)
endif
include $(topsrcdir)/config/rules.mk

View File

@ -1,25 +0,0 @@
// Make sure that we clean up after each test if it times out, for example.
registerCleanupFunction(function() {
var pb = Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService);
ok(!pb.privateBrowsingEnabled, "Private browsing should be terminated after finishing the test");
pb.privateBrowsingEnabled = false;
try {
Services.prefs.clearUserPref("browser.privatebrowsing.keep_current_session");
} catch(e) {}
});
/**
* Waits for completion of a clear history operation, before
* proceeding with aCallback.
*
* @param aCallback
* Function to be called when done.
*/
function waitForClearHistory(aCallback) {
Services.obs.addObserver(function observeCH(aSubject, aTopic, aData) {
Services.obs.removeObserver(observeCH, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
aCallback();
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
PlacesUtils.bhistory.removeAllPages();
}

View File

@ -1,20 +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/.
DEPTH = @DEPTH@
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = @relativesrcdir@
include $(DEPTH)/config/autoconf.mk
MOCHITEST_BROWSER_FILES = \
head.js \
browser_privatebrowsing_concurrent.js \
browser_privatebrowsing_concurrent_page.html \
browser_privatebrowsing_lastpbcontextexited.js \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,14 +0,0 @@
/*
* Function created to put a window in PB mode.
* THIS IS DANGEROUS. DO NOT DO THIS OUTSIDE OF TESTS!
*/
function setPrivateWindow(aWindow, aEnable) {
return aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIXULWindow)
.docShell.QueryInterface(Ci.nsILoadContext)
.usePrivateBrowsing = aEnable;
}

View File

@ -64,6 +64,7 @@ EXTRA_JS_MODULES = \
InlineSpellChecker.jsm \
PageMenu.jsm \
PopupNotifications.jsm \
PrivateBrowsingUtils.jsm \
PropertyListUtils.jsm \
Task.jsm \
UpdateChannel.jsm \
@ -71,7 +72,6 @@ EXTRA_JS_MODULES = \
EXTRA_PP_JS_MODULES = \
LightweightThemeConsumer.jsm \
PrivateBrowsingUtils.jsm \
Services.jsm \
WindowDraggingUtils.jsm \
Troubleshoot.jsm \

View File

@ -4,7 +4,6 @@
var EXPORTED_SYMBOLS = ["PrivateBrowsingUtils"];
const Cc = Components.classes;
const Ci = Components.interfaces;
var PrivateBrowsingUtils = {
@ -13,19 +12,5 @@ var PrivateBrowsingUtils = {
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsILoadContext)
.usePrivateBrowsing;
},
get permanentPrivateBrowsing() {
#ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
return false; // permanent PB is not supported for now
#else
try {
return Cc["@mozilla.org/privatebrowsing;1"].
getService(Ci.nsIPrivateBrowsingService).
autoStarted;
} catch (e) {
return false; // PB not supported
}
#endif
}
};