summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/downloads/tests/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/mozapps/downloads/tests/chrome')
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/.eslintrc.js7
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/chrome.ini10
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_delayedbutton.xul117
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_dialog_layout.xul108
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif1
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif^headers^1
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt1
-rw-r--r--toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt^headers^2
8 files changed, 247 insertions, 0 deletions
diff --git a/toolkit/mozapps/downloads/tests/chrome/.eslintrc.js b/toolkit/mozapps/downloads/tests/chrome/.eslintrc.js
new file mode 100644
index 000000000..8c0f4f574
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/.eslintrc.js
@@ -0,0 +1,7 @@
+"use strict";
+
+module.exports = {
+ "extends": [
+ "../../../../../testing/mochitest/chrome.eslintrc.js"
+ ]
+};
diff --git a/toolkit/mozapps/downloads/tests/chrome/chrome.ini b/toolkit/mozapps/downloads/tests/chrome/chrome.ini
new file mode 100644
index 000000000..b5a29cb45
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/chrome.ini
@@ -0,0 +1,10 @@
+[DEFAULT]
+skip-if = os == 'android'
+support-files =
+ unknownContentType_dialog_layout_data.pif
+ unknownContentType_dialog_layout_data.pif^headers^
+ unknownContentType_dialog_layout_data.txt
+ unknownContentType_dialog_layout_data.txt^headers^
+
+[test_unknownContentType_delayedbutton.xul]
+[test_unknownContentType_dialog_layout.xul]
diff --git a/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_delayedbutton.xul b/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_delayedbutton.xul
new file mode 100644
index 000000000..9bbec0f92
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/test_unknownContentType_delayedbutton.xul
@@ -0,0 +1,117 @@
+<?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="doTest()">
+
+ <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;
+
+ Cu.import("resource://gre/modules/Services.jsm");
+ Cu.import("resource://gre/modules/Task.jsm");
+ Cu.import("resource://gre/modules/Promise.jsm");
+
+ const UCT_URI = "chrome://mozapps/content/downloads/unknownContentType.xul";
+ const LOAD_URI = "http://mochi.test:8888/chrome/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt";
+
+ const DIALOG_DELAY = Services.prefs.getIntPref("security.dialog_enable_delay") + 200;
+
+ let UCTObserver = {
+ opened: Promise.defer(),
+ closed: Promise.defer(),
+
+ observe: function(aSubject, aTopic, aData) {
+ let win = aSubject.QueryInterface(Ci.nsIDOMEventTarget);
+
+ switch (aTopic) {
+ case "domwindowopened":
+ win.addEventListener("load", function onLoad(event) {
+ win.removeEventListener("load", onLoad, false);
+
+ // Let the dialog initialize
+ SimpleTest.executeSoon(function() {
+ UCTObserver.opened.resolve(win);
+ });
+ }, false);
+ break;
+
+ case "domwindowclosed":
+ if (win.location == UCT_URI) {
+ this.closed.resolve();
+ }
+ break;
+ }
+ }
+ };
+
+ Services.ww.registerNotification(UCTObserver);
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.requestFlakyTimeout("This test is testing a timing-based feature, so it really needs to wait a certain amount of time to verify that the feature worked.");
+
+ function waitDelay(delay) {
+ return new Promise((resolve, reject) => {
+ window.setTimeout(resolve, delay);
+ });
+ }
+
+ function doTest() {
+ Task.spawn(function test_aboutCrashed() {
+ let frame = document.getElementById("testframe");
+ frame.setAttribute("src", LOAD_URI);
+
+ let uctWindow = yield UCTObserver.opened.promise;
+ let ok = uctWindow.document.documentElement.getButton("accept");
+
+ SimpleTest.is(ok.disabled, true, "button started disabled");
+
+ yield waitDelay(DIALOG_DELAY);
+
+ SimpleTest.is(ok.disabled, false, "button was enabled");
+
+ focusOutOfDialog = SimpleTest.promiseFocus(window);
+ window.focus();
+ yield focusOutOfDialog;
+
+ SimpleTest.is(ok.disabled, true, "button was disabled");
+
+ focusOnDialog = SimpleTest.promiseFocus(uctWindow);
+ uctWindow.focus();
+ yield focusOnDialog;
+
+ SimpleTest.is(ok.disabled, true, "button remained disabled");
+
+ yield waitDelay(DIALOG_DELAY);
+ SimpleTest.is(ok.disabled, false, "button re-enabled after delay");
+
+ uctWindow.document.documentElement.cancelDialog();
+ yield UCTObserver.closed.promise;
+
+ Services.ww.unregisterNotification(UCTObserver);
+ uctWindow = null;
+ UCTObserver = null;
+ SimpleTest.finish();
+ });
+ }
+ ]]></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>
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>
diff --git a/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif
new file mode 100644
index 000000000..9353d1312
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif
@@ -0,0 +1 @@
+Dummy content for unknownContentType_dialog_layout_data.pif
diff --git a/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif^headers^ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif^headers^
new file mode 100644
index 000000000..09b22facc
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.pif^headers^
@@ -0,0 +1 @@
+Content-Type: application/octet-stream
diff --git a/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt
new file mode 100644
index 000000000..77e719559
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt
@@ -0,0 +1 @@
+Dummy content for unknownContentType_dialog_layout_data.txt
diff --git a/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt^headers^ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt^headers^
new file mode 100644
index 000000000..2a3c472e2
--- /dev/null
+++ b/toolkit/mozapps/downloads/tests/chrome/unknownContentType_dialog_layout_data.txt^headers^
@@ -0,0 +1,2 @@
+Content-Type: text/plain
+Content-Disposition: attachment