mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Places chrome tests should wait for clear history.
This commit is contained in:
parent
26deafd4c5
commit
c23d3d5740
@ -45,13 +45,15 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
// The mochitest page is added to history.
|
||||
waitForClearHistory(continue_test);
|
||||
}
|
||||
|
||||
function continue_test() {
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Cleanup.
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
|
||||
// Add some visits.
|
||||
let vtime = Date.now() * 1000;
|
||||
const ttype = PlacesUtils.history.TRANSITION_TYPED;
|
||||
@ -76,8 +78,13 @@
|
||||
|
||||
// loop through the rows and check formatting
|
||||
let treeView = tree.view;
|
||||
for (let i = 0; i < rc; i++) {
|
||||
selection.select(rc);
|
||||
let node = tree.selectedNode;
|
||||
ok(true, "found " + node.title);
|
||||
}
|
||||
let rc = treeView.rowCount;
|
||||
ok(rc == 3, "Rows found.");
|
||||
is(rc, 3, "Rows found.");
|
||||
let selection = treeView.selection;
|
||||
for (let i = 0; i < rc; i++) {
|
||||
selection.select(0);
|
||||
@ -89,10 +96,25 @@
|
||||
}
|
||||
|
||||
// Cleanup.
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
|
||||
SimpleTest.finish();
|
||||
waitForClearHistory(SimpleTest.finish);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears history invoking callback when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
|
||||
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
|
||||
}
|
||||
|
||||
]]></script>
|
||||
</window>
|
||||
|
@ -48,11 +48,14 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
// The mochitest page is added to history.
|
||||
waitForClearHistory(continue_test);
|
||||
}
|
||||
|
||||
function continue_test() {
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
PlacesUtils.history
|
||||
.addVisit(Services.io.newURI("http://example.tld/", null, null),
|
||||
Date.now() * 1000, null, PlacesUtils.history.TRANSITION_TYPED, false, 0);
|
||||
@ -73,10 +76,25 @@
|
||||
ok(true, "No exceptions thrown");
|
||||
|
||||
// Cleanup.
|
||||
PlacesUtils.bhistory.removeAllPages();
|
||||
|
||||
SimpleTest.finish();
|
||||
waitForClearHistory(SimpleTest.finish);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears history invoking callback when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
|
||||
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
|
||||
}
|
||||
|
||||
]]></script>
|
||||
</window>
|
||||
|
@ -86,6 +86,11 @@
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function runTest() {
|
||||
// The mochitest page is added to history.
|
||||
waitForClearHistory(continue_test);
|
||||
}
|
||||
|
||||
function continue_test() {
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
@ -109,9 +114,6 @@
|
||||
midnight.setSeconds(0);
|
||||
midnight.setMilliseconds(0);
|
||||
|
||||
// Cleanup.
|
||||
bh.removeAllPages();
|
||||
|
||||
// Add a visit 1ms before midnight.
|
||||
hs.addVisit(uri("http://before.midnight.com/"),
|
||||
(midnight.getTime() - 1) * 1000,
|
||||
@ -196,11 +198,26 @@
|
||||
}
|
||||
// Cleanup.
|
||||
bs.removeItem(itemId);
|
||||
bh.removeAllPages();
|
||||
|
||||
SimpleTest.finish();
|
||||
waitForClearHistory(SimpleTest.finish);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears history invoking callback when done.
|
||||
*/
|
||||
function waitForClearHistory(aCallback) {
|
||||
const TOPIC_EXPIRATION_FINISHED = "places-expiration-finished";
|
||||
let observer = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, TOPIC_EXPIRATION_FINISHED);
|
||||
aCallback();
|
||||
}
|
||||
};
|
||||
Services.obs.addObserver(observer, TOPIC_EXPIRATION_FINISHED, false);
|
||||
let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
|
||||
getService(Ci.nsINavHistoryService);
|
||||
hs.QueryInterface(Ci.nsIBrowserHistory).removeAllPages();
|
||||
}
|
||||
|
||||
]]>
|
||||
</script>
|
||||
</window>
|
||||
|
Loading…
Reference in New Issue
Block a user