1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/mozapps/downloads/tests/chrome/test_search_keys.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +<?xml version="1.0"?> 1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.6 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.8 +<!-- 1.9 + * Make sure the download manager can display downloads in the right order and 1.10 + * contains the expected data. The list has one of each download state ordered 1.11 + * by the start/end times. 1.12 +--> 1.13 + 1.14 +<window title="Download Manager Test" 1.15 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.16 + onload="test();"> 1.17 + 1.18 + <script type="application/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> 1.20 + <script type="application/javascript" 1.21 + src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> 1.22 + <script type="application/javascript" 1.23 + src="utils.js"/> 1.24 + 1.25 + <script type="application/javascript"> 1.26 + <![CDATA[ 1.27 + 1.28 +function test_meta_k(aWin) 1.29 +{ 1.30 + let doc = aWin.document; 1.31 + let searchbox = doc.getElementById("searchbox"); 1.32 + let richlistbox = doc.getElementById("downloadView"); 1.33 + 1.34 + // Enusre the serachbox is not focused 1.35 + richlistbox.focus(); 1.36 + 1.37 + // Dispatch the right key combination 1.38 + synthesizeKey("k", {accelKey: true}, aWin); 1.39 + 1.40 + ok(searchbox.hasAttribute("focused"), "Searchbox is focused"); 1.41 +} 1.42 + 1.43 +let testFuncs = [ 1.44 + test_meta_k, 1.45 +] 1.46 + 1.47 +function test() 1.48 +{ 1.49 + var dmui = getDMUI(); 1.50 + if (!dmui) { 1.51 + todo(false, "skip test for toolkit download manager UI"); 1.52 + return; 1.53 + } 1.54 + 1.55 + let dm = Cc["@mozilla.org/download-manager;1"]. 1.56 + getService(Ci.nsIDownloadManager); 1.57 + 1.58 + // See if the DM is already open, and if it is, close it! 1.59 + let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. 1.60 + getService(Ci.nsIWindowMediator); 1.61 + let win = wm.getMostRecentWindow("Download:Manager"); 1.62 + if (win) 1.63 + win.close(); 1.64 + 1.65 + let os = Cc["@mozilla.org/observer-service;1"]. 1.66 + getService(Ci.nsIObserverService); 1.67 + const DLMGR_UI_DONE = "download-manager-ui-done"; 1.68 + 1.69 + let testObs = { 1.70 + observe: function(aSubject, aTopic, aData) 1.71 + { 1.72 + if (aTopic != DLMGR_UI_DONE) 1.73 + return; 1.74 + 1.75 + SimpleTest.waitForFocus(function () { continueTest(aSubject) }, aSubject); 1.76 + } 1.77 + }; 1.78 + 1.79 + function continueTest(win) { 1.80 + // Now we can run our tests 1.81 + for each (let t in testFuncs) 1.82 + t(win); 1.83 + 1.84 + win.close(); 1.85 + os.removeObserver(testObs, DLMGR_UI_DONE); 1.86 + SimpleTest.finish(); 1.87 + }; 1.88 + 1.89 + // Register with the observer service 1.90 + os.addObserver(testObs, DLMGR_UI_DONE, false); 1.91 + 1.92 + // Show the Download Manager UI 1.93 + dmui.show(); 1.94 + 1.95 + SimpleTest.waitForExplicitFinish(); 1.96 +} 1.97 + 1.98 + ]]> 1.99 + </script> 1.100 + 1.101 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.102 + <p id="display"></p> 1.103 + <div id="content" style="display:none;"></div> 1.104 + <pre id="test"></pre> 1.105 + </body> 1.106 +</window>