зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1265194 - Move handlePrompt() and checkPromptState() to prompt_common.js, and rename a test. r=adw
--HG-- rename : toolkit/components/prompts/test/test_bug861605.html => toolkit/components/prompts/test/test_dom_prompts.html
This commit is contained in:
Родитель
bdb9281e48
Коммит
5d65a8856b
|
@ -10,7 +10,7 @@ support-files =
|
|||
[test_bug620145.html]
|
||||
skip-if = toolkit == 'android' #TIMED_OUT
|
||||
[test_bug625187.html]
|
||||
[test_bug861605.html]
|
||||
[test_dom_prompts.html]
|
||||
[test_modal_prompts.html]
|
||||
skip-if = toolkit == 'android' || (os == 'linux' && (debug || asan)) #android: TIMED_OUT (For Linux : 950636)
|
||||
[test_modal_select.html]
|
||||
|
|
|
@ -7,6 +7,9 @@ var didDialog;
|
|||
|
||||
var isSelectDialog = false;
|
||||
var isTabModal = false;
|
||||
if (SpecialPowers.getBoolPref("prompts.tab_modal.enabled")) {
|
||||
isTabModal = true;
|
||||
}
|
||||
var usePromptService = true;
|
||||
|
||||
var timer; // keep in outer scope so it's not GC'd before firing
|
||||
|
@ -121,3 +124,60 @@ function getDialogDoc() {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
var isOSX = ("nsILocalFileMac" in SpecialPowers.Ci);
|
||||
var isLinux = ("@mozilla.org/gnome-gconf-service;1" in SpecialPowers.Cc);
|
||||
var isE10S = SpecialPowers.Services.appinfo.processType == 2;
|
||||
|
||||
function handlePrompt() {
|
||||
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");
|
||||
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 (isLinux && (!promptState.focused || isE10S)) {
|
||||
todo(false, "Focus seems missing or wrong on Linux"); // bug 1265077
|
||||
} else 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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Test for Bug 861605</title>
|
||||
<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/EventUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body onload="runtest()">
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=861605">Mozilla Bug 861605</a>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
|
|
@ -18,66 +18,7 @@ Prompter tests: modal prompts
|
|||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript;version=1.8">
|
||||
|
||||
var isOSX = ("nsILocalFileMac" in SpecialPowers.Ci);
|
||||
var isLinux = ("@mozilla.org/gnome-gconf-service;1" in SpecialPowers.Cc);
|
||||
var isE10S = SpecialPowers.Services.appinfo.processType == 2;
|
||||
|
||||
function checkPromptState(promptState, expectedState) {
|
||||
// XXX check title? OS X has title in content
|
||||
is(promptState.msg, expectedState.msg, "Checking expected message");
|
||||
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 (isLinux && (!promptState.focused || isE10S)) {
|
||||
todo(false, "Focus seems missing or wrong on Linux"); // bug 1265077
|
||||
} else 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* runTests() {
|
||||
|
||||
function handlePrompt() {
|
||||
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});
|
||||
});
|
||||
}
|
||||
|
||||
let ioService = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
ok(true, "Running tests (isTabModal=" + isTabModal + ", usePromptService=" + usePromptService + ")");
|
||||
|
|
Загрузка…
Ссылка в новой задаче