mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
Bug 806744 - Port the satchel test_privbrowsing.html to the new per-tab PB APIs. r=jdm
--HG-- rename : toolkit/components/satchel/test/test_privbrowsing.html => toolkit/components/satchel/test/browser/browser_privbrowsing_perwindowpb.js
This commit is contained in:
parent
500d4b5b3c
commit
41541998ab
@ -12,6 +12,9 @@ relativesrcdir = @relativesrcdir@
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = test_satchel
|
||||
DIRS = \
|
||||
browser \
|
||||
$(NULL)
|
||||
|
||||
XPCSHELL_TESTS = \
|
||||
unit \
|
||||
|
25
toolkit/components/satchel/test/browser/Makefile.in
Normal file
25
toolkit/components/satchel/test/browser/Makefile.in
Normal file
@ -0,0 +1,25 @@
|
||||
# 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 \
|
||||
../subtst_privbrowsing.html \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_PER_WINDOW_PRIVATE_BROWSING
|
||||
MOCHITEST_BROWSER_FILES += \
|
||||
browser_privbrowsing_perwindowpb.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
@ -0,0 +1,59 @@
|
||||
/* 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/. */
|
||||
|
||||
/** Test for Bug 472396 **/
|
||||
function test() {
|
||||
// initialization
|
||||
waitForExplicitFinish();
|
||||
let windowsToClose = [];
|
||||
let testURI =
|
||||
"http://example.com/tests/toolkit/components/satchel/test/subtst_privbrowsing.html";
|
||||
let formHistory = Cc["@mozilla.org/satchel/form-history;1"].
|
||||
getService(Ci.nsIFormHistory2);
|
||||
|
||||
function doTest(aIsPrivateMode, aShouldValueExist, aWindow, aCallback) {
|
||||
aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
|
||||
// Wait for the second load of the page to call the callback,
|
||||
// because the first load submits the form and the page reloads after
|
||||
// the form submission.
|
||||
aWindow.gBrowser.selectedBrowser.addEventListener("load", function onLoad() {
|
||||
aWindow.gBrowser.selectedBrowser.removeEventListener("load", onLoad, true);
|
||||
executeSoon(aCallback);
|
||||
}, true);
|
||||
|
||||
is(formHistory.entryExists("field", "value"), aShouldValueExist,
|
||||
"Checking value exists in form history");
|
||||
}, true);
|
||||
|
||||
aWindow.gBrowser.selectedBrowser.loadURI(testURI);
|
||||
}
|
||||
|
||||
function testOnWindow(aOptions, aCallback) {
|
||||
whenNewWindowLoaded(aOptions, function(aWin) {
|
||||
windowsToClose.push(aWin);
|
||||
executeSoon(function() aCallback(aWin));
|
||||
});
|
||||
};
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
windowsToClose.forEach(function(aWin) {
|
||||
aWin.close();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
testOnWindow({private: true}, function(aWin) {
|
||||
doTest(true, false, aWin, function() {
|
||||
// Test when not on private mode after visiting a site on private
|
||||
// mode. The form history should no exist.
|
||||
testOnWindow({}, function(aWin) {
|
||||
doTest(false, false, aWin, function() {
|
||||
finish();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
8
toolkit/components/satchel/test/browser/head.js
Normal file
8
toolkit/components/satchel/test/browser/head.js
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
win.addEventListener("load", function onLoad() {
|
||||
win.removeEventListener("load", onLoad, false);
|
||||
aCallback(win);
|
||||
}, false);
|
||||
}
|
Loading…
Reference in New Issue
Block a user