diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-04-14 12:55:19 +0200 |
commit | eb70e6e3d0bff11c25f14b1196025791bf2308fb (patch) | |
tree | 5ef4ce17db83c74d7b05ec12c8f59e095a6dd5bd /toolkit/components/prompts | |
parent | 32ead795290b3399d56b4708fc75b77d296f6a1a (diff) | |
download | uxp-eb70e6e3d0bff11c25f14b1196025791bf2308fb.tar.gz |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/prompts')
-rw-r--r-- | toolkit/components/prompts/moz.build | 2 | ||||
-rw-r--r-- | toolkit/components/prompts/test/.eslintrc.js | 7 | ||||
-rw-r--r-- | toolkit/components/prompts/test/bug619644_inner.html | 7 | ||||
-rw-r--r-- | toolkit/components/prompts/test/bug625187_iframe.html | 16 | ||||
-rw-r--r-- | toolkit/components/prompts/test/chromeScript.js | 241 | ||||
-rw-r--r-- | toolkit/components/prompts/test/mochitest.ini | 19 | ||||
-rw-r--r-- | toolkit/components/prompts/test/prompt_common.js | 158 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_bug619644.html | 76 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_bug620145.html | 105 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_dom_prompts.html | 208 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_modal_prompts.html | 1184 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_modal_select.html | 146 | ||||
-rw-r--r-- | toolkit/components/prompts/test/test_subresources_prompts.html | 202 |
13 files changed, 0 insertions, 2371 deletions
diff --git a/toolkit/components/prompts/moz.build b/toolkit/components/prompts/moz.build index 1dc21cca62..b827a11b6d 100644 --- a/toolkit/components/prompts/moz.build +++ b/toolkit/components/prompts/moz.build @@ -6,6 +6,4 @@ DIRS += ['src'] -MOCHITEST_MANIFESTS += ['test/mochitest.ini'] - JAR_MANIFESTS += ['jar.mn'] diff --git a/toolkit/components/prompts/test/.eslintrc.js b/toolkit/components/prompts/test/.eslintrc.js deleted file mode 100644 index 3c788d6d68..0000000000 --- a/toolkit/components/prompts/test/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; - -module.exports = { - "extends": [ - "../../../../testing/mochitest/mochitest.eslintrc.js" - ] -}; diff --git a/toolkit/components/prompts/test/bug619644_inner.html b/toolkit/components/prompts/test/bug619644_inner.html deleted file mode 100644 index f929c56499..0000000000 --- a/toolkit/components/prompts/test/bug619644_inner.html +++ /dev/null @@ -1,7 +0,0 @@ -<head></head><body><p>Original content</p> -<script> - window.opener.postMessage("", "*"); - confirm ("Message"); - document.write ("Extra content"); - window.opener.postMessage(document.documentElement.innerHTML, "*"); -</script></body> diff --git a/toolkit/components/prompts/test/bug625187_iframe.html b/toolkit/components/prompts/test/bug625187_iframe.html deleted file mode 100644 index 740d59a617..0000000000 --- a/toolkit/components/prompts/test/bug625187_iframe.html +++ /dev/null @@ -1,16 +0,0 @@ -<html> -<head> - <title>Test for Bug 625187 - the iframe</title> -<!-- - - Any copyright is dedicated to the Public Domain. - - http://creativecommons.org/publicdomain/zero/1.0/ - - - - Contributor(s): - - Mihai Sucan <mihai.sucan@gmail.com> - --> -</head> -<body> -<p><button id="btn1" onclick="alert('hello world 2')">Button 2</button></p> -<p><button id="btn2" onclick="window.parent.alert('hello world 3')">Button 3</button></p> -</body> -</html> diff --git a/toolkit/components/prompts/test/chromeScript.js b/toolkit/components/prompts/test/chromeScript.js deleted file mode 100644 index 7b2d371007..0000000000 --- a/toolkit/components/prompts/test/chromeScript.js +++ /dev/null @@ -1,241 +0,0 @@ -const { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; -Components.utils.import("resource://gre/modules/Services.jsm"); -Components.utils.import("resource://gre/modules/Timer.jsm"); - -// Define these to make EventUtils happy. -let window = this; -let parent = {}; - -let EventUtils = {}; -Services.scriptloader.loadSubScript( - "chrome://mochikit/content/tests/SimpleTest/EventUtils.js", - EventUtils -); - -addMessageListener("handlePrompt", msg => { - handlePromptWhenItAppears(msg.action, msg.isTabModal, msg.isSelect); -}); - -function handlePromptWhenItAppears(action, isTabModal, isSelect) { - let interval = setInterval(() => { - if (handlePrompt(action, isTabModal, isSelect)) { - clearInterval(interval); - } - }, 100); -} - -function handlePrompt(action, isTabModal, isSelect) { - let ui; - - if (isTabModal) { - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - let gBrowser = browserWin.gBrowser; - let promptManager = gBrowser.getTabModalPromptBox(gBrowser.selectedBrowser); - let prompts = promptManager.listPrompts(); - if (!prompts.length) { - return false; // try again in a bit - } - - ui = prompts[0].Dialog.ui; - } else { - let doc = getDialogDoc(); - if (!doc) { - return false; // try again in a bit - } - - if (isSelect) - ui = doc; - else - ui = doc.defaultView.Dialog.ui; - - } - - let promptState; - if (isSelect) { - promptState = getSelectState(ui); - dismissSelect(ui, action); - } else { - promptState = getPromptState(ui); - dismissPrompt(ui, action); - } - sendAsyncMessage("promptHandled", { promptState: promptState }); - return true; -} - -function getSelectState(ui) { - let listbox = ui.getElementById("list"); - - let state = {}; - state.msg = ui.getElementById("info.txt").value; - state.selectedIndex = listbox.selectedIndex; - state.items = []; - - for (let i = 0; i < listbox.itemCount; i++) { - let item = listbox.getItemAtIndex(i).label; - state.items.push(item); - } - - return state; -} - -function getPromptState(ui) { - let state = {}; - state.msg = ui.infoBody.textContent; - state.titleHidden = ui.infoTitle.getAttribute("hidden") == "true"; - state.textHidden = ui.loginContainer.hidden; - state.passHidden = ui.password1Container.hidden; - state.checkHidden = ui.checkboxContainer.hidden; - state.checkMsg = ui.checkbox.label; - state.checked = ui.checkbox.checked; - // tab-modal prompts don't have an infoIcon - state.iconClass = ui.infoIcon ? ui.infoIcon.className : null; - state.textValue = ui.loginTextbox.getAttribute("value"); - state.passValue = ui.password1Textbox.getAttribute("value"); - - state.butt0Label = ui.button0.label; - state.butt1Label = ui.button1.label; - state.butt2Label = ui.button2.label; - - state.butt0Disabled = ui.button0.disabled; - state.butt1Disabled = ui.button1.disabled; - state.butt2Disabled = ui.button2.disabled; - - function isDefaultButton(b) { - return (b.hasAttribute("default") && - b.getAttribute("default") == "true"); - } - state.defButton0 = isDefaultButton(ui.button0); - state.defButton1 = isDefaultButton(ui.button1); - state.defButton2 = isDefaultButton(ui.button2); - - let fm = Cc["@mozilla.org/focus-manager;1"]. - getService(Ci.nsIFocusManager); - let e = fm.focusedElement; - - if (e == null) { - state.focused = null; - } else if (ui.button0.isSameNode(e)) { - state.focused = "button0"; - } else if (ui.button1.isSameNode(e)) { - state.focused = "button1"; - } else if (ui.button2.isSameNode(e)) { - state.focused = "button2"; - } else if (ui.loginTextbox.inputField.isSameNode(e)) { - state.focused = "textField"; - } else if (ui.password1Textbox.inputField.isSameNode(e)) { - state.focused = "passField"; - } else if (ui.infoBody.isSameNode(e)) { - state.focused = "infoBody"; - } else { - state.focused = "ERROR: unexpected element focused: " + (e ? e.localName : "<null>"); - } - - return state; -} - -function dismissSelect(ui, action) { - let dialog = ui.getElementsByTagName("dialog")[0]; - let listbox = ui.getElementById("list"); - - if (action.selectItem) { - listbox.selectedIndex = 1; - } - - if (action.buttonClick == "ok") { - dialog.acceptDialog(); - } else if (action.buttonClick == "cancel") { - dialog.cancelDialog(); - } -} - -function dismissPrompt(ui, action) { - if (action.setCheckbox) { - // Annoyingly, the prompt code is driven by oncommand. - ui.checkbox.setChecked(true); - ui.checkbox.doCommand(); - } - - if ("textField" in action) { - ui.loginTextbox.setAttribute("value", action.textField); - } - - if ("passField" in action) { - ui.password1Textbox.setAttribute("value", action.passField); - } - - switch (action.buttonClick) { - case "ok": - case 0: - ui.button0.click(); - break; - case "cancel": - case 1: - ui.button1.click(); - break; - case 2: - ui.button2.click(); - break; - case "ESC": - // XXX This is assuming tab-modal. - let browserWin = Services.wm.getMostRecentWindow("navigator:browser"); - EventUtils.synthesizeKey("KEY_Escape", { code: "Escape" }, browserWin); - break; - case "pollOK": - // Buttons are disabled at the moment, poll until they're reenabled. - // Can't use setInterval here, because the window's in a modal state - // and thus DOM events are suppressed. - let interval = setInterval(() => { - if (ui.button0.disabled) - return; - ui.button0.click(); - clearInterval(interval); - }, 100); - break; - - default: - throw "dismissPrompt action listed unknown button."; - } -} - -function getDialogDoc() { - // Trudge through all the open windows, until we find the one - // that has either commonDialog.xul or selectDialog.xul loaded. - var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. - getService(Ci.nsIWindowMediator); - // var enumerator = wm.getEnumerator("navigator:browser"); - var enumerator = wm.getXULWindowEnumerator(null); - - while (enumerator.hasMoreElements()) { - var win = enumerator.getNext(); - var windowDocShell = win.QueryInterface(Ci.nsIXULWindow).docShell; - - var containedDocShells = windowDocShell.getDocShellEnumerator( - Ci.nsIDocShellTreeItem.typeChrome, - Ci.nsIDocShell.ENUMERATE_FORWARDS); - while (containedDocShells.hasMoreElements()) { - // Get the corresponding document for this docshell - var childDocShell = containedDocShells.getNext(); - // We don't want it if it's not done loading. - if (childDocShell.busyFlags != Ci.nsIDocShell.BUSY_FLAGS_NONE) - continue; - var childDoc = childDocShell.QueryInterface(Ci.nsIDocShell) - .contentViewer - .DOMDocument; - - if (childDoc.location.href != "chrome://global/content/commonDialog.xul" && - childDoc.location.href != "chrome://global/content/selectDialog.xul") - continue; - - // We're expecting the dialog to be focused. If it's not yet, try later. - // (In particular, this is needed on Linux to reliably check focused elements.) - let fm = Cc["@mozilla.org/focus-manager;1"]. - getService(Ci.nsIFocusManager); - if (fm.focusedWindow != childDoc.defaultView) - continue; - - return childDoc; - } - } - - return null; -} diff --git a/toolkit/components/prompts/test/mochitest.ini b/toolkit/components/prompts/test/mochitest.ini deleted file mode 100644 index 7f87650d6b..0000000000 --- a/toolkit/components/prompts/test/mochitest.ini +++ /dev/null @@ -1,19 +0,0 @@ -[DEFAULT] -support-files = - ../../passwordmgr/test/authenticate.sjs - bug619644_inner.html - bug625187_iframe.html - prompt_common.js - chromeScript.js - -[test_bug619644.html] -[test_bug620145.html] -skip-if = toolkit == 'android' #TIMED_OUT -[test_subresources_prompts.html] -skip-if = toolkit == 'android' -[test_dom_prompts.html] -skip-if = toolkit == 'android' #android: bug 1267092 -[test_modal_prompts.html] -skip-if = toolkit == 'android' || (os == 'linux' && (debug || asan)) #android: TIMED_OUT (For Linux : 950636) -[test_modal_select.html] -skip-if = toolkit == 'android' #android: TIMED_OUT diff --git a/toolkit/components/prompts/test/prompt_common.js b/toolkit/components/prompts/test/prompt_common.js deleted file mode 100644 index e3a69b3474..0000000000 --- a/toolkit/components/prompts/test/prompt_common.js +++ /dev/null @@ -1,158 +0,0 @@ -const Ci = SpecialPowers.Ci; -const Cc = SpecialPowers.Cc; -ok(Ci != null, "Access Ci"); -ok(Cc != null, "Access Cc"); - -function hasTabModalPrompts() { - var prefName = "prompts.tab_modal.enabled"; - var Services = SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").Services; - return Services.prefs.getPrefType(prefName) == Services.prefs.PREF_BOOL && - Services.prefs.getBoolPref(prefName); -} -var isTabModal = hasTabModalPrompts(); -var isSelectDialog = false; -var isOSX = ("nsILocalFileMac" in SpecialPowers.Ci); -var isE10S = SpecialPowers.Services.appinfo.processType == 2; - - -var gChromeScript = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL("chromeScript.js")); -SimpleTest.registerCleanupFunction(() => gChromeScript.destroy()); - -function onloadPromiseFor(id) { - var iframe = document.getElementById(id); - return new Promise(resolve => { - iframe.addEventListener("load", function onload(e) { - iframe.removeEventListener("load", onload); - resolve(true); - }); - }); -} - -function handlePrompt(state, action) { - return new Promise(resolve => { - gChromeScript.addMessageListener("promptHandled", function handled(msg) { - gChromeScript.removeMessageListener("promptHandled", handled); - checkPromptState(msg.promptState, state); - resolve(true); - }); - gChromeScript.sendAsyncMessage("handlePrompt", { action: action, isTabModal: isTabModal}); - }); -} - -function checkPromptState(promptState, expectedState) { - // XXX check title? OS X has title in content - is(promptState.msg, expectedState.msg, "Checking expected message"); - if (isOSX && !isTabModal) - ok(!promptState.titleHidden, "Checking title always visible on OS X"); - else - is(promptState.titleHidden, expectedState.titleHidden, "Checking title visibility"); - is(promptState.textHidden, expectedState.textHidden, "Checking textbox visibility"); - is(promptState.passHidden, expectedState.passHidden, "Checking passbox visibility"); - is(promptState.checkHidden, expectedState.checkHidden, "Checking checkbox visibility"); - is(promptState.checkMsg, expectedState.checkMsg, "Checking checkbox label"); - is(promptState.checked, expectedState.checked, "Checking checkbox checked"); - if (!isTabModal) - is(promptState.iconClass, "spaced " + expectedState.iconClass, "Checking expected icon CSS class"); - is(promptState.textValue, expectedState.textValue, "Checking textbox value"); - is(promptState.passValue, expectedState.passValue, "Checking passbox value"); - - if (expectedState.butt0Label) { - is(promptState.butt0Label, expectedState.butt0Label, "Checking accept-button label"); - } - if (expectedState.butt1Label) { - is(promptState.butt1Label, expectedState.butt1Label, "Checking cancel-button label"); - } - if (expectedState.butt2Label) { - is(promptState.butt2Label, expectedState.butt2Label, "Checking extra1-button label"); - } - - // For prompts with a time-delay button. - if (expectedState.butt0Disabled) { - is(promptState.butt0Disabled, true, "Checking accept-button is disabled"); - is(promptState.butt1Disabled, false, "Checking cancel-button isn't disabled"); - } - - is(promptState.defButton0, expectedState.defButton == "button0", "checking button0 default"); - is(promptState.defButton1, expectedState.defButton == "button1", "checking button1 default"); - is(promptState.defButton2, expectedState.defButton == "button2", "checking button2 default"); - - if (isOSX && expectedState.focused && expectedState.focused.startsWith("button")) { - is(promptState.focused, "infoBody", "buttons don't focus on OS X, but infoBody does instead"); - } else { - is(promptState.focused, expectedState.focused, "Checking focused element"); - } -} - -function checkEchoedAuthInfo(expectedState, doc) { - // The server echos back the HTTP auth info it received. - let username = doc.getElementById("user").textContent; - let password = doc.getElementById("pass").textContent; - let authok = doc.getElementById("ok").textContent; - - is(authok, "PASS", "Checking for successful authentication"); - is(username, expectedState.user, "Checking for echoed username"); - is(password, expectedState.pass, "Checking for echoed password"); -} - -/** - * Create a Proxy to relay method calls on an nsIAuthPrompt[2] prompter to a chrome script which can - * perform the calls in the parent. Out and inout params will be copied back from the parent to - * content. - * - * @param chromeScript The reference to the chrome script that will listen to `proxyPrompter` - * messages in the parent and call the `methodName` method. - * The return value from the message handler should be an object with properties: - * `rv` - containing the return value of the method call. - * `args` - containing the array of arguments passed to the method since out or inout ones could have - * been modified. - */ -function PrompterProxy(chromeScript) { - return new Proxy({}, { - get(target, prop, receiver) { - return (...args) => { - // Array of indices of out/inout params to copy from the parent back to the caller. - let outParams = []; - - switch (prop) { - case "prompt": { - outParams = [/* result */ 5]; - break; - } - case "promptAuth": { - outParams = []; - break; - } - case "promptPassword": { - outParams = [/* pwd */ 4]; - break; - } - case "promptUsernameAndPassword": { - outParams = [/* user */ 4, /* pwd */ 5]; - break; - } - default: { - throw new Error("Unknown nsIAuthPrompt method"); - } - } - - let result = chromeScript.sendSyncMessage("proxyPrompter", { - args, - methodName: prop, - })[0][0]; - - for (let outParam of outParams) { - // Copy the out or inout param value over the original - args[outParam].value = result.args[outParam].value; - } - - if (prop == "promptAuth") { - args[2].username = result.args[2].username; - args[2].password = result.args[2].password; - args[2].domain = result.args[2].domain; - } - - return result.rv; - }; - }, - }); -} diff --git a/toolkit/components/prompts/test/test_bug619644.html b/toolkit/components/prompts/test/test_bug619644.html deleted file mode 100644 index 9f61eb18bd..0000000000 --- a/toolkit/components/prompts/test/test_bug619644.html +++ /dev/null @@ -1,76 +0,0 @@ -<!DOCTYPE HTML> -<html> -<!-- -https://bugzilla.mozilla.org/show_bug.cgi?id=619644 ---> -<head> - <title>Test for Bug 619644</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=619644">Mozilla Bug 619644</a> -<pre id="test"> -<script class="testbody" type="text/javascript"> -// This is a little yucky, but it works -// The contents of bug619644_inner.html -const expectedFinalDoc = -"<head><\/head><body><p>Original content<\/p>\n<script>\n window.opener.postMessage(\"\", \"*\");\n confirm (\"Message\");\n document.write (\"Extra content\");\n window.opener.postMessage(document.documentElement.innerHTML, \"*\");\n<\/script>Extra content<\/body>"; - -if (!isTabModal) { - todo(false, "Test disabled when tab modal prompts are not enabled."); -} else { - inittest(); -} - -var promptDone; - -function inittest() { - window.addEventListener("message", runtest, false); - window.open("bug619644_inner.html", "619644"); - - SimpleTest.waitForExplicitFinish(); -} - -function runtest(e) { - window.removeEventListener("message", runtest, false); - window.addEventListener("message", checktest, false); - - let state = { - msg : "Message", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - let action = { - buttonClick: "ESC", - }; - - promptDone = handlePrompt(state, action); -} - -function checktest(e) { - is(e.data, expectedFinalDoc, "ESC press should not abort document load"); - e.source.close(); - promptDone.then(endtest); -} - -function endtest() { - info("Ending test"); - SimpleTest.finish(); -} -</script> -</pre> -</body> -</html> diff --git a/toolkit/components/prompts/test/test_bug620145.html b/toolkit/components/prompts/test/test_bug620145.html deleted file mode 100644 index bb4470259d..0000000000 --- a/toolkit/components/prompts/test/test_bug620145.html +++ /dev/null @@ -1,105 +0,0 @@ -<html> -<head> - <title>Test for Bug 620145</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=620145">Mozilla Bug 620145</a> -<pre id="test"> -</pre> - -<div id="text" style="max-width: 100px" onmouseup="openAlert()"> - This is a short piece of text used for testing that mouse selecting is - stopped when an alert appears. -</div> -<div id="text2" style="max-width: 100px"> - This is another short piece of text used for testing that mouse selecting is - stopped when an alert appears. -</div> -<button id="button" onmouseup="openAlert()">Button</button> - -<script class="testbody" type="text/javascript"> -var selectionTest = false; - -function openAlert() { - info("opening alert..."); - alert("hello!"); - info("...alert done."); -} - -add_task(function* runTest() { - var state, action; - // The <button> in this test's HTML opens a prompt when clicked. - // Here we send the events to simulate clicking it. - info("isTabModal? " + isTabModal); - selectionTest = isTabModal; - - state = { - msg : "hello!", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - var button = $("button"); - dispatchMouseEvent(button, "mousedown"); - dispatchMouseEvent(button, "mouseup"); - // alert appears at this point, to be closed by the chrome script. - - yield promptDone; - checkSelection(); - - // using same state and action. - promptDone = handlePrompt(state, action); - - var text = $("text"); - dispatchMouseEvent(text, "mousedown"); - dispatchMouseEvent(text, "mouseup"); - // alert appears at this point, to be closed by the chrome script. - - yield promptDone; - checkSelection(); -}); - -function dispatchMouseEvent(target, type) -{ - var win = target.ownerDocument.defaultView; - e = document.createEvent("MouseEvent"); - e.initEvent(type, false, false, win, 0, 1, 1, 1, 1, - false, false, false, false, 0, null); - var utils = SpecialPowers.getDOMWindowUtils(win); - utils.dispatchDOMEventViaPresShell(target, e, true); - ok(true, type + " sent to " + target.id); -} - -function checkSelection() -{ - if (!selectionTest) { - todo(false, "Selection test is disabled when tab modal prompts are not enabled."); - } else { - synthesizeMouse($("text"), 25, 55, { type: "mousemove" }); - is(window.getSelection().toString(), "", "selection not made"); - } -} -</script> - -</body> -</html> diff --git a/toolkit/components/prompts/test/test_dom_prompts.html b/toolkit/components/prompts/test/test_dom_prompts.html deleted file mode 100644 index 413ed8fd51..0000000000 --- a/toolkit/components/prompts/test/test_dom_prompts.html +++ /dev/null @@ -1,208 +0,0 @@ -<html> -<head> - <title>Test for DOM prompts</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -<pre id="test"> -</pre> - -<script class="testbody" type="text/javascript"> -var rv; -var state, action; - -add_task(function* test_alert_ok() { - info("Starting test: Alert"); - state = { - msg : "This is the alert text.", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - alert("This is the alert text."); - - yield promptDone; -}); - -// bug 861605 made the arguments to alert/confirm optional (prompt already was). -add_task(function* test_alert_noargs() { - info("Starting test: Alert with no args"); - state = { - msg : "", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - try { - alert(); - ok(true, "alert() without arguments should not throw!"); - } catch (e) { - ok(false, "alert() without arguments should not throw!"); - } - - yield promptDone; -}); - - -add_task(function* test_confirm_ok() { - info("Starting test: Confirm"); - state = { - msg : "This is the confirm text.", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - rv = confirm("This is the confirm text."); - is(rv, true, "check prompt return value"); - - yield promptDone; -}); - -// bug 861605 made the arguments to alert/confirm optional (prompt already was). -add_task(function* test_confirm_noargs() { - info("Starting test: Confirm with no args"); - state = { - msg : "", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - try { - rv = confirm(); - ok(true, "confirm() without arguments should not throw!"); - } catch (e) { - ok(false, "confirm() without arguments should not throw!"); - } - is(rv, true, "check prompt return value"); - - yield promptDone; -}); - - -add_task(function* test_prompt_ok() { - info("Starting test: Prompt"); - state = { - msg : "This is the Prompt text.", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - rv = prompt("This is the Prompt text."); - is(rv, "", "check prompt return value"); - - yield promptDone; -}); - -// bug 861605 made the arguments to alert/confirm optional (prompt already was). -add_task(function* test_prompt_noargs() { - info("Starting test: Prompt with no args"); - state = { - msg : "", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - try { - rv = prompt(); - ok(true, "prompt() without arguments should not throw!"); - } catch (e) { - ok(false, "prompt() without arguments should not throw!"); - } - is(rv, "", "check prompt return value"); - - yield promptDone; -}); - -</script> - -</body> -</html> diff --git a/toolkit/components/prompts/test/test_modal_prompts.html b/toolkit/components/prompts/test/test_modal_prompts.html deleted file mode 100644 index 42e6be52c3..0000000000 --- a/toolkit/components/prompts/test/test_modal_prompts.html +++ /dev/null @@ -1,1184 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Modal Prompts Test</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -Prompter tests: modal prompts -<p id="display"></p> - -<div id="content" style="display: none"> - <iframe id="iframe"></iframe> -</div> - -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.8"> - -function* runTests() { - const { NetUtil } = SpecialPowers.Cu.import('resource://gre/modules/NetUtil.jsm'); - let state, action; - ok(true, "Running tests (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")"); - - let prompter, promptArgs; - if (usePromptService) { - prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"]. - getService(Ci.nsIPromptService2); - } else { - prompter = Cc["@mozilla.org/prompter;1"]. - getService(Ci.nsIPromptFactory). - getPrompt(window, Ci.nsIPrompt); - if (isTabModal) { - let bag = prompter.QueryInterface(Ci.nsIWritablePropertyBag2); - bag.setPropertyAsBool("allowTabModal", true); - } - } - - let checkVal = {}; - let textVal = {}; - let passVal = {}; - let flags; - let isOK, clickedButton; - - // ===== - info("Starting test: Alert"); - state = { - msg : "This is the alert text.", - title : "TestTitle", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the alert text."]; - if (usePromptService) - promptArgs.unshift(window); - prompter.alert.apply(null, promptArgs); - - yield promptDone; - - // ===== - info("Starting test: AlertCheck (null checkbox label, so it's hidden)"); - state = { - msg : "This is the alertCheck text.", - title : "TestTitle", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the alertCheck text.", null, {}]; - if (usePromptService) - promptArgs.unshift(window); - prompter.alertCheck.apply(null, promptArgs); - - yield promptDone; - - // ===== - info("Starting test: AlertCheck"); - state = { - msg : "This is the alertCheck text.", - title : "TestTitle", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - checkVal.value = false; - promptArgs = ["TestTitle", "This is the alertCheck text.", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - prompter.alertCheck.apply(null, promptArgs); - is(checkVal.value, true, "checkbox was checked"); - - yield promptDone; - - // ===== - info("Starting test: Confirm (ok)"); - state = { - msg : "This is the confirm text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the confirm text."]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirm.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - - yield promptDone; - - // ===== - info("Starting test: Confirm (cancel)"); - state = { - msg : "This is the confirm text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "cancel", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the confirm text."]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirm.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmCheck (ok, null checkbox label)"); - state = { - msg : "This is the confirmCheck text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the confirmCheck text.", null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirmCheck.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmCheck (cancel, null checkbox label)"); - state = { - msg : "This is the confirmCheck text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "cancel", - }; - - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the confirmCheck text.", null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirmCheck.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmCheck (ok)"); - state = { - msg : "This is the confirmCheck text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - checkVal.value = false; - promptArgs = ["TestTitle", "This is the confirmCheck text.", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirmCheck.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmCheck (cancel)"); - state = { - msg : "This is the confirmCheck text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "cancel", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - checkVal.value = false; - promptArgs = ["TestTitle", "This is the confirmCheck text.", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.confirmCheck.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (ok, no default text)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - textField : "bacon", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = ""; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(textVal.value, "bacon", "checking expected text value"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (ok, default text)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "kittens", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "kittens"; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(textVal.value, "kittens", "checking expected text value"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (cancel, default text)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "puppies", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "cancel", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "puppies"; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(textVal.value, "puppies", "checking expected text value"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (cancel, default text modified)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : true, - textValue : "puppies", - passValue : "", - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "cancel", - textField : "bacon", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "puppies"; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(textVal.value, "puppies", "checking expected text value"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (ok, with checkbox)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : false, - textValue : "tribbles", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "ok", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "tribbles"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(textVal.value, "tribbles", "checking expected text value"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: Prompt (cancel, with checkbox)"); - state = { - msg : "This is the prompt text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : false, - passHidden : true, - checkHidden : false, - textValue : "tribbles", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "cancel", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "tribbles"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the prompt text.", textVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.prompt.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(textVal.value, "tribbles", "checking expected text value"); - is(checkVal.value, false, "expected checkbox setting"); - - yield promptDone; - - // ===== - // Just two tests for this, since password manager already tests this extensively. - info("Starting test: PromptUsernameAndPassword (ok)"); - state = { - msg : "This is the pUAP text.", - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "usr", - passValue : "ssh", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick: "ok", - setCheckbox: true, - textField: "newusr", - passField: "newssh", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "usr"; - passVal.value = "ssh"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the pUAP text.", textVal, passVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.promptUsernameAndPassword.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(textVal.value, "newusr", "checking expected text value"); - is(passVal.value, "newssh", "checking expected pass value"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: PromptUsernameAndPassword (cancel)"); - state = { - msg : "This is the pUAP text.", - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "usr", - passValue : "ssh", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "cancel", - setCheckbox : true, - textField : "newusr", - passField : "newssh", - }; - - promptDone = handlePrompt(state, action); - - textVal.value = "usr"; - passVal.value = "ssh"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the pUAP text.", textVal, passVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.promptUsernameAndPassword.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(textVal.value, "usr", "checking expected text value"); - is(passVal.value, "ssh", "checking expected pass value"); - is(checkVal.value, false, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: PromptPassword (ok)"); - state = { - msg : "This is the promptPassword text.", - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : true, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "ssh", - checkMsg : "Check me out!", - checked : false, - focused : "passField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - setCheckbox : true, - passField : "newssh", - }; - - promptDone = handlePrompt(state, action); - - passVal.value = "ssh"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the promptPassword text.", passVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.promptPassword.apply(null, promptArgs); - is(isOK, true, "checked expected retval"); - is(passVal.value, "newssh", "checking expected pass value"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: PromptPassword (cancel)"); - state = { - msg : "This is the promptPassword text.", - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : true, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "ssh", - checkMsg : "Check me out!", - checked : false, - focused : "passField", - defButton : "button0", - }; - action = { - buttonClick : "cancel", - setCheckbox : true, - passField : "newssh", - }; - - promptDone = handlePrompt(state, action); - - passVal.value = "ssh"; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the promptPassword text.", passVal, "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - isOK = prompter.promptPassword.apply(null, promptArgs); - is(isOK, false, "checked expected retval"); - is(passVal.value, "ssh", "checking expected pass value"); - is(checkVal.value, false, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmEx (ok/cancel, ok)"); - state = { - msg : "This is the confirmEx text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - butt0Label : "OK", - butt1Label : "Cancel", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - flags = Ci.nsIPromptService.STD_OK_CANCEL_BUTTONS; - promptArgs = ["TestTitle", "This is the confirmEx text.", flags, null, null, null, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 0, "checked expected button num click"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmEx (yes/no, cancel)"); - state = { - msg : "This is the confirmEx text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - butt0Label : "Yes", - butt1Label : "No", - }; - action = { - buttonClick: "cancel", - }; - - promptDone = handlePrompt(state, action); - - flags = Ci.nsIPromptService.STD_YES_NO_BUTTONS; - promptArgs = ["TestTitle", "This is the confirmEx text.", flags, null, null, null, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 1, "checked expected button num click"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmEx (buttons from args, checkbox, ok)"); - state = { - msg : "This is the confirmEx text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button0", - defButton : "button0", - butt0Label : "butt0", - butt1Label : "butt1", - butt2Label : "butt2", - }; - action = { - buttonClick: "ok", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - let b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING; - flags = b * Ci.nsIPromptService.BUTTON_POS_2 + - b * Ci.nsIPromptService.BUTTON_POS_1 + - b * Ci.nsIPromptService.BUTTON_POS_0; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the confirmEx text.", flags, - "butt0", "butt1", "butt2", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 0, "checked expected button num click"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmEx (buttons from args, checkbox, cancel)"); - state = { - msg : "This is the confirmEx text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button1", // Default changed! - defButton : "button1", - butt0Label : "butt0", - butt1Label : "butt1", - butt2Label : "butt2", - }; - action = { - buttonClick: "cancel", - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING; - flags = b * Ci.nsIPromptService.BUTTON_POS_2 + - b * Ci.nsIPromptService.BUTTON_POS_1 + - b * Ci.nsIPromptService.BUTTON_POS_0; - flags ^= Ci.nsIPromptService.BUTTON_POS_1_DEFAULT; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the confirmEx text.", flags, - "butt0", "butt1", "butt2", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 1, "checked expected button num click"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - info("Starting test: ConfirmEx (buttons from args, checkbox, button3)"); - state = { - msg : "This is the confirmEx text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "button2", // Default changed! - defButton : "button2", - butt0Label : "butt0", - butt1Label : "butt1", - butt2Label : "butt2", - }; - action = { - buttonClick: 2, - setCheckbox: true, - }; - - promptDone = handlePrompt(state, action); - - b = Ci.nsIPromptService.BUTTON_TITLE_IS_STRING; - flags = b * Ci.nsIPromptService.BUTTON_POS_2 + - b * Ci.nsIPromptService.BUTTON_POS_1 + - b * Ci.nsIPromptService.BUTTON_POS_0; - flags ^= Ci.nsIPromptService.BUTTON_POS_2_DEFAULT; - checkVal.value = false; - promptArgs = ["TestTitle", "This is the confirmEx text.", flags, - "butt0", "butt1", "butt2", "Check me out!", checkVal]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 2, "checked expected button num click"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - - // ===== - // (skipped for E10S and tabmodal tests: window is required) - info("Starting test: Alert, no window"); - state = { - msg : "This is the alert text.", - title : "TestTitle", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - if (!isTabModal && !isE10S) { - promptDone = handlePrompt(state, action); - - promptArgs = ["TestTitle", "This is the alert text."]; - if (usePromptService) - promptArgs.unshift(null); - prompter.alert.apply(null, promptArgs); - - yield promptDone; - } - - - // ===== - // (skipped for tabmodal tests: delay not supported) - info("Starting test: ConfirmEx (delay, ok)"); - state = { - msg : "This is the confirmEx delay text.", - title : "TestTitle", - iconClass : "question-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : null, // nothing focused until after delay fires - defButton : "button0", - butt0Label : "OK", - butt1Label : "Cancel", - butt0Disabled: true, - }; - - // OS X doesn't initially focus the button, but rather the infoBody. - // The focus stays there even after the button-enable delay has fired. - if (isOSX) - state.focused = "infoBody"; - - action = { - buttonClick: "pollOK", - }; - if (!isTabModal) { - promptDone = handlePrompt(state, action); - - flags = (Ci.nsIPromptService.STD_OK_CANCEL_BUTTONS | Ci.nsIPromptService.BUTTON_DELAY_ENABLE); - promptArgs = ["TestTitle", "This is the confirmEx delay text.", flags, null, null, null, null, {}]; - if (usePromptService) - promptArgs.unshift(window); - clickedButton = prompter.confirmEx.apply(null, promptArgs); - is(clickedButton, 0, "checked expected button num click"); - - yield promptDone; - } - - // promptAuth already tested via password manager but do a few specific things here. - var channel = NetUtil.newChannel({ - uri: "http://example.com", - loadUsingSystemPrincipal: true - }); - - var level = Ci.nsIAuthPrompt2.LEVEL_NONE; - var authinfo = { - username : "", - password : "", - domain : "", - flags : Ci.nsIAuthInformation.AUTH_HOST, - authenticationScheme : "basic", - realm : "" - }; - - - // ===== - // (promptAuth is only accessible from the prompt service) - info("Starting test: promptAuth with empty realm"); - state = { - msg : 'http://example.com is requesting your username and password.', - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - setCheckbox : true, - textField : "username", - passField : "password", - }; - if (usePromptService) { - promptDone = handlePrompt(state, action); - - checkVal.value = false; - isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal); - is(isOK, true, "checked expected retval"); - is(authinfo.username, "username", "checking filled username"); - is(authinfo.password, "password", "checking filled password"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - } - - - // ===== - // (promptAuth is only accessible from the prompt service) - info("Starting test: promptAuth with long realm"); - state = { - msg : 'http://example.com is requesting your username and password. The site ' + - 'says: \u201cabcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ' + - 'abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi abcdefghi ' + - 'abcdefghi \u2026\u201d', - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - setCheckbox : true, - textField : "username", - passField : "password", - }; - if (usePromptService) { - promptDone = handlePrompt(state, action); - - checkVal.value = false; - var longString = ""; - for (var i = 0; i < 20; i++) - longString += "abcdefghi "; // 200 chars long - authinfo.realm = longString; - authinfo.username = ""; - authinfo.password = ""; - isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal); - is(isOK, true, "checked expected retval"); - is(authinfo.username, "username", "checking filled username"); - is(authinfo.password, "password", "checking filled password"); - is(checkVal.value, true, "expected checkbox setting"); - - yield promptDone; - } - - info("Starting test: promptAuth for a cross-origin and a empty realm"); - authinfo = { - username : "", - password : "", - domain : "", - flags : Ci. nsIAuthInformation.AUTH_HOST | - Ci.nsIAuthInformation.CROSS_ORIGIN_SUB_RESOURCE, - authenticationScheme : "basic", - realm : "" - } - state = { - msg : 'http://example.com is requesting your username and password. ' + - 'WARNING: Your password will not be sent to the website you are currently visiting!', - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - setCheckbox : false, - textField : "username", - passField : "password", - }; - if (usePromptService) { - promptDone = handlePrompt(state, action); - checkVal.value = false; - isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal); - is(isOK, true, "checked expected retval"); - is(authinfo.username, "username", "checking filled username"); - is(authinfo.password, "password", "checking filled password"); - is(checkVal.value, false, "expected checkbox setting"); - - yield promptDone; - } - - info("Starting test: promptAuth for a cross-origin with realm"); - authinfo = { - username : "", - password : "", - domain : "", - flags : Ci. nsIAuthInformation.AUTH_HOST | Ci.nsIAuthInformation.CROSS_ORIGIN_SUB_RESOURCE, - authenticationScheme : "basic", - realm : "Something!!!" - } - state = { - msg : 'http://example.com is requesting your username and password. ' + - 'WARNING: Your password will not be sent to the website you are currently visiting!', - title : "TestTitle", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : false, - textValue : "", - passValue : "", - checkMsg : "Check me out!", - checked : false, - focused : "textField", - defButton : "button0", - }; - action = { - buttonClick : "ok", - setCheckbox : false, - textField : "username", - passField : "password", - }; - if (usePromptService) { - promptDone = handlePrompt(state, action); - - checkVal.value = false; - isOK = prompter.promptAuth(window, channel, level, authinfo, "Check me out!", checkVal); - is(isOK, true, "checked expected retval"); - is(authinfo.username, "username", "checking filled username"); - is(authinfo.password, "password", "checking filled password"); - is(checkVal.value, false, "expected checkbox setting"); - - yield promptDone; - } -} - -let usePromptService; - -/* - * Run the body of the 3 times: - * - 1st pass: with window-modal prompts, using nsIPromptService - * - 2nd pass: still window-modal, using nsIPrompt directly (via nsIPromptFactory) - * - 3rd pass: with tab-modal prompts. Can't opt into these via * nsIPromptService. - */ - -add_task(function* runPromptTests() { - info("Process type: " + SpecialPowers.Services.appinfo.processType); - - isTabModal = false; usePromptService = true; - info("Running tests with: isTabModal=" + isTabModal + ", usePromptService=" + usePromptService); - yield* runTests(); - - isTabModal = false; usePromptService = false; - info("Running tests with: isTabModal=" + isTabModal + ", usePromptService=" + usePromptService); - yield* runTests(); - - if (SpecialPowers.getBoolPref("prompts.tab_modal.enabled")) { - isTabModal = true; usePromptService = false; - info("Running tests with: isTabModal=" + isTabModal + ", usePromptService=" + usePromptService); - yield* runTests(); - } -}); - -</script> -</pre> -</body> -</html> diff --git a/toolkit/components/prompts/test/test_modal_select.html b/toolkit/components/prompts/test/test_modal_select.html deleted file mode 100644 index 1e008d0f44..0000000000 --- a/toolkit/components/prompts/test/test_modal_select.html +++ /dev/null @@ -1,146 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> - <title>Modal Prompts Test</title> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> -</head> -<body> -Prompter tests: modal prompts -<p id="display"></p> - -<div id="content" style="display: none"> - <iframe id="iframe"></iframe> -</div> - -<pre id="test"> -<script class="testbody" type="text/javascript;version=1.8"> - -let prompter = Cc["@mozilla.org/embedcomp/prompt-service;1"]. - getService(Ci.nsIPromptService2); - -function checkPromptState(promptState, expectedState) { - // XXX check title? OS X has title in content - // XXX check focused element - // XXX check button labels? - - is(promptState.msg, expectedState.msg, "Checking expected message"); - - // Compare listbox contents - is(promptState.items.length, expectedState.items.length, "Checking listbox length"); - - if (promptState.items.length) - is(promptState.selectedIndex, 0, "Checking selected index"); - - for (let i = 0; i < promptState.items; i++) { - is(promptState.items[i], expectedState.items[i], "Checking list item #" + i); - } -} - -let selectVal = {}; -let isOK; -let state, action; - -function handlePrompt(state, action) { - return new Promise(resolve => { - gChromeScript.addMessageListener("promptHandled", function handled(msg) { - gChromeScript.removeMessageListener("promptHandled", handled); - checkPromptState(msg.promptState, state); - resolve(true); - }); - gChromeScript.sendAsyncMessage("handlePrompt", { action: action, isSelect: true}); - }); -} - - -// ===== -add_task(function* test_select_empty_list() { - info("Starting test: Select (0 items, ok)"); - state = { - msg : "This is the select text.", - title : "TestTitle", - items : [], - }; - action = { - buttonClick: "ok", - }; - promptDone = handlePrompt(state, action); - items = []; - selectVal.value = null; // outparam, just making sure. - isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal); - is(isOK, true, "checked expected retval"); - is(selectVal.value, -1, "checking selected index"); - - yield promptDone; -}); - -// ===== -add_task(function* test_select_ok() { - info("Starting test: Select (3 items, ok)"); - state = { - msg : "This is the select text.", - title : "TestTitle", - items : ["one", "two", "three"], - }; - action = { - buttonClick: "ok", - }; - promptDone = handlePrompt(state, action); - items = ["one", "two", "three"]; - selectVal.value = null; // outparam, just making sure. - isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal); - is(isOK, true, "checked expected retval"); - is(selectVal.value, 0, "checking selected index"); - - yield promptDone; -}); - -// ===== -add_task(function* test_select_item() { - info("Starting test: Select (3 items, selection changed, ok)"); - state = { - msg : "This is the select text.", - title : "TestTitle", - items : ["one", "two", "three"], - }; - action = { - buttonClick: "ok", - selectItem: 1, - }; - promptDone = handlePrompt(state, action); - items = ["one", "two", "three"]; - selectVal.value = null; // outparam, just making sure. - isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal); - is(isOK, true, "checked expected retval"); - is(selectVal.value, 1, "checking selected index"); - - yield promptDone; -}); - -// ===== -add_task(function* test_cancel_prompt() { - info("Starting test: Select (3 items, cancel)"); - state = { - msg : "This is the select text.", - title : "TestTitle", - items : ["one", "two", "three"], - }; - action = { - buttonClick: "cancel", - }; - promptDone = handlePrompt(state, action); - items = ["one", "two", "three"]; - selectVal.value = null; // outparam, just making sure. - isOK = prompter.select(window, "TestTitle", "This is the select text.", items.length, items, selectVal); - is(isOK, false, "checked expected retval"); - is(selectVal.value, 0, "checking selected index"); - - yield promptDone; -}); - -</script> -</pre> -</body> -</html> diff --git a/toolkit/components/prompts/test/test_subresources_prompts.html b/toolkit/components/prompts/test/test_subresources_prompts.html deleted file mode 100644 index 241ce430f9..0000000000 --- a/toolkit/components/prompts/test/test_subresources_prompts.html +++ /dev/null @@ -1,202 +0,0 @@ -<html> -<head> - <title>Test subresources prompts (Bug 625187 and bug 1230462)</title> - <script type="text/javascript" src="/MochiKit/MochiKit.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script> - <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> - <script type="text/javascript" src="prompt_common.js"></script> - <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"> -<!-- - - Any copyright is dedicated to the Public Domain. - - http://creativecommons.org/publicdomain/zero/1.0/ - - - - Contributor(s): - - Mihai Sucan <mihai.sucan@gmail.com> - --> -</head> -<body> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=625187">Mozilla Bug 625187</a> -<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1230462">Mozilla Bug 1230462</a> - -<p><button onclick="alert('hello world')">Button</button></p> - -<iframe id="iframe_diff_origin" src="http://example.com/tests/toolkit/components/prompts/test/bug625187_iframe.html"></iframe> - -<iframe id="iframe_same_origin" src="bug625187_iframe.html"></iframe> - -<iframe id="iframe_prompt"></iframe> - -<pre id="test"></pre> - -<script class="testbody" type="text/javascript"> -var iframe1Loaded = onloadPromiseFor("iframe_diff_origin"); -var iframe2Loaded = onloadPromiseFor("iframe_same_origin"); -var iframe_prompt = document.getElementById("iframe_prompt"); - -add_task(function* runTest() -{ - // This test depends on tab modal prompts being enabled. - if (!isTabModal) { - todo(false, "Test disabled when tab modal prompts are not enabled."); - return; - } - - info("Ensuring iframe1 has loaded..."); - yield iframe1Loaded; - info("Ensuring iframe2 has loaded..."); - yield iframe2Loaded; - let state, action; - - state = { - msg : "hello world", - iconClass : "alert-icon", - titleHidden : true, - textHidden : true, - passHidden : true, - checkHidden : true, - textValue : "", - passValue : "", - checkMsg : "", - checked : false, - focused : "button0", - defButton : "button0", - }; - action = { - buttonClick: "ok", - }; - - promptDone = handlePrompt(state, action); - - var button = document.querySelector("button"); - dispatchMouseEvent(button, "click"); - - yield promptDone; - - - // mostly reusing same state/action - state.titleHidden = false; - state.msg = "hello world 2"; - promptDone = handlePrompt(state, action); - - var iframe = document.getElementById("iframe_diff_origin"); - button = SpecialPowers.wrap(iframe.contentWindow).document.getElementById("btn1"); - dispatchMouseEvent(button, "click"); - - yield promptDone; - - - // mostly reusing same state/action - state.titleHidden = true; - state.msg = "hello world 2"; - promptDone = handlePrompt(state, action); - - iframe = document.getElementById("iframe_same_origin"); - button = iframe.contentWindow.document.getElementById("btn1"); - dispatchMouseEvent(button, "click"); - - yield promptDone; - - - // mostly reusing same state/action - state.msg = "hello world 3"; - promptDone = handlePrompt(state, action); - - button = iframe.contentWindow.document.getElementById("btn2"); - dispatchMouseEvent(button, "click"); - - yield promptDone; -}); - -add_task(function* runTestAuth() -{ - // Following tests chack prompt message for a cross-origin and not - // cross-origin subresources load - - // Force parent to not look for tab-modal prompts, as they're not - // used for auth prompts. - isTabModal = false; - - state = { - msg : "http://mochi.test:8888 is requesting your username " + - "and password. The site says: “mochitest”", - title : "Authentication Required", - textValue : "", - passValue : "", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : true, - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - - action = { - buttonClick : "ok", - setCheckbox : false, - textField : "mochiuser1", - passField : "mochipass1", - }; - - promptDone = handlePrompt(state, action); - - var iframe3Loaded = onloadPromiseFor("iframe_prompt"); - iframe_prompt.src = "authenticate.sjs?user=mochiuser1&pass=mochipass1"; - yield promptDone; - yield iframe3Loaded; - checkEchoedAuthInfo({user: "mochiuser1", pass: "mochipass1"}, - iframe_prompt.contentDocument); - - // Cross-origin subresourse test. - - // Force parent to not look for tab-modal prompts, as they're not used for auth prompts. - isTabModal =false; - state = { - msg : "http://example.com is requesting your username and password. " + - "WARNING: Your password will not be sent to the website you are currently visiting!", - title : "Authentication Required", - textValue : "", - passValue : "", - iconClass : "authentication-icon question-icon", - titleHidden : true, - textHidden : false, - passHidden : false, - checkHidden : true, - checkMsg : "", - checked : false, - focused : "textField", - defButton : "button0", - }; - - action = { - buttonClick : "ok", - setCheckbox : false, - textField : "mochiuser2", - passField : "mochipass2", - }; - - promptDone = handlePrompt(state, action); - - iframe3Loaded = onloadPromiseFor("iframe_prompt"); - iframe_prompt.src = "http://example.com/tests/toolkit/components/prompts/test/authenticate.sjs?user=mochiuser2&pass=mochipass2&realm=mochitest"; - yield promptDone; - yield iframe3Loaded; - checkEchoedAuthInfo({user: "mochiuser2", pass: "mochipass2"}, - SpecialPowers.wrap(iframe_prompt.contentWindow).document); -}); - -function dispatchMouseEvent(target, type) -{ - var win = SpecialPowers.unwrap(target.ownerDocument.defaultView); - var e = document.createEvent("MouseEvent"); - e.initEvent(type, false, false, win, 0, 1, 1, 1, 1, - false, false, false, false, 0, null); - var utils = SpecialPowers.getDOMWindowUtils(win); - utils.dispatchDOMEventViaPresShell(SpecialPowers.unwrap(target), e, true); -} -</script> -</body> -</html> |