Bug 551540 followup - Wait for the Organizer window to be closed before proceeding; r=dolske a=orange-fix

This commit is contained in:
Ehsan Akhgari 2010-10-14 15:38:56 -04:00
Родитель ed75b830df
Коммит dd643517ab
2 изменённых файлов: 64 добавлений и 10 удалений

Просмотреть файл

@ -38,6 +38,24 @@
// This test makes sure that the Forget This Site command is hidden for multiple // This test makes sure that the Forget This Site command is hidden for multiple
// selections. // selections.
/**
* 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();
}
function test() { function test() {
// initialization // initialization
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
@ -61,6 +79,7 @@ function test() {
ww.unregisterNotification(observer); ww.unregisterNotification(observer);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow); let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
executeSoon(function() {
// Select History in the left pane. // Select History in the left pane.
organizer.PlacesOrganizer.selectLeftPaneQuery('History'); organizer.PlacesOrganizer.selectLeftPaneQuery('History');
let PO = organizer.PlacesOrganizer; let PO = organizer.PlacesOrganizer;
@ -86,10 +105,19 @@ function test() {
"be hidden with " + selectionCount + " items selected"); "be hidden with " + selectionCount + " items selected");
// Close the context menu // Close the context menu
contextmenu.hidePopup(); contextmenu.hidePopup();
// Wait for the Organizer window to actually be closed
function closeObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowclosed")
return;
ww.unregisterNotification(closeObserver);
SimpleTest.waitForFocus(function() {
// Proceed
funcNext();
});
}
ww.registerNotification(closeObserver);
// Close Library window. // Close Library window.
organizer.close(); organizer.close();
// Proceed
funcNext();
}, false); }, false);
// Get cell coordinates // Get cell coordinates
var x = {}, y = {}, width = {}, height = {}; var x = {}, y = {}, width = {}, height = {};
@ -97,6 +125,7 @@ function test() {
x, y, width, height); x, y, width, height);
// Initiate a context menu for the selected cell // Initiate a context menu for the selected cell
EventUtils.synthesizeMouse(tree.body, x + 4, y + 4, {type: "contextmenu"}, organizer); EventUtils.synthesizeMouse(tree.body, x + 4, y + 4, {type: "contextmenu"}, organizer);
});
}, organizer); }, organizer);
} }
@ -111,9 +140,7 @@ function test() {
testForgetThisSiteVisibility(1, function() { testForgetThisSiteVisibility(1, function() {
testForgetThisSiteVisibility(2, function() { testForgetThisSiteVisibility(2, function() {
// Cleanup // Cleanup
history.QueryInterface(Ci.nsIBrowserHistory) waitForClearHistory(finish);
.removeAllPages();
finish();
}); });
}); });
} }

Просмотреть файл

@ -38,6 +38,24 @@
// This test makes sure that the Forget This Site command is hidden in private // This test makes sure that the Forget This Site command is hidden in private
// browsing mode. // browsing mode.
/**
* 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();
}
function test() { function test() {
// initialization // initialization
let pb = Cc["@mozilla.org/privatebrowsing;1"]. let pb = Cc["@mozilla.org/privatebrowsing;1"].
@ -60,6 +78,7 @@ function test() {
Services.ww.unregisterNotification(observer); Services.ww.unregisterNotification(observer);
let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow); let organizer = aSubject.QueryInterface(Ci.nsIDOMWindow);
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
executeSoon(function() {
// Select History in the left pane. // Select History in the left pane.
let PO = organizer.PlacesOrganizer; let PO = organizer.PlacesOrganizer;
PO.selectLeftPaneQuery('History'); PO.selectLeftPaneQuery('History');
@ -85,10 +104,19 @@ function test() {
"The Forget This Site command should " + (expected ? "not " : "") + "be disabled"); "The Forget This Site command should " + (expected ? "not " : "") + "be disabled");
// Close the context menu // Close the context menu
contextmenu.hidePopup(); contextmenu.hidePopup();
// Wait for the Organizer window to actually be closed
function closeObserver(aSubject, aTopic, aData) {
if (aTopic != "domwindowclosed")
return;
Services.ww.unregisterNotification(closeObserver);
SimpleTest.waitForFocus(function() {
// Proceed
funcNext();
});
}
Services.ww.registerNotification(closeObserver);
// Close Library window. // Close Library window.
organizer.close(); organizer.close();
// Proceed
funcNext();
}, false); }, false);
// Get cell coordinates // Get cell coordinates
var x = {}, y = {}, width = {}, height = {}; var x = {}, y = {}, width = {}, height = {};
@ -96,6 +124,7 @@ function test() {
x, y, width, height); x, y, width, height);
// Initiate a context menu for the selected cell // Initiate a context menu for the selected cell
EventUtils.synthesizeMouse(tree.body, x + 4, y + 4, {type: "contextmenu"}, organizer); EventUtils.synthesizeMouse(tree.body, x + 4, y + 4, {type: "contextmenu"}, organizer);
});
}, organizer); }, organizer);
} }
@ -115,9 +144,7 @@ function test() {
pb.privateBrowsingEnabled = false; pb.privateBrowsingEnabled = false;
testForgetThisSiteVisibility(true, function() { testForgetThisSiteVisibility(true, function() {
// Cleanup // Cleanup
history.QueryInterface(Ci.nsIBrowserHistory) waitForClearHistory(finish);
.removeAllPages();
finish();
}); });
}); });
}); });