toolkit/mozapps/downloads/tests/chrome/test_search_keys.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 5 <!--
michael@0 6 * Make sure the download manager can display downloads in the right order and
michael@0 7 * contains the expected data. The list has one of each download state ordered
michael@0 8 * by the start/end times.
michael@0 9 -->
michael@0 10
michael@0 11 <window title="Download Manager Test"
michael@0 12 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 13 onload="test();">
michael@0 14
michael@0 15 <script type="application/javascript"
michael@0 16 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
michael@0 17 <script type="application/javascript"
michael@0 18 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/>
michael@0 19 <script type="application/javascript"
michael@0 20 src="utils.js"/>
michael@0 21
michael@0 22 <script type="application/javascript">
michael@0 23 <![CDATA[
michael@0 24
michael@0 25 function test_meta_k(aWin)
michael@0 26 {
michael@0 27 let doc = aWin.document;
michael@0 28 let searchbox = doc.getElementById("searchbox");
michael@0 29 let richlistbox = doc.getElementById("downloadView");
michael@0 30
michael@0 31 // Enusre the serachbox is not focused
michael@0 32 richlistbox.focus();
michael@0 33
michael@0 34 // Dispatch the right key combination
michael@0 35 synthesizeKey("k", {accelKey: true}, aWin);
michael@0 36
michael@0 37 ok(searchbox.hasAttribute("focused"), "Searchbox is focused");
michael@0 38 }
michael@0 39
michael@0 40 let testFuncs = [
michael@0 41 test_meta_k,
michael@0 42 ]
michael@0 43
michael@0 44 function test()
michael@0 45 {
michael@0 46 var dmui = getDMUI();
michael@0 47 if (!dmui) {
michael@0 48 todo(false, "skip test for toolkit download manager UI");
michael@0 49 return;
michael@0 50 }
michael@0 51
michael@0 52 let dm = Cc["@mozilla.org/download-manager;1"].
michael@0 53 getService(Ci.nsIDownloadManager);
michael@0 54
michael@0 55 // See if the DM is already open, and if it is, close it!
michael@0 56 let wm = Cc["@mozilla.org/appshell/window-mediator;1"].
michael@0 57 getService(Ci.nsIWindowMediator);
michael@0 58 let win = wm.getMostRecentWindow("Download:Manager");
michael@0 59 if (win)
michael@0 60 win.close();
michael@0 61
michael@0 62 let os = Cc["@mozilla.org/observer-service;1"].
michael@0 63 getService(Ci.nsIObserverService);
michael@0 64 const DLMGR_UI_DONE = "download-manager-ui-done";
michael@0 65
michael@0 66 let testObs = {
michael@0 67 observe: function(aSubject, aTopic, aData)
michael@0 68 {
michael@0 69 if (aTopic != DLMGR_UI_DONE)
michael@0 70 return;
michael@0 71
michael@0 72 SimpleTest.waitForFocus(function () { continueTest(aSubject) }, aSubject);
michael@0 73 }
michael@0 74 };
michael@0 75
michael@0 76 function continueTest(win) {
michael@0 77 // Now we can run our tests
michael@0 78 for each (let t in testFuncs)
michael@0 79 t(win);
michael@0 80
michael@0 81 win.close();
michael@0 82 os.removeObserver(testObs, DLMGR_UI_DONE);
michael@0 83 SimpleTest.finish();
michael@0 84 };
michael@0 85
michael@0 86 // Register with the observer service
michael@0 87 os.addObserver(testObs, DLMGR_UI_DONE, false);
michael@0 88
michael@0 89 // Show the Download Manager UI
michael@0 90 dmui.show();
michael@0 91
michael@0 92 SimpleTest.waitForExplicitFinish();
michael@0 93 }
michael@0 94
michael@0 95 ]]>
michael@0 96 </script>
michael@0 97
michael@0 98 <body xmlns="http://www.w3.org/1999/xhtml">
michael@0 99 <p id="display"></p>
michael@0 100 <div id="content" style="display:none;"></div>
michael@0 101 <pre id="test"></pre>
michael@0 102 </body>
michael@0 103 </window>

mercurial