summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul')
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul108
1 files changed, 108 insertions, 0 deletions
diff --git a/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul b/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul
new file mode 100644
index 000000000..1210b908d
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul
@@ -0,0 +1,108 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+<!--
+ * 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/tests/SimpleTest/SimpleTest.js"/>
+
+ <script type="application/javascript">
+ <![CDATA[
+const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
+
+const UCT_URI = "chrome://mozapps/content/downloads/unknownContentType.xul";
+
+let testIndex = -1;
+let tests = [
+ { // This URL will trigger the simple UI, where only the Save an Cancel buttons are available
+ url: "http://mochi.test: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://mochi.test: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);
+
+ if (aTopic == "domwindowclosed") {
+ if (win.location == UCT_URI)
+ loadNextTest();
+ return;
+ }
+
+ // domwindowopened
+ win.addEventListener("load", function onLoad(event) {
+ win.removeEventListener("load", onLoad, false);
+
+ // Let the dialog initialize
+ SimpleTest.executeSoon(function() {
+ checkWindow(win);
+ });
+ }, false);
+ }
+};
+
+function init() {
+ ww.registerNotification(windowObserver);
+ loadNextTest();
+}
+
+function loadNextTest() {
+ if (!tests[++testIndex]) {
+ ww.unregisterNotification(windowObserver);
+ SimpleTest.finish();
+ return;
+ }
+ let frame = document.getElementById("testframe");
+ frame.setAttribute("src", tests[testIndex].url);
+}
+
+function checkWindow(win) {
+ for (let [id, props] of Object.entries(tests[testIndex].elements)) {
+ let elem = win.dialog.dialogElement(id);
+ for (let [prop, value] of Object.entries(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>