Bug 445005 - "Would you like to save..." label now shown on unknownContentType popup

This also adds a test to ensure that the unkownContentType dialog displays the
right information with given files.
r=gavin, r=sdwilsh
This commit is contained in:
Sylvain Pasche 2008-07-17 12:29:15 -04:00
parent ab44ddd517
commit 3aa6f00470
7 changed files with 156 additions and 3 deletions

View File

@ -440,14 +440,14 @@ nsUnknownContentTypeDialog.prototype = {
this.mLauncher.targetFileIsExecutable);
if (shouldntRememberChoice && !this.openWithDefaultOK()) {
// hide featured choice
this.mDialog.document.getElementById("normalBox").collapsed = "true";
this.dialogElement("normalBox").collapsed = true;
// show basic choice
this.mDialog.document.getElementById("basicBox").collapsed = "false";
this.dialogElement("basicBox").collapsed = false;
// change button labels
this.mDialog.document.documentElement.getButton("accept").label = this.dialogElement("strings").getString("unknownAccept.label");
this.mDialog.document.documentElement.getButton("cancel").label = this.dialogElement("strings").getString("unknownCancel.label");
// hide other handler
this.mDialog.document.getElementById("openHandler").collapsed = "true";
this.dialogElement("openHandler").collapsed = true;
// set save as the selected option
this.dialogElement("mode").selectedItem = this.dialogElement("save");
}

View File

@ -61,8 +61,13 @@ _CHROME_FILES = \
test_select_all.xul \
test_space_key_pauses_resumes.xul \
test_ui_stays_open_on_alert_clickback.xul \
test_unkownContentType_dialog_layout.xul \
test_bug_412360.xul \
test_bug_429247.xul \
unknownContentType_dialog_layout_data.txt \
unknownContentType_dialog_layout_data.txt^headers^ \
unknownContentType_dialog_layout_data.pif \
unknownContentType_dialog_layout_data.pif^headers^ \
utils.js \
$(NULL)

View File

@ -0,0 +1,143 @@
<?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 Unknown Content Type UI Test Code.
*
* The Initial Developer of the Original Code is
* Sylvain Pasche <sylvain.pasche@gmail.coml>.
* 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 ***** */
/**
* The unknownContentType popup can have two different layouts depending on
* whether a helper application can be selected or not.
* This tests that both layouts have correct collapsed elements.
*/
-->
<window title="Unknown Content Type Dialog Test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="init()">
<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/chrome/toolkit/mozapps/downloads/tests/chrome/utils.js"/>
<script type="application/javascript">
<![CDATA[
const UCT_URI = "chrome://mozapps/content/downloads/unknownContentType.xul";
let testIndex = 0;
let tests = [
{ // This URL will trigger the simple UI, where only the Save an Cancel buttons are available
url: "http://localhost:8888/chrome/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif",
elements: {
basicBox: { collapsed: false },
normalBox: { collapsed: true }
}
},
{ // This URL will trigger the full UI
url: "http://localhost:8888/chrome/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt",
elements: {
basicBox: { collapsed: true },
normalBox: { collapsed: false }
}
}
];
let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
getService(Ci.nsIWindowWatcher);
SimpleTest.waitForExplicitFinish();
let windowObserver = {
observe: function(aSubject, aTopic, aData) {
let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
win.addEventListener("load", function onLoad(event) {
win.removeEventListener("load", onLoad, false);
if (win.document.documentURI != UCT_URI)
return;
// Let the dialog initialize
executeSoon(function() {
checkWindow(win);
testIndex++;
if (!tests[testIndex]) {
ww.unregisterNotification(windowObserver);
SimpleTest.finish();
return;
}
loadNextTest();
});
}, false);
}
};
function init() {
ww.registerNotification(windowObserver);
loadNextTest();
}
function loadNextTest() {
let frame = document.getElementById("testframe");
frame.setAttribute("src", tests[testIndex].url);
}
function checkWindow(win) {
for (let [id, props] in Iterator(tests[testIndex].elements)) {
let elem = win.dialog.dialogElement(id);
for (let [prop, value] in Iterator(props)) {
is(elem[prop], value,
"Element with id " + id + " has property " +
prop + " set to " + value);
}
}
win.document.documentElement.cancelDialog();
}
]]>
</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>
<iframe xmlns="http://www.w3.org/1999/xhtml"
id="testframe">
</iframe>
</window>

View File

@ -0,0 +1 @@
Dummy content for unknownContentType_dialog_layout_data.pif

View File

@ -0,0 +1 @@
Content-Type: application/octet-stream

View File

@ -0,0 +1 @@
Dummy content for unknownContentType_dialog_layout_data.txt

View File

@ -0,0 +1,2 @@
Content-Type: text/plain
Content-Disposition: attachment