зеркало из https://github.com/mozilla/pjs.git
Bug 425753 - Send notification when download manager finishes building the list. r=sdwilsh, a1.9=beltzner
This commit is contained in:
Родитель
2201b03a49
Коммит
0b594cd8f4
|
@ -1096,8 +1096,14 @@ function buildDownloadList(aForceBuild)
|
|||
function stepListBuilder(aNumItems) {
|
||||
try {
|
||||
// If we're done adding all items, we can quit
|
||||
if (!gStmt.executeStep())
|
||||
if (!gStmt.executeStep()) {
|
||||
// Send a notification that we finished
|
||||
Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService).
|
||||
notifyObservers(window, "download-manager-ui-done", null);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to get the attribute values from the statement
|
||||
let attrs = {
|
||||
|
|
|
@ -56,6 +56,7 @@ _BROWSER_FILES = \
|
|||
browser_bug_413093.js \
|
||||
browser_bug_413985.js \
|
||||
browser_bug_416303.js \
|
||||
browser_multiword_search.js \
|
||||
$(NULL)
|
||||
|
||||
ifneq (,$(filter cocoa, $(MOZ_WIDGET_TOOLKIT)))
|
||||
|
@ -67,7 +68,6 @@ endif
|
|||
ifneq ($(OS_ARCH), WINNT)
|
||||
_BROWSER_FILES += \
|
||||
browser_cleanup_search.js \
|
||||
browser_multiword_search.js \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ function test()
|
|||
"INSERT INTO moz_downloads (name, target, source, state, endTime, maxBytes) " +
|
||||
"VALUES (?1, ?2, ?3, ?4, ?5, ?6)");
|
||||
|
||||
try {
|
||||
for each (let site in ["ed.agadak.net", "mozilla.org"]) {
|
||||
stmt.bindStringParameter(0, "Super Pimped Download");
|
||||
stmt.bindStringParameter(1, "file://dummy/file");
|
||||
|
@ -64,8 +65,10 @@ function test()
|
|||
// Add it!
|
||||
stmt.execute();
|
||||
}
|
||||
|
||||
} finally {
|
||||
stmt.reset();
|
||||
stmt.finalize();
|
||||
}
|
||||
|
||||
// Close the UI if necessary
|
||||
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
|
||||
|
@ -73,67 +76,54 @@ function test()
|
|||
let win = wm.getMostRecentWindow("Download:Manager");
|
||||
if (win) win.close();
|
||||
|
||||
// Start the test when the download manager window loads
|
||||
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Ci.nsIWindowWatcher);
|
||||
ww.registerNotification({
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
ww.unregisterNotification(this);
|
||||
aSubject.QueryInterface(Ci.nsIDOMEventTarget).
|
||||
addEventListener("DOMContentLoaded", doTest, false);
|
||||
}
|
||||
});
|
||||
let obs = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
const DLMGR_UI_DONE = "download-manager-ui-done";
|
||||
|
||||
let testPhase = 0;
|
||||
let testObs = {
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
if (aTopic != DLMGR_UI_DONE)
|
||||
return;
|
||||
|
||||
// Let the Startup method of the download manager UI finish before we test
|
||||
let doTest = function() setTimeout(function() {
|
||||
win = wm.getMostRecentWindow("Download:Manager");
|
||||
let $ = function(id) win.document.getElementById(id);
|
||||
|
||||
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
|
||||
let $ = function(aId) win.document.getElementById(aId);
|
||||
let downloadView = $("downloadView");
|
||||
let searchbox = $("searchbox");
|
||||
|
||||
// Try again if selectedIndex is -1
|
||||
if (downloadView.selectedIndex)
|
||||
return doTest();
|
||||
let search = function(aTerms) {
|
||||
searchbox.value = aTerms;
|
||||
searchbox.doCommand();
|
||||
};
|
||||
|
||||
// The list must have built, so figure out what test to do
|
||||
switch (testPhase) {
|
||||
switch (testPhase++) {
|
||||
case 0:
|
||||
// Search for multiple words in any order in all places
|
||||
searchbox.value = "download super pimped 104 GB august 2";
|
||||
searchbox.doCommand();
|
||||
search("download super pimped 104 GB august 2");
|
||||
|
||||
// Next phase eventually checks for two downloads
|
||||
testPhase++;
|
||||
return doTest();
|
||||
break;
|
||||
case 1:
|
||||
// List is being populated
|
||||
ok(downloadView.itemCount > 0, "Search found something");
|
||||
|
||||
// Actually check for the two downloads
|
||||
testPhase++;
|
||||
return doTest();
|
||||
case 2:
|
||||
// Done populating the two items
|
||||
ok(downloadView.itemCount == 2, "Search matched both downloads");
|
||||
|
||||
// Do partial word matches including the site
|
||||
searchbox.value = "agadak aug 2 downl 104";
|
||||
searchbox.doCommand();
|
||||
search("agadak aug 2 downl 104");
|
||||
|
||||
// Next phase checks for a single item
|
||||
testPhase++;
|
||||
return doTest();
|
||||
case 3:
|
||||
break;
|
||||
case 2:
|
||||
// Done populating the one result
|
||||
ok(downloadView.itemCount == 1, "Found the single download");
|
||||
|
||||
// We're done!
|
||||
return finish();
|
||||
obs.removeObserver(testObs, DLMGR_UI_DONE);
|
||||
finish();
|
||||
|
||||
break;
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
};
|
||||
obs.addObserver(testObs, DLMGR_UI_DONE, false);
|
||||
|
||||
// Show the Download Manager UI
|
||||
Cc["@mozilla.org/download-manager-ui;1"].
|
||||
|
|
Загрузка…
Ссылка в новой задаче