зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1113178 - Fix all remaining tests using removeAllPages() r=mak
This commit is contained in:
Родитель
f517067128
Коммит
0d23b8433d
|
@ -10,11 +10,12 @@ let tmp = {};
|
|||
Cu.import("resource://gre/modules/Promise.jsm", tmp);
|
||||
Cu.import("resource://gre/modules/NewTabUtils.jsm", tmp);
|
||||
Cu.import("resource:///modules/DirectoryLinksProvider.jsm", tmp);
|
||||
Cu.import("resource://testing-common/PlacesTestUtils.jsm", tmp);
|
||||
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
||||
.getService(Ci.mozIJSSubScriptLoader)
|
||||
.loadSubScript("chrome://browser/content/sanitize.js", tmp);
|
||||
Cu.import("resource://gre/modules/Timer.jsm", tmp);
|
||||
let {Promise, NewTabUtils, Sanitizer, clearTimeout, setTimeout, DirectoryLinksProvider} = tmp;
|
||||
let {Promise, NewTabUtils, Sanitizer, clearTimeout, setTimeout, DirectoryLinksProvider, PlacesTestUtils} = tmp;
|
||||
|
||||
let uri = Services.io.newURI("about:newtab", null, null);
|
||||
let principal = Services.scriptSecurityManager.getNoAppCodebasePrincipal(uri);
|
||||
|
@ -154,7 +155,7 @@ let TestRunner = {
|
|||
*/
|
||||
finish: function () {
|
||||
function cleanupAndFinish() {
|
||||
clearHistory(function () {
|
||||
PlacesTestUtils.clearHistory().then(() => {
|
||||
whenPagesUpdated(finish);
|
||||
NewTabUtils.restore();
|
||||
});
|
||||
|
@ -229,7 +230,7 @@ function setLinks(aLinks, aCallback = TestRunner.next) {
|
|||
// given entries and call populateCache() now again to make sure the cache
|
||||
// has the desired contents.
|
||||
NewTabUtils.links.populateCache(function () {
|
||||
clearHistory(function () {
|
||||
PlacesTestUtils.clearHistory().then(() => {
|
||||
fillHistory(links, function () {
|
||||
NewTabUtils.links.populateCache(function () {
|
||||
NewTabUtils.allPages.update();
|
||||
|
@ -240,15 +241,6 @@ function setLinks(aLinks, aCallback = TestRunner.next) {
|
|||
});
|
||||
}
|
||||
|
||||
function clearHistory(aCallback) {
|
||||
Services.obs.addObserver(function observe(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(observe, aTopic);
|
||||
executeSoon(aCallback);
|
||||
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
|
||||
PlacesUtils.history.removeAllPages();
|
||||
}
|
||||
|
||||
function fillHistory(aLinks, aCallback = TestRunner.next) {
|
||||
let numLinks = aLinks.length;
|
||||
if (!numLinks) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
|
||||
|
||||
|
@ -64,7 +63,7 @@ function cleanUp() {
|
|||
|
||||
function runNextTest() {
|
||||
if (gTestIndex == tests.length) {
|
||||
waitForClearHistory(finish);
|
||||
PlacesTestUtils.clearHistory().then(finish);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -136,15 +135,3 @@ function getSiteItem(aHost) {
|
|||
return gBrowser.contentDocument.
|
||||
querySelector(".site[value='" + aHost + "']");
|
||||
}
|
||||
|
||||
// copied from toolkit/components/places/tests/head_common.js
|
||||
function waitForClearHistory(aCallback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/NetUtil.jsm");
|
||||
|
||||
const ABOUT_PERMISSIONS_SPEC = "about:permissions";
|
||||
|
@ -81,7 +80,7 @@ function cleanUp() {
|
|||
|
||||
function runNextTest() {
|
||||
if (gTestIndex == tests.length) {
|
||||
waitForClearHistory(finish);
|
||||
PlacesTestUtils.clearHistory().then(finish);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -275,7 +274,7 @@ var tests = [
|
|||
function test_forget_site() {
|
||||
// click "Forget About This Site" button
|
||||
gBrowser.contentDocument.getElementById("forget-site-button").doCommand();
|
||||
waitForClearHistory(function() {
|
||||
PlacesTestUtils.clearHistory().then(() => {
|
||||
is(gSiteLabel.value, "", "site label cleared");
|
||||
|
||||
let allSitesItem = gBrowser.contentDocument.getElementById("all-sites-item");
|
||||
|
@ -329,15 +328,3 @@ function addWindowListener(aURL, aCallback) {
|
|||
onWindowTitleChange: function(aXULWindow, aNewTitle) { }
|
||||
});
|
||||
}
|
||||
|
||||
// copied from toolkit/components/places/tests/head_common.js
|
||||
function waitForClearHistory(aCallback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
|
||||
"resource://testing-common/PlacesTestUtils.jsm");
|
||||
|
||||
/**
|
||||
* Asynchronously adds visits to a page, invoking a callback function when done.
|
||||
*
|
||||
|
|
|
@ -31,7 +31,7 @@ function test() {
|
|||
});
|
||||
|
||||
|
||||
waitForClearHistory(function () {
|
||||
PlacesTestUtils.clearHistory().then(() => {
|
||||
historyObserver = {
|
||||
onTitleChanged: function(aURI, aPageTitle) {
|
||||
switch (++testNumber) {
|
||||
|
@ -89,7 +89,7 @@ function test() {
|
|||
|
||||
function afterFirstVisitInPrivateWindow() {
|
||||
is(PlacesUtils.history.getPageTitle(TEST_URI), TITLE_2, "The title remains the same after visiting in private window");
|
||||
waitForClearHistory(finish);
|
||||
PlacesTestUtils.clearHistory().then(finish);
|
||||
}
|
||||
|
||||
function whenPageLoad(aWin, aCallback) {
|
||||
|
@ -107,17 +107,5 @@ function test() {
|
|||
executeSoon(function() { aCallback(aWin) });
|
||||
});
|
||||
}
|
||||
|
||||
function waitForClearHistory(aCallback) {
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, PlacesUtils.TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,11 +16,7 @@ function test() {
|
|||
// delete all cookies
|
||||
cm.removeAll();
|
||||
// delete all history items
|
||||
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();
|
||||
PlacesTestUtils.clearHistory().then(aCallback);
|
||||
}
|
||||
|
||||
let testNumber = 0;
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
|
||||
"resource://testing-common/PlacesTestUtils.jsm");
|
||||
|
||||
function whenNewWindowLoaded(aOptions, aCallback) {
|
||||
let win = OpenBrowserWindow(aOptions);
|
||||
let gotLoad = false;
|
||||
|
|
|
@ -19,6 +19,8 @@ Cu.import("resource://gre/modules/ForgetAboutSite.jsm");
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Promise",
|
||||
"resource://gre/modules/Promise.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "PlacesTestUtils",
|
||||
"resource://testing-common/PlacesTestUtils.jsm");
|
||||
|
||||
const COOKIE_EXPIRY = Math.round(Date.now() / 1000) + 60;
|
||||
const COOKIE_NAME = "testcookie";
|
||||
|
@ -414,7 +416,7 @@ function test_history_not_cleared_with_uri_contains_domain()
|
|||
do_check_true(yield promiseIsURIVisited(TEST_URI));
|
||||
|
||||
// Clear history since we left something there from this test.
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
yield PlacesTestUtils.clearHistory();
|
||||
}
|
||||
|
||||
// Cookie Service
|
||||
|
|
|
@ -39,6 +39,7 @@ let os = Cc["@mozilla.org/observer-service;1"]
|
|||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Components.utils.import("resource://testing-common/PlacesTestUtils.jsm");
|
||||
|
||||
let checkDestination = false,
|
||||
checkFileName = false;
|
||||
|
@ -185,7 +186,7 @@ function endTest() {
|
|||
|
||||
Services.prefs.clearUserPref("browser.download.useToolkitUI");
|
||||
|
||||
waitForClearHistory(SimpleTest.finish);
|
||||
PlacesTestUtils.clearHistory().then(SimpleTest.finish);
|
||||
}
|
||||
|
||||
]]>
|
||||
|
|
|
@ -146,15 +146,3 @@ function setCleanState()
|
|||
let win = getDMWindow();
|
||||
if (win) win.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears history invoking callback when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Services.obs.addObserver(function observeClearHistory(aSubject, aTopic) {
|
||||
Services.obs.removeObserver(observeClearHistory, aTopic);
|
||||
aCallback();
|
||||
}, PlacesUtils.TOPIC_EXPIRATION_FINISHED, false);
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче