Wed, 31 Dec 2014 06:09:35 +0100
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 | * This test ensures that the escape key closes the download manager. This test |
michael@0 | 7 | * was added in bug 416303. |
michael@0 | 8 | --> |
michael@0 | 9 | |
michael@0 | 10 | <window title="Download Manager Test" |
michael@0 | 11 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 12 | onload="test();"> |
michael@0 | 13 | |
michael@0 | 14 | <script type="application/javascript" |
michael@0 | 15 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 16 | <script type="application/javascript" |
michael@0 | 17 | src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="utils.js"/> |
michael@0 | 20 | |
michael@0 | 21 | <script type="application/javascript"> |
michael@0 | 22 | <![CDATA[ |
michael@0 | 23 | |
michael@0 | 24 | const DLMGR_UI_DONE = "download-manager-ui-done"; |
michael@0 | 25 | |
michael@0 | 26 | let os = Cc["@mozilla.org/observer-service;1"]. |
michael@0 | 27 | getService(Ci.nsIObserverService); |
michael@0 | 28 | |
michael@0 | 29 | function test() |
michael@0 | 30 | { |
michael@0 | 31 | var dmui = getDMUI(); |
michael@0 | 32 | if (!dmui) { |
michael@0 | 33 | todo(false, "skip test for toolkit download manager UI"); |
michael@0 | 34 | return; |
michael@0 | 35 | } |
michael@0 | 36 | |
michael@0 | 37 | // Close the UI if necessary |
michael@0 | 38 | let wm = Cc["@mozilla.org/appshell/window-mediator;1"]. |
michael@0 | 39 | getService(Ci.nsIWindowMediator); |
michael@0 | 40 | let win = wm.getMostRecentWindow("Download:Manager"); |
michael@0 | 41 | if (win) win.close(); |
michael@0 | 42 | |
michael@0 | 43 | // Register with the observer service |
michael@0 | 44 | os.addObserver(testObs, DLMGR_UI_DONE, false); |
michael@0 | 45 | |
michael@0 | 46 | // Show the Download Manager UI |
michael@0 | 47 | dmui.show(); |
michael@0 | 48 | |
michael@0 | 49 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | let testObs = { |
michael@0 | 53 | observe: function(aSubject, aTopic, aData) |
michael@0 | 54 | { |
michael@0 | 55 | if (aTopic != DLMGR_UI_DONE) |
michael@0 | 56 | return; |
michael@0 | 57 | |
michael@0 | 58 | SimpleTest.waitForFocus(function () { continueTest(aSubject) }, aSubject); |
michael@0 | 59 | } |
michael@0 | 60 | }; |
michael@0 | 61 | |
michael@0 | 62 | function continueTest(win) |
michael@0 | 63 | { |
michael@0 | 64 | // Put in a value to clear out |
michael@0 | 65 | let search = win.document.getElementById("searchbox"); |
michael@0 | 66 | search.focus(); |
michael@0 | 67 | search.value = "download manager escape test"; |
michael@0 | 68 | |
michael@0 | 69 | // Send the escape key to the download manager UI window |
michael@0 | 70 | let sendEscape = function() synthesizeKey("VK_ESCAPE", {}, win); |
michael@0 | 71 | |
michael@0 | 72 | // Escape from search box |
michael@0 | 73 | sendEscape(); |
michael@0 | 74 | is(win.closed, false, |
michael@0 | 75 | "Escape doesn't close the window when in the search box"); |
michael@0 | 76 | is(search.value, "", "Escape correctly emptied the search box"); |
michael@0 | 77 | |
michael@0 | 78 | // Escape from list (escape from search box moves focus to list) |
michael@0 | 79 | sendEscape(); |
michael@0 | 80 | is(win.closed, true, |
michael@0 | 81 | "Previous escape moved focus to list and now escape closed the window"); |
michael@0 | 82 | |
michael@0 | 83 | os.removeObserver(testObs, DLMGR_UI_DONE); |
michael@0 | 84 | SimpleTest.finish(); |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | ]]> |
michael@0 | 88 | </script> |
michael@0 | 89 | |
michael@0 | 90 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 91 | <p id="display"></p> |
michael@0 | 92 | <div id="content" style="display:none;"></div> |
michael@0 | 93 | <pre id="test"></pre> |
michael@0 | 94 | </body> |
michael@0 | 95 | </window> |