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 tests 437422. This test basically intends to checks if the clear list |
michael@0 | 7 | * button is disabled when: |
michael@0 | 8 | * 1. an invalid search string has been entered into the search box. |
michael@0 | 9 | * 2. active downloads are present in the dm ui |
michael@0 | 10 | * 3. we have both case (1) and (2) |
michael@0 | 11 | --> |
michael@0 | 12 | |
michael@0 | 13 | <window title="Download Manager Test" |
michael@0 | 14 | onload="runTest();" |
michael@0 | 15 | xmlns:html="http://www.w3.org/1999/xhtml" |
michael@0 | 16 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
michael@0 | 17 | |
michael@0 | 18 | <script type="application/javascript" |
michael@0 | 19 | src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/> |
michael@0 | 20 | <script type="application/javascript" |
michael@0 | 21 | src="utils.js"/> |
michael@0 | 22 | |
michael@0 | 23 | <script type="application/javascript"> |
michael@0 | 24 | |
michael@0 | 25 | <![CDATA[ |
michael@0 | 26 | |
michael@0 | 27 | let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); |
michael@0 | 28 | let dmFile = Cc["@mozilla.org/file/directory_service;1"]. |
michael@0 | 29 | getService(Ci.nsIProperties).get("TmpD", Ci.nsIFile); |
michael@0 | 30 | dmFile.append("dm-ui-test.file"); |
michael@0 | 31 | dmFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0666); |
michael@0 | 32 | let gTestPath = ios.newFileURI(dmFile).spec; |
michael@0 | 33 | |
michael@0 | 34 | const DoneDownloadData = [ |
michael@0 | 35 | { name: "Dead", |
michael@0 | 36 | source: "https://bugzilla.mozilla.org/attachment.cgi?id=266520", |
michael@0 | 37 | target: gTestPath, |
michael@0 | 38 | startTime: 1180493839859230, |
michael@0 | 39 | endTime: 1180493839859239, |
michael@0 | 40 | state: Ci.nsIDownloadManager.DOWNLOAD_CANCELED, |
michael@0 | 41 | currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 } |
michael@0 | 42 | ]; |
michael@0 | 43 | |
michael@0 | 44 | const ActiveDownloadData = [ |
michael@0 | 45 | { name: "Patch", |
michael@0 | 46 | source: "https://bugzilla.mozilla.org/attachment.cgi?id=266520", |
michael@0 | 47 | target: gTestPath, |
michael@0 | 48 | startTime: 1180493839859230, |
michael@0 | 49 | endTime: 1180493839859239, |
michael@0 | 50 | state: Ci.nsIDownloadManager.DOWNLOAD_DOWNLOADING, |
michael@0 | 51 | currBytes: 0, maxBytes: -1, preferredAction: 0, autoResume: 0 } |
michael@0 | 52 | ]; |
michael@0 | 53 | |
michael@0 | 54 | function runTest() |
michael@0 | 55 | { |
michael@0 | 56 | var dmui = getDMUI(); |
michael@0 | 57 | if (!dmui) { |
michael@0 | 58 | todo(false, "skip test for toolkit download manager UI"); |
michael@0 | 59 | return; |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | setCleanState(); |
michael@0 | 63 | populateDM(DoneDownloadData); |
michael@0 | 64 | |
michael@0 | 65 | let obs = Cc["@mozilla.org/observer-service;1"]. |
michael@0 | 66 | getService(Ci.nsIObserverService); |
michael@0 | 67 | const DLMGR_UI_DONE = "download-manager-ui-done"; |
michael@0 | 68 | |
michael@0 | 69 | let testPhase = 0; |
michael@0 | 70 | let testObs = { |
michael@0 | 71 | observe: function(aSubject, aTopic, aData) { |
michael@0 | 72 | let win = aSubject.QueryInterface(Ci.nsIDOMWindow); |
michael@0 | 73 | win.focus(); |
michael@0 | 74 | let doc = win.document; |
michael@0 | 75 | let searchbox = doc.getElementById("searchbox"); |
michael@0 | 76 | let clearButton = doc.getElementById("clearListButton"); |
michael@0 | 77 | |
michael@0 | 78 | switch (testPhase++) { |
michael@0 | 79 | case 0: |
michael@0 | 80 | // Ensure that the clear list button is enabled at first |
michael@0 | 81 | ok(!clearButton.disabled, |
michael@0 | 82 | "The clear list button is not disabled initially."); |
michael@0 | 83 | |
michael@0 | 84 | // Now, insert an nonsensical search string - nothing should show up, |
michael@0 | 85 | // and the button should be disabled in the next test phase |
michael@0 | 86 | searchbox.value = "Nonsensical"; |
michael@0 | 87 | searchbox.doCommand(); |
michael@0 | 88 | |
michael@0 | 89 | break; |
michael@0 | 90 | case 1: |
michael@0 | 91 | ok(clearButton.disabled, |
michael@0 | 92 | "The clear list button is disabled with a nonsensical search " + |
michael@0 | 93 | "term entered"); |
michael@0 | 94 | |
michael@0 | 95 | // Clear the search box |
michael@0 | 96 | searchbox.value = ""; |
michael@0 | 97 | searchbox.doCommand(); |
michael@0 | 98 | break; |
michael@0 | 99 | |
michael@0 | 100 | case 2: |
michael@0 | 101 | // Populate the download manager with an active download now, and |
michael@0 | 102 | // rebuild the list |
michael@0 | 103 | let dm = Cc["@mozilla.org/download-manager;1"]. |
michael@0 | 104 | getService(Ci.nsIDownloadManager); |
michael@0 | 105 | populateDM(ActiveDownloadData); |
michael@0 | 106 | dm.cleanUp(); |
michael@0 | 107 | |
michael@0 | 108 | break; |
michael@0 | 109 | case 3: |
michael@0 | 110 | ok(clearButton.disabled, |
michael@0 | 111 | "The clear list button is disabled when we only have an active " + |
michael@0 | 112 | "download"); |
michael@0 | 113 | |
michael@0 | 114 | // Now, insert an nonsensical search string - only the active download |
michael@0 | 115 | // should show up, and the button should be disabled in the next test |
michael@0 | 116 | // phase |
michael@0 | 117 | searchbox.value = "Nonsensical"; |
michael@0 | 118 | searchbox.doCommand(); |
michael@0 | 119 | break; |
michael@0 | 120 | case 4: |
michael@0 | 121 | ok(clearButton.disabled, |
michael@0 | 122 | "The clear list button is disabled with a nonsensical search " + |
michael@0 | 123 | "term entered and one active download"); |
michael@0 | 124 | |
michael@0 | 125 | obs.removeObserver(testObs, DLMGR_UI_DONE); |
michael@0 | 126 | setCleanState(); |
michael@0 | 127 | SimpleTest.finish(); |
michael@0 | 128 | |
michael@0 | 129 | break; |
michael@0 | 130 | } |
michael@0 | 131 | } |
michael@0 | 132 | }; |
michael@0 | 133 | |
michael@0 | 134 | obs.addObserver(testObs, DLMGR_UI_DONE, false); |
michael@0 | 135 | |
michael@0 | 136 | dmui.show(); |
michael@0 | 137 | |
michael@0 | 138 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 139 | } |
michael@0 | 140 | |
michael@0 | 141 | ]]> |
michael@0 | 142 | </script> |
michael@0 | 143 | |
michael@0 | 144 | <body xmlns="http://www.w3.org/1999/xhtml"> |
michael@0 | 145 | <p id="display"></p> |
michael@0 | 146 | <div id="content" style="display: none"></div> |
michael@0 | 147 | <pre id="test"></pre> |
michael@0 | 148 | </body> |
michael@0 | 149 | </window> |