Tests that don't depend on the browser should be chrome tests
r=Mardak

--HG--
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_411172_mac.js => toolkit/mozapps/downloads/tests/chrome/test_backspace_key_removes.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_basic_functionality.js => toolkit/mozapps/downloads/tests/chrome/test_basic_functionality.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_429247.js => toolkit/mozapps/downloads/tests/chrome/test_bug_429247.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_cleanup_search.js => toolkit/mozapps/downloads/tests/chrome/test_cleanup_search.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_411172.js => toolkit/mozapps/downloads/tests/chrome/test_delete_key_removes.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_416303.js => toolkit/mozapps/downloads/tests/chrome/test_esc_key_closes_clears.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_multi_select.js => toolkit/mozapps/downloads/tests/chrome/test_multi_select.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_multiword_search.js => toolkit/mozapps/downloads/tests/chrome/test_multiword_search.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_410289.js => toolkit/mozapps/downloads/tests/chrome/test_pause_button_state.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_394039.js => toolkit/mozapps/downloads/tests/chrome/test_removeDownload_updates_ui.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_413093.js => toolkit/mozapps/downloads/tests/chrome/test_retention_is_0_closes.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_search_clearlist.js => toolkit/mozapps/downloads/tests/chrome/test_search_clearlist.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_select_all.js => toolkit/mozapps/downloads/tests/chrome/test_select_all.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_413985.js => toolkit/mozapps/downloads/tests/chrome/test_space_key_pauses_resumes.xul
rename : toolkit/mozapps/downloads/tests/browser/browser_bug_397935.js => toolkit/mozapps/downloads/tests/chrome/test_ui_stays_open_on_alert_clickback.xul
This commit is contained in:
Shawn Wilsher ext:(%2C%20Edward%20Lee%20%3Cedward.lee%40engineering.uiuc.edu%3E) 2008-06-11 11:06:39 -04:00
Родитель faddef0df3
Коммит 74931b7648
19 изменённых файлов: 981 добавлений и 408 удалений

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

@ -50,5 +50,6 @@ XPCSHELL_TESTS = \
$(NULL)
DIRS += browser
DIRS += chrome
include $(topsrcdir)/config/rules.mk

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

@ -46,29 +46,9 @@ include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_BROWSER_FILES = \
browser_basic_functionality.js \
browser_bug_394039.js \
browser_bug_397935.js \
browser_bug_406857.js \
browser_bug_410289.js \
browser_bug_411172.js \
browser_bug_412360.js \
browser_bug_413093.js \
browser_bug_413985.js \
browser_bug_416303.js \
browser_bug_429247.js \
browser_cleanup_search.js \
browser_multi_select.js \
browser_multiword_search.js \
browser_search_clearlist.js \
browser_select_all.js \
$(NULL)
ifneq (,$(filter cocoa, $(MOZ_WIDGET_TOOLKIT)))
_BROWSER_FILES += \
browser_bug_411172_mac.js \
$(NULL)
endif
libs:: $(_BROWSER_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/browser/$(relativesrcdir)

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

@ -1,87 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Download Manager UI Test Code.
*
* The Initial Developer of the Original Code is
* Edward Lee <edward.lee@engineering.uiuc.edu>.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test()
{
// Close the UI if necessary
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
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 the Startup method of the download manager UI finish before we test
let doTest = function() setTimeout(function() {
win = wm.getMostRecentWindow("Download:Manager");
// Put in a value to clear out
let search = win.document.getElementById("searchbox");
search.focus();
search.value = "download manager escape test";
// Send the escape key to the download manager UI window
let sendEscape = function() EventUtils.synthesizeKey("VK_ESCAPE", {}, win);
// Escape from search box
sendEscape();
is(win.closed, false,
"Escape doesn't close the window when in the search box");
is(search.value, "", "Escape correctly emptied the search box");
// Escape from list (escape from search box moves focus to list)
sendEscape();
is(win.closed, true,
"Previous escape moved focus to list and now escape closed the window");
finish();
}, 0);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
}

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

@ -0,0 +1,73 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Mozilla code.
#
# The Initial Developer of the Original Code is
# Mozilla Corporation.
# Portions created by the Initial Developer are Copyright (C) 2008
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Shawn Wilsher <me@shawnwilsher.com> (Original Author)
# Edward Lee <edward.lee@engineering.uiuc.edu>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = toolkit/mozapps/downloads/tests/chrome
include $(DEPTH)/config/autoconf.mk
include $(topsrcdir)/config/rules.mk
_CHROME_FILES = \
test_basic_functionality.xul \
test_cleanup_search.xul \
test_delete_key_removes.xul \
test_esc_key_closes_clears.xul \
test_multi_select.xul \
test_multiword_search.xul \
test_pause_button_state.xul \
test_removeDownload_updates_ui.xul \
test_retention_is_0_closes.xul \
test_search_clearlist.xul \
test_select_all.xul \
test_space_key_pauses_resumes.xul \
test_ui_stays_open_on_alert_clickback.xul \
test_bug_429247.xul \
$(NULL)
ifneq (,$(filter cocoa, $(MOZ_WIDGET_TOOLKIT)))
_CHROME_FILES += \
test_backspace_key_removes.xul \
$(NULL)
endif
libs:: $(_CHROME_FILES)
$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/chrome/$(relativesrcdir)

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,33 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* This test ensures that the delete key removes a download. This was added by
* bug 411172.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var dmFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
@ -88,35 +114,6 @@ const DownloadData = [
currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
];
function test_backspaceKeyRemoves(aWin)
{
// This also tests the ordering of the display
var doc = aWin.document;
var dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
var db = dm.DBConnection;
var stmt = db.createStatement("SELECT COUNT(*) FROM moz_downloads");
stmt.executeStep();
var richlistbox = doc.getElementById("downloadView");
is(stmt.getInt32(0), richlistbox.children.length,
"The database and the number of downloads display matches");
stmt.reset();
var len = DownloadData.length;
for (var i = 0; i < len; i++) {
EventUtils.synthesizeKey("VK_BACK_SPACE", {}, aWin);
stmt.executeStep();
is(stmt.getInt32(0), len - (i + 1),
"The download was properly removed");
stmt.reset();
}
}
var testFuncs = [
test_backspaceKeyRemoves
];
function test()
{
@ -137,7 +134,7 @@ function test()
for each (var dl in DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();
}
stmt.statement.finalize();
@ -149,24 +146,65 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let doc = win.document;
let stmt = db.createStatement("SELECT COUNT(*) FROM moz_downloads");
try {
stmt.executeStep();
let richlistbox = doc.getElementById("downloadView");
is(stmt.getInt32(0), richlistbox.children.length,
"The database and the number of downloads display matches");
stmt.reset();
let len = DownloadData.length;
for (let i = 0; i < len; i++) {
synthesizeKey("VK_BACK_SPACE", {}, win);
stmt.executeStep();
is(stmt.getInt32(0), len - (i + 1),
"The download was properly removed");
stmt.reset();
}
}
finally {
stmt.reset();
stmt.finalize();
}
win.close();
dmFile.remove(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
};
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
finish();
}
waitForExplicitFinish();
// We also need to allow enough time for the DM to build up the whole list
window.setTimeout(finishUp, 3000);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,32 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* Make sure the download manager can display downloads in the right order and
* contains the expected data. The list has one of each download state ordered
* by the start/end times.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var dmFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
@ -175,7 +200,7 @@ function test()
for each (var dl in DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();
}
stmt.statement.finalize();
@ -187,24 +212,45 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
// Now we can run our tests
for each (let t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
};
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
finish();
}
waitForExplicitFinish();
// We also need to allow enough time for the DM to build up the whole list
window.setTimeout(finishUp, 3000);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -19,7 +21,7 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Nochum Sossonko <nsossonko@hotmail.com>
* Nochum Sossonko <nsossonko@hotmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -37,9 +39,27 @@
/**
* Test bug 429247 to make sure clicking on whitespace in the Download
* Manager doesn't run the default action on the selected download.
* Manager doesn't run the default action on the selected download.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -49,8 +69,8 @@ function test()
dmFile.append("dm-ui-test.file");
dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666);
let gTestPath = ios.newFileURI(dmFile).spec;
//data to populate the download manager with
// Data to populate the download manager with
const DownloadData = {
name: "381603.patch",
source: "https://bugzilla.mozilla.org/attachment.cgi?id=266520",
@ -78,12 +98,9 @@ function test()
stmt.initialize(rawStmt);
for (let prop in DownloadData)
stmt.params[prop] = DownloadData[prop];
stmt.execute();
stmt.statement.finalize();
stmt.execute();
stmt.statement.finalize();
// Close the UI if necessary
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
@ -95,7 +112,6 @@ function test()
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)
@ -104,8 +120,7 @@ function test()
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let $ = function(aId) win.document.getElementById(aId);
let downloadView = $("downloadView");
// Default test/check for invocations
let invokeCount = 0;
let counter = function() invokeCount++;
@ -117,22 +132,20 @@ function test()
// All the expected results
let allExpected = [0, "The default action was not performed"];
// Select the first download
downloadView.selectedIndex = 0;
let [func, test, value] = defaultForSelectedTest;
// Make a copy of the original function and replace it with a test
let copy = win[func];
win[func] = test;
// Get the offsetY of the whitespace under the download
let downloadItem = downloadView.getItemAtIndex(0);
let downloadItem = downloadView.getItemAtIndex(0);
let boxOffset = downloadItem.boxObject.height + 1;
//The last download in the download manager + 1 is whitespace
EventUtils.synthesizeMouse(downloadItem, 0, boxOffset, {clickCount: 2}, win);
// The last download in the download manager + 1 is whitespace
synthesizeMouse(downloadItem, 0, boxOffset, {clickCount: 2}, win);
// Make sure the value is as expected
let [correct, message] = allExpected;
@ -143,15 +156,26 @@ function test()
win[func] = copy;
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
}
};
obs.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -41,6 +43,23 @@
* Test bug 430486 to make sure the Clear list button is disabled only when
* there are no download items visible.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -135,8 +154,9 @@ function test()
is(clearList.disabled, true, "Clear list is disabled for no items");
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
break;
}
@ -148,5 +168,15 @@ function test()
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,33 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* This test ensures that the delete key removes a download. This was added by
* bug 411172.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var dmFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
@ -88,35 +114,6 @@ const DownloadData = [
currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
];
function test_deleteKeyRemoves(aWin)
{
// This also tests the ordering of the display
var doc = aWin.document;
var dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
var db = dm.DBConnection;
var stmt = db.createStatement("SELECT COUNT(*) FROM moz_downloads");
stmt.executeStep();
var richlistbox = doc.getElementById("downloadView");
is(stmt.getInt32(0), richlistbox.children.length,
"The database and the number of downloads display matches");
stmt.reset();
var len = DownloadData.length;
for (var i = 0; i < len; i++) {
EventUtils.synthesizeKey("VK_DELETE", {}, aWin);
stmt.executeStep();
is(stmt.getInt32(0), len - (i + 1),
"The download was properly removed");
stmt.reset();
}
}
var testFuncs = [
test_deleteKeyRemoves
];
function test()
{
@ -137,7 +134,7 @@ function test()
for each (var dl in DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();
}
stmt.statement.finalize();
@ -149,24 +146,65 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let doc = win.document;
let stmt = db.createStatement("SELECT COUNT(*) FROM moz_downloads");
try {
stmt.executeStep();
let richlistbox = doc.getElementById("downloadView");
is(stmt.getInt32(0), richlistbox.children.length,
"The database and the number of downloads display matches");
stmt.reset();
let len = DownloadData.length;
for (let i = 0; i < len; i++) {
synthesizeKey("VK_DELETE", {}, win);
stmt.executeStep();
is(stmt.getInt32(0), len - (i + 1),
"The download was properly removed");
stmt.reset();
}
}
finally {
stmt.reset();
stmt.finalize();
}
win.close();
dmFile.remove(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
};
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
finish();
}
waitForExplicitFinish();
// We also need to allow enough time for the DM to build up the whole list
window.setTimeout(finishUp, 3000);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -0,0 +1,125 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Download Manager UI Test Code.
*
* The Initial Developer of the Original Code is
* Edward Lee <edward.lee@engineering.uiuc.edu>.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* This test ensures that the escape key closes the download manager. This test
* was added in bug 416303.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
// Close the UI if necessary
let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("Download:Manager");
if (win) win.close();
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
// Put in a value to clear out
let search = win.document.getElementById("searchbox");
search.focus();
search.value = "download manager escape test";
// Send the escape key to the download manager UI window
let sendEscape = function() synthesizeKey("VK_ESCAPE", {}, win);
// Escape from search box
sendEscape();
is(win.closed, false,
"Escape doesn't close the window when in the search box");
is(search.value, "", "Escape correctly emptied the search box");
// Escape from list (escape from search box moves focus to list)
sendEscape();
is(win.closed, true,
"Previous escape moved focus to list and now escape closed the window");
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
};
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -39,6 +41,25 @@
* manager by making sure commands work as expected for both single and doubly
* selected items.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -169,7 +190,7 @@ function test()
// Select 2 downloads for double
if (whichTest == "double")
EventUtils.synthesizeKey("VK_DOWN", { shiftKey: true }, win);
synthesizeKey("VK_DOWN", { shiftKey: true }, win);
for each (let [command, func, test, value] in commandTests) {
// Make a copy of the original function and replace it with a test
@ -190,8 +211,9 @@ function test()
}
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
}
};
obs.addObserver(testObs, DLMGR_UI_DONE, false);
@ -200,5 +222,15 @@ function test()
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -39,6 +41,23 @@
* search against the download name, source/referrer, date/time, file size,
* etc.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -123,8 +142,9 @@ function test()
ok(downloadView.itemCount == 1, "Found the single download");
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
break;
}
@ -136,5 +156,15 @@ function test()
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,31 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* This tests bug 410289. Specifically, it tests that the pause button is
* active for resumable downloads, and inactive for non-resumable ones.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var dmFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
@ -61,43 +85,6 @@ const DownloadData = [
currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
];
function test_pauseButtonCorrect(aWin)
{
// This also tests the ordering of the display
var doc = aWin.document;
var dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
var richlistbox = doc.getElementById("downloadView");
for (var i = 0; i < DownloadData.length; i++) {
var dl = richlistbox.children[i];
var buttons = dl.buttons;
for (var j = 0; j < buttons.length; j++) {
var button = buttons[j];
if ("cmd_pause" == button.getAttribute("cmd")) {
var id = dl.getAttribute("dlid");
// check if it should be disabled or not
var resumable = dm.getDownload(id).resumable;
is(DownloadData[i].entityID ? true : false, resumable,
"Pause button is properly disabled");
// also check if tooltip text was updated
if (!resumable) {
var sb = doc.getElementById("downloadStrings");
is(button.getAttribute("tooltiptext"), sb.getString("cannotPause"),
"Pause button has proper text");
}
}
}
}
}
var testFuncs = [
test_pauseButtonCorrect
];
function test()
{
var dm = Cc["@mozilla.org/download-manager;1"].
@ -117,7 +104,7 @@ function test()
for each (var dl in DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();
}
stmt.statement.finalize();
@ -129,24 +116,66 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let doc = win.document;
let richlistbox = doc.getElementById("downloadView");
for (let i = 0; i < DownloadData.length; i++) {
let dl = richlistbox.children[i];
let buttons = dl.buttons;
for (let j = 0; j < buttons.length; j++) {
let button = buttons[j];
if ("cmd_pause" == button.getAttribute("cmd")) {
let id = dl.getAttribute("dlid");
// check if it should be disabled or not
let resumable = dm.getDownload(id).resumable;
is(DownloadData[i].entityID ? true : false, resumable,
"Pause button is properly disabled");
// also check if tooltip text was updated
if (!resumable) {
let sb = doc.getElementById("downloadStrings");
is(button.getAttribute("tooltiptext"), sb.getString("cannotPause"),
"Pause button has proper text");
}
}
}
}
win.close();
dmFile.remove(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
}
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
finish();
}
waitForExplicitFinish();
// We also need to allow enough time for the DM to build up the whole list
window.setTimeout(finishUp, 2000);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,30 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* Test bug 394039 to make sure calling removeDownload of the
* nsIDownloadManager service correctly updates the download window.
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
var dmFile = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile);
@ -52,30 +75,6 @@ const DownloadData = [
currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 }
];
function test_removeDownloadRemoves(aWin)
{
// This also tests the ordering of the display
var doc = aWin.document;
var dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
var db = dm.DBConnection;
var stmt = db.createStatement("SELECT id FROM moz_downloads");
stmt.executeStep();
var id = stmt.getInt64(0);
stmt.reset();
stmt.finalize();
dm.removeDownload(id);
var richlistbox = doc.getElementById("downloadView");
is(richlistbox.children.length, 0,
"The download was properly removed");
}
var testFuncs = [
test_removeDownloadRemoves
];
function test()
{
var dm = Cc["@mozilla.org/download-manager;1"].
@ -95,7 +94,7 @@ function test()
for each (var dl in DownloadData) {
for (var prop in dl)
stmt.params[prop] = dl[prop];
stmt.execute();
}
stmt.statement.finalize();
@ -107,24 +106,59 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let doc = win.document;
// Note: This also tests the ordering of the display
let stmt = db.createStatement("SELECT id FROM moz_downloads");
let id = -1;
try {
stmt.executeStep();
id = stmt.getInt64(0);
}
finally {
stmt.reset();
stmt.finalize();
}
dm.removeDownload(id);
let richlistbox = doc.getElementById("downloadView");
is(richlistbox.children.length, 0,
"The download was properly removed");
win.close();
dmFile.remove(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
}
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
// Now we can run our tests
for each (var t in testFuncs)
t(win);
win.close();
dmFile.remove(false);
finish();
}
waitForExplicitFinish();
// We also need to allow enough time for the DM to build up the whole list
window.setTimeout(finishUp, 3000);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -33,9 +35,32 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* This tests that the download manager UI closes upon download completion when
* browser.download.manager.retention is set to 0. This test was added in bug
* 413093.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function bug413093obs()
{
this.mDownload = null;
@ -58,7 +83,7 @@ bug413093obs.prototype = {
}
dump("domwindowopened callback - resuming download\n");
// Resume the download now that UI is up and running
let dm = Cc["@mozilla.org/download-manager;1"].
getService(Ci.nsIDownloadManager);
@ -70,7 +95,7 @@ bug413093obs.prototype = {
getService(Ci.nsIDownloadManagerUI);
ok(!dmui.visible, "Download Manager UI is not showing");
finish();
SimpleTest.finish();
}
},
@ -170,5 +195,15 @@ function test()
addDownload();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,6 +40,23 @@
* Test bug 431188 to make sure the Clear list button is enabled after doing a
* search and finding results.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -131,8 +150,9 @@ function test()
is(clearList.disabled, true, "Clear list is disabled for no items");
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
break;
}
@ -144,5 +164,15 @@ function test()
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -38,6 +40,25 @@
* Test bug 429614 to make sure ctrl/cmd-a work to select all downloads and
* hitting delete removes them all.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -98,16 +119,17 @@ function test()
// Select all downloads
let isMac = navigator.platform.search("Mac") == 0;
EventUtils.synthesizeKey("a", { metaKey: isMac, ctrlKey: !isMac }, win);
synthesizeKey("a", { metaKey: isMac, ctrlKey: !isMac }, win);
is(downloadView.selectedCount, sites.length, "All downloads selected");
// Delete all downloads
EventUtils.synthesizeKey("VK_DELETE", {}, win);
synthesizeKey("VK_DELETE", {}, win);
is(downloadView.itemCount, 0, "All downloads removed");
// We're done!
win.close();
obs.removeObserver(testObs, DLMGR_UI_DONE);
finish();
SimpleTest.finish();
}
};
obs.addObserver(testObs, DLMGR_UI_DONE, false);
@ -116,5 +138,15 @@ function test()
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -5,7 +7,7 @@
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
@ -32,9 +34,33 @@
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
*
* ***** END LICENSE BLOCK ***** */
/**
* This tests that the space key will pause and resume a download in the UI.
* This test was added in bug 413985.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function bug413985obs(aWin)
{
this.mWin = aWin;
@ -46,7 +72,7 @@ bug413985obs.prototype = {
{
if ("timer-callback" == aTopic) {
// dispatch a space keypress to resume the download
EventUtils.synthesizeKey(" ", {}, this.mWin);
synthesizeKey(" ", {}, this.mWin);
}
},
@ -56,7 +82,7 @@ bug413985obs.prototype = {
!this.wasPaused) {
this.wasPaused = true;
// dispatch a space keypress to pause the download
EventUtils.synthesizeKey(" ", {}, this.mWin);
synthesizeKey(" ", {}, this.mWin);
}
if (aDownload.state == Ci.nsIDownloadManager.DOWNLOAD_PAUSED &&
@ -77,7 +103,7 @@ bug413985obs.prototype = {
getService(Ci.nsIDownloadManager);
dm.removeListener(this);
finish();
SimpleTest.finish();
}
},
onStateChange: function(a, b, c, d, e) { },
@ -132,22 +158,43 @@ function test()
if (win)
win.close();
// OK, now that all the data is in, let's pull up the UI
let os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
let doc = win.document;
dm.addListener(new bug413985obs(win));
let dl = addDownload();
// we need to focus the download as well
doc.getElementById("downloadView").selectedIndex = 0;
os.removeObserver(testObs, DLMGR_UI_DONE);
}
};
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Show the Download Manager UI
Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI).show();
// The window doesn't open once we call show, so we need to wait a little bit
function finishUp() {
var win = wm.getMostRecentWindow("Download:Manager");
dm.addListener(new bug413985obs(win));
var dl = addDownload();
// we need to focus the download as well
var doc = win.document;
doc.getElementById("downloadView").selectedIndex = 0;
}
waitForExplicitFinish();
window.setTimeout(finishUp, 500);
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>

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

@ -1,3 +1,5 @@
<?xml version="1.0"?>
<!--
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@ -39,6 +41,23 @@
* it's opened by the user clicking the alert and has the close-when-done pref
* set.
*/
-->
<window title="Download Manager Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script type="application/javascript"
src="chrome://mochikit/content/MochiKit/packed.js"/>
<script type="application/javascript"
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript">
<![CDATA[
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
function test()
{
@ -58,31 +77,48 @@ 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 os = Cc["@mozilla.org/observer-service;1"].
getService(Ci.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
let testObs = {
observe: function(aSubject, aTopic, aData)
{
if (aTopic != DLMGR_UI_DONE)
return;
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
// Note: This test will not be valid if the download list is built
// synchronously in Startup in downloads.js
// Make sure the window stays open
let dmui = Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI);
ok(dmui.visible, "Download Manager stays open on alert click");
win.close();
setClose(false);
os.removeObserver(testObs, DLMGR_UI_DONE);
SimpleTest.finish();
}
});
};
// Let the Startup method of the download manager UI finish before we test
let doTest = function() setTimeout(function() {
// Make sure the window stays open
let dmui = Cc["@mozilla.org/download-manager-ui;1"].
getService(Ci.nsIDownloadManagerUI);
ok(dmui.visible, "Download Manager stays open on alert click");
setClose(false);
finish();
}, 500);
// Register with the observer service
os.addObserver(testObs, DLMGR_UI_DONE, false);
// Simulate an alert click with pref set to true
setClose(true);
dm.QueryInterface(Ci.nsIObserver).observe(null, "alertclickcallback", null);
waitForExplicitFinish();
SimpleTest.waitForExplicitFinish();
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
</body>
</window>