2010-05-04 21:40:39 +04:00
|
|
|
<html style="ime-mode: disabled;">
|
2009-05-05 10:15:23 +04:00
|
|
|
<head>
|
|
|
|
<title>Test for IME state controling</title>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
2010-05-27 06:04:14 +04:00
|
|
|
<script type="text/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
2014-02-17 18:58:06 +04:00
|
|
|
<script type="text/javascript" src="utils.js"></script>
|
2009-05-05 10:15:23 +04:00
|
|
|
<link rel="stylesheet" type="text/css"
|
|
|
|
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
2010-05-04 21:40:39 +04:00
|
|
|
<body onload="setTimeout(runTests, 0);" style="ime-mode: disabled;">
|
2014-02-17 18:58:06 +04:00
|
|
|
<script>
|
|
|
|
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
|
|
|
|
</script>
|
2010-05-04 21:40:39 +04:00
|
|
|
<div id="display" style="ime-mode: disabled;">
|
2009-05-05 10:15:23 +04:00
|
|
|
<!-- input elements -->
|
|
|
|
<input type="text" id="text"/><br/>
|
|
|
|
<input type="text" id="text_readonly" readonly="readonly"/><br/>
|
|
|
|
<input type="password" id="password"/><br/>
|
|
|
|
<input type="password" id="password_readonly" readonly="readonly"/><br/>
|
|
|
|
<input type="checkbox" id="checkbox"/><br/>
|
|
|
|
<input type="radio" id="radio"/><br/>
|
|
|
|
<input type="submit" id="submit"/><br/>
|
|
|
|
<input type="reset" id="reset"/><br/>
|
|
|
|
<input type="file" id="file"/><br/>
|
|
|
|
<input type="button" id="ibutton"/><br/>
|
|
|
|
<input type="image" id="image" alt="image"/><br/>
|
|
|
|
|
2010-11-23 09:48:45 +03:00
|
|
|
<!-- html5 input elements -->
|
|
|
|
<input type="url" id="url"/><br/>
|
|
|
|
<input type="email" id="email"/><br/>
|
|
|
|
<input type="search" id="search"/><br/>
|
|
|
|
<input type="tel" id="tel"/><br/>
|
|
|
|
<input type="number" id="number"/><br/>
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
<!-- form controls -->
|
|
|
|
<button id="button">button</button><br/>
|
|
|
|
<textarea id="textarea">textarea</textarea><br/>
|
|
|
|
<textarea id="textarea_readonly" readonly="readonly">textarea[readonly]</textarea><br/>
|
|
|
|
<select id="select">
|
|
|
|
<option value="option" selected="selected"/>
|
|
|
|
</select><br/>
|
|
|
|
<select id="select_multiple" multiple="multiple">
|
|
|
|
<option value="option" selected="selected"/>
|
|
|
|
</select><br/>
|
|
|
|
<isindex id="isindex" prompt="isindex"/><br/>
|
|
|
|
|
|
|
|
<!-- a element -->
|
2010-05-04 21:40:39 +04:00
|
|
|
<a id="a_href" href="about:blank">a[href]</a><br/>
|
2009-05-05 10:15:23 +04:00
|
|
|
|
|
|
|
<!-- ime-mode test -->
|
|
|
|
<input type="text" id="ime_mode_auto" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled" style="ime-mode: disabled;"/><br/>
|
2010-11-23 09:48:45 +03:00
|
|
|
|
|
|
|
<input type="text" id="ime_mode_auto_url" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal_url" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active_url" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive_url" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled_url" style="ime-mode: disabled;"/><br/>
|
|
|
|
|
|
|
|
<input type="text" id="ime_mode_auto_email" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal_email" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active_email" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive_email" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled_email" style="ime-mode: disabled;"/><br/>
|
|
|
|
|
|
|
|
<input type="text" id="ime_mode_auto_search" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal_search" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active_search" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive_search" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled_search" style="ime-mode: disabled;"/><br/>
|
|
|
|
|
|
|
|
<input type="text" id="ime_mode_auto_tel" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal_tel" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active_tel" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive_tel" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled_tel" style="ime-mode: disabled;"/><br/>
|
|
|
|
|
|
|
|
<input type="text" id="ime_mode_auto_number" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_normal_number" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_active_number" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_inactive_number" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="text" id="ime_mode_disabled_number" style="ime-mode: disabled;"/><br/>
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
<input type="password" id="ime_mode_auto_p" style="ime-mode: auto;"/><br/>
|
|
|
|
<input type="password" id="ime_mode_normal_p" style="ime-mode: normal;"/><br/>
|
|
|
|
<input type="password" id="ime_mode_active_p" style="ime-mode: active;"/><br/>
|
|
|
|
<input type="password" id="ime_mode_inactive_p" style="ime-mode: inactive;"/><br/>
|
|
|
|
<input type="password" id="ime_mode_disabled_p" style="ime-mode: disabled;"/><br/>
|
|
|
|
<textarea id="ime_mode_auto_t" style="ime-mode: auto;">textarea</textarea><br/>
|
|
|
|
<textarea id="ime_mode_normal_t" style="ime-mode: normal;">textarea</textarea><br/>
|
|
|
|
<textarea id="ime_mode_active_t" style="ime-mode: active;">textarea</textarea><br/>
|
|
|
|
<textarea id="ime_mode_inactive_t" style="ime-mode: inactive;">textarea</textarea><br/>
|
|
|
|
<textarea id="ime_mode_disabled_t" style="ime-mode: disabled;">textarea</textarea><br/>
|
2009-12-04 11:03:27 +03:00
|
|
|
|
|
|
|
<!-- plugin -->
|
|
|
|
<object type="application/x-test" id="plugin"></object><br/>
|
2010-05-04 21:40:39 +04:00
|
|
|
|
|
|
|
<!-- contenteditable editor -->
|
|
|
|
<div id="contenteditableEditor" contenteditable="true"></div>
|
|
|
|
|
|
|
|
<!-- designMode editor -->
|
|
|
|
<iframe id="designModeEditor"
|
|
|
|
onload="document.getElementById('designModeEditor').contentDocument.designMode = 'on';"
|
|
|
|
src="data:text/html,<html><body></body></html>"></iframe><br/>
|
|
|
|
</div>
|
2009-05-05 10:15:23 +04:00
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
</pre>
|
|
|
|
|
|
|
|
<script class="testbody" type="application/javascript">
|
|
|
|
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2012-11-09 12:40:40 +04:00
|
|
|
function hitEventLoop(aFunc, aTimes)
|
|
|
|
{
|
|
|
|
if (--aTimes) {
|
|
|
|
setTimeout(hitEventLoop, 0, aFunc, aTimes);
|
|
|
|
} else {
|
|
|
|
setTimeout(aFunc, 20);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
var gUtils = window.
|
2018-02-28 20:51:33 +03:00
|
|
|
QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIDOMWindowUtils);
|
|
|
|
var gFM = Cc["@mozilla.org/focus-manager;1"].
|
|
|
|
getService(Ci.nsIFocusManager);
|
2009-05-05 10:15:23 +04:00
|
|
|
const kIMEEnabledSupported = navigator.platform.indexOf("Mac") == 0 ||
|
|
|
|
navigator.platform.indexOf("Win") == 0 ||
|
|
|
|
navigator.platform.indexOf("Linux") == 0;
|
|
|
|
|
|
|
|
// We support to control IME open state on Windows and Mac actually. However,
|
|
|
|
// we cannot test it on Mac if the current keyboard layout is not CJK. And also
|
|
|
|
// we cannot test it on Win32 if the system didn't be installed IME. So,
|
|
|
|
// currently we should not run the open state testing.
|
|
|
|
const kIMEOpenSupported = false;
|
|
|
|
|
|
|
|
function runBasicTest(aIsEditable, aInDesignMode, aDescription)
|
|
|
|
{
|
2015-05-26 10:45:26 +03:00
|
|
|
var onIMEFocusBlurHandler = null;
|
|
|
|
var TIPCallback = function(aTIP, aNotification) {
|
|
|
|
switch (aNotification.type) {
|
|
|
|
case "request-to-commit":
|
|
|
|
aTIP.commitComposition();
|
|
|
|
break;
|
|
|
|
case "request-to-cancel":
|
|
|
|
aTIP.cancelComposition();
|
|
|
|
break;
|
|
|
|
case "notify-focus":
|
|
|
|
case "notify-blur":
|
|
|
|
if (onIMEFocusBlurHandler) {
|
|
|
|
onIMEFocusBlurHandler(aNotification);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2018-02-28 20:51:33 +03:00
|
|
|
var TIP = Cc["@mozilla.org/text-input-processor;1"]
|
|
|
|
.createInstance(Ci.nsITextInputProcessor);
|
2015-05-26 10:45:26 +03:00
|
|
|
if (!TIP.beginInputTransactionForTests(window, TIPCallback)) {
|
|
|
|
ok(false, "runBasicTest(): failed to begin input transaction");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
function test(aTest)
|
|
|
|
{
|
2012-11-09 12:40:40 +04:00
|
|
|
function moveFocus(aTest, aFocusEventHandler)
|
2009-05-05 10:15:23 +04:00
|
|
|
{
|
2010-05-04 21:40:39 +04:00
|
|
|
if (aInDesignMode) {
|
|
|
|
if (document.activeElement) {
|
|
|
|
document.activeElement.blur();
|
|
|
|
}
|
|
|
|
} else if (aIsEditable) {
|
|
|
|
document.getElementById("display").focus();
|
|
|
|
} else if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED) {
|
|
|
|
document.getElementById("password").focus();
|
2009-05-05 10:15:23 +04:00
|
|
|
} else {
|
2010-05-04 21:40:39 +04:00
|
|
|
document.getElementById("text").focus();
|
|
|
|
}
|
|
|
|
var previousFocusedElement = gFM.focusedElement;
|
|
|
|
var element = document.getElementById(aTest.id);
|
2012-11-13 05:18:57 +04:00
|
|
|
var focusEventTarget = element;
|
2012-11-09 12:40:40 +04:00
|
|
|
var subDocument = null;
|
2010-05-04 21:40:39 +04:00
|
|
|
if (element.contentDocument) {
|
2012-11-13 05:18:57 +04:00
|
|
|
focusEventTarget = element.contentDocument;
|
2012-11-09 12:40:40 +04:00
|
|
|
subDocument = element.contentDocument;
|
2010-05-04 21:40:39 +04:00
|
|
|
element = element.contentDocument.documentElement;
|
|
|
|
}
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2012-11-13 05:18:57 +04:00
|
|
|
focusEventTarget.addEventListener("focus", aFocusEventHandler, true);
|
2015-05-26 10:45:26 +03:00
|
|
|
onIMEFocusBlurHandler = aFocusEventHandler;
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2010-05-04 21:40:39 +04:00
|
|
|
element.focus();
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2012-11-13 05:18:57 +04:00
|
|
|
focusEventTarget.removeEventListener("focus", aFocusEventHandler, true);
|
2015-05-26 10:45:26 +03:00
|
|
|
onIMEFocusBlurHandler = null;
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2010-05-04 21:40:39 +04:00
|
|
|
var focusedElement = gFM.focusedElement;
|
|
|
|
if (focusedElement) {
|
|
|
|
var bindingParent = document.getBindingParent(focusedElement);
|
|
|
|
if (bindingParent) {
|
|
|
|
focusedElement = bindingParent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aTest.focusable) {
|
|
|
|
is(focusedElement, element,
|
|
|
|
aDescription + ": " + aTest.description + ", focus didn't move");
|
|
|
|
return (element == focusedElement);
|
2009-05-05 10:15:23 +04:00
|
|
|
}
|
2010-05-04 21:40:39 +04:00
|
|
|
is(focusedElement, previousFocusedElement,
|
|
|
|
aDescription + ": " + aTest.description + ", focus moved as unexpected");
|
|
|
|
return (previousFocusedElement == focusedElement);
|
2009-05-05 10:15:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function testOpened(aTest, aOpened)
|
|
|
|
{
|
|
|
|
document.getElementById("text").focus();
|
|
|
|
gUtils.IMEIsOpen = aOpened;
|
2010-05-04 21:40:39 +04:00
|
|
|
if (!moveFocus(aTest)) {
|
|
|
|
return;
|
|
|
|
}
|
2009-05-05 10:15:23 +04:00
|
|
|
var message = aDescription + ": " + aTest.description +
|
|
|
|
", wrong opened state";
|
|
|
|
is(gUtils.IMEIsOpen,
|
|
|
|
aTest.changeOpened ? aTest.expectedOpened : aOpened, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
// IME Enabled state testing
|
|
|
|
var enabled = gUtils.IME_STATUS_ENABLED;
|
|
|
|
if (kIMEEnabledSupported) {
|
2012-11-13 05:18:57 +04:00
|
|
|
var focusEventCount = 0;
|
2015-05-26 10:45:26 +03:00
|
|
|
var IMEReceivesFocus = 0;
|
|
|
|
var IMEReceivesBlur = 0;
|
2012-11-09 12:40:40 +04:00
|
|
|
var IMEHasFocus = false;
|
|
|
|
|
|
|
|
function onFocus(aEvent)
|
|
|
|
{
|
|
|
|
switch (aEvent.type) {
|
2012-11-13 05:18:57 +04:00
|
|
|
case "focus":
|
|
|
|
focusEventCount++;
|
|
|
|
is(gUtils.IMEStatus, aTest.expectedEnabled,
|
|
|
|
aDescription + ": " + aTest.description + ", wrong enabled state at focus event");
|
|
|
|
break;
|
2015-05-26 10:45:26 +03:00
|
|
|
case "notify-focus":
|
|
|
|
IMEReceivesFocus++;
|
2012-11-09 12:40:40 +04:00
|
|
|
IMEHasFocus = true;
|
|
|
|
is(gUtils.IMEStatus, aTest.expectedEnabled,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a focus notification after IME state is updated");
|
2012-11-09 12:40:40 +04:00
|
|
|
break;
|
2015-05-26 10:45:26 +03:00
|
|
|
case "notify-blur":
|
|
|
|
IMEReceivesBlur++;
|
2012-11-09 12:40:40 +04:00
|
|
|
IMEHasFocus = false;
|
2013-03-23 18:20:31 +04:00
|
|
|
var changingStatus = !(aIsEditable && aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED);
|
|
|
|
if (aTest.toDesignModeEditor) {
|
|
|
|
is(gUtils.IME_STATUS_ENABLED, aTest.expectedEnabled,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a blur notification after IME state is updated");
|
2013-03-23 18:20:31 +04:00
|
|
|
} else if (changingStatus) {
|
|
|
|
isnot(gUtils.IMEStatus, aTest.expectedEnabled,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a blur notification before IME state is updated");
|
2013-03-23 18:20:31 +04:00
|
|
|
} else {
|
|
|
|
is(gUtils.IMEStatus, aTest.expectedEnabled,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a blur notification and its context has expected IME state if the state isn't being changed");
|
2013-03-23 18:20:31 +04:00
|
|
|
}
|
2012-11-09 12:40:40 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!moveFocus(aTest, onFocus)) {
|
2010-05-04 21:40:39 +04:00
|
|
|
return;
|
|
|
|
}
|
2012-11-09 12:40:40 +04:00
|
|
|
|
|
|
|
if (aTest.focusable) {
|
|
|
|
if (!aTest.focusEventNotFired) {
|
2012-11-13 05:18:57 +04:00
|
|
|
ok(focusEventCount > 0,
|
|
|
|
aDescription + ": " + aTest.description + ", focus event is never fired");
|
2012-11-09 12:40:40 +04:00
|
|
|
if (aTest.expectedEnabled == gUtils.IME_STATUS_ENABLED || aTest.expectedEnabled == gUtils.IME_STATUS_PASSWORD) {
|
2015-05-26 10:45:26 +03:00
|
|
|
ok(IMEReceivesFocus > 0,
|
|
|
|
aDescription + ": " + aTest.description + ", IME should receive a focus notification");
|
2013-03-23 18:20:31 +04:00
|
|
|
if (aInDesignMode && !aTest.toDesignModeEditor) {
|
2015-05-26 10:45:26 +03:00
|
|
|
is(IMEReceivesBlur, 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME shouldn't receive a blur notification in designMode since focus isn't moved from another editor");
|
2012-11-09 12:40:40 +04:00
|
|
|
} else {
|
2015-05-26 10:45:26 +03:00
|
|
|
ok(IMEReceivesBlur > 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a blur notification for the previous focused editor");
|
2012-11-09 12:40:40 +04:00
|
|
|
}
|
2012-11-13 05:18:57 +04:00
|
|
|
ok(IMEHasFocus,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should have focus right now");
|
2012-11-09 12:40:40 +04:00
|
|
|
} else {
|
2015-05-26 10:45:26 +03:00
|
|
|
is(IMEReceivesFocus, 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME shouldn't receive a focus notification");
|
|
|
|
ok(IMEReceivesBlur > 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME should receive a blur notification");
|
2012-11-09 12:40:40 +04:00
|
|
|
ok(!IMEHasFocus,
|
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME shouldn't have focus right now");
|
2012-11-09 12:40:40 +04:00
|
|
|
}
|
|
|
|
} else {
|
2012-11-13 05:18:57 +04:00
|
|
|
todo(focusEventCount > 0,
|
|
|
|
aDescription + ": " + aTest.description + ", focus event should be fired");
|
2012-11-09 12:40:40 +04:00
|
|
|
}
|
|
|
|
} else {
|
2015-05-26 10:45:26 +03:00
|
|
|
is(IMEReceivesFocus, 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME shouldn't receive a focus notification at testing non-focusable element");
|
|
|
|
is(IMEReceivesBlur, 0,
|
2012-11-09 12:40:40 +04:00
|
|
|
aDescription + ": " + aTest.description +
|
2015-05-26 10:45:26 +03:00
|
|
|
", IME shouldn't receive a blur notification at testing non-focusable element");
|
2012-11-09 12:40:40 +04:00
|
|
|
}
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
enabled = gUtils.IMEStatus;
|
2011-03-25 18:03:33 +03:00
|
|
|
inputtype = gUtils.focusedInputType;
|
2010-05-04 21:40:39 +04:00
|
|
|
is(enabled, aTest.expectedEnabled,
|
2009-05-05 10:15:23 +04:00
|
|
|
aDescription + ": " + aTest.description + ", wrong enabled state");
|
2010-11-23 09:48:45 +03:00
|
|
|
if (aTest.expectedType && !aInDesignMode) {
|
|
|
|
is(inputtype, aTest.expectedType,
|
|
|
|
aDescription + ": " + aTest.description + ", wrong input type");
|
|
|
|
} else if (aInDesignMode) {
|
|
|
|
is(inputtype, "",
|
|
|
|
aDescription + ": " + aTest.description + ", wrong input type")
|
|
|
|
}
|
2009-05-05 10:15:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!kIMEOpenSupported || enabled != gUtils.IME_STATUS_ENABLED ||
|
|
|
|
aTest.expectedEnabled != gUtils.IME_STATUS_ENABLED) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IME Open state testing
|
|
|
|
testOpened(aTest, false);
|
|
|
|
testOpened(aTest, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kIMEEnabledSupported) {
|
2010-05-04 21:40:39 +04:00
|
|
|
// make sure there is an active element
|
|
|
|
document.getElementById("text").focus();
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
document.activeElement.blur();
|
2010-05-04 21:40:39 +04:00
|
|
|
is(gUtils.IMEStatus,
|
|
|
|
aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_DISABLED,
|
2009-05-05 10:15:23 +04:00
|
|
|
aDescription + ": unexpected enabled state when no element has focus");
|
|
|
|
}
|
|
|
|
|
2010-05-04 21:40:39 +04:00
|
|
|
// Form controls except text editable elements are "disable" in normal
|
|
|
|
// condition, however, if they are editable, they are "enabled".
|
|
|
|
// XXX Probably there are some bugs: If the form controls editable, they
|
|
|
|
// shouldn't be focusable.
|
|
|
|
const kEnabledStateOnNonEditableElement =
|
|
|
|
(aInDesignMode || aIsEditable) ? gUtils.IME_STATUS_ENABLED :
|
|
|
|
gUtils.IME_STATUS_DISABLED;
|
|
|
|
const kEnabledStateOnPasswordField =
|
|
|
|
aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_PASSWORD;
|
|
|
|
const kEnabledStateOnReadonlyField =
|
|
|
|
aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_DISABLED;
|
2009-05-05 10:15:23 +04:00
|
|
|
const kTests = [
|
|
|
|
{ id: "text",
|
|
|
|
description: "input[type=text]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2010-11-23 09:48:45 +03:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "text" },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "text_readonly",
|
|
|
|
description: "input[type=text][readonly]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "password",
|
|
|
|
description: "input[type=password]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2010-11-23 09:48:45 +03:00
|
|
|
expectedEnabled: kEnabledStateOnPasswordField,
|
|
|
|
expectedType: "password" },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "password_readonly",
|
|
|
|
description: "input[type=password][readonly]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "checkbox",
|
|
|
|
description: "input[type=checkbox]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2012-11-09 12:40:40 +04:00
|
|
|
focusEventNotFired: aIsEditable && !aInDesignMode,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "radio",
|
|
|
|
description: "input[type=radio]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2012-11-09 12:40:40 +04:00
|
|
|
focusEventNotFired: aIsEditable && !aInDesignMode,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "submit",
|
|
|
|
description: "input[type=submit]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "reset",
|
|
|
|
description: "input[type=reset]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "file",
|
|
|
|
description: "input[type=file]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2012-11-09 12:40:40 +04:00
|
|
|
focusEventNotFired: aIsEditable && !aInDesignMode,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "button",
|
|
|
|
description: "input[type=button]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "image",
|
|
|
|
description: "input[type=image]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2010-11-23 09:48:45 +03:00
|
|
|
{ id: "url",
|
|
|
|
description: "input[type=url]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "url" },
|
|
|
|
{ id: "email",
|
|
|
|
description: "input[type=email]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "email" },
|
|
|
|
{ id: "search",
|
|
|
|
description: "input[type=search]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "search" },
|
|
|
|
{ id: "tel",
|
|
|
|
description: "input[type=tel]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "tel" },
|
|
|
|
{ id: "number",
|
|
|
|
description: "input[type=number]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "number" },
|
2009-05-05 10:15:23 +04:00
|
|
|
|
|
|
|
// form controls
|
|
|
|
{ id: "button",
|
|
|
|
description: "button",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "textarea",
|
|
|
|
description: "textarea",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "textarea_readonly",
|
|
|
|
description: "textarea[readonly]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "select",
|
|
|
|
description: "select (dropdown list)",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2012-11-09 12:40:40 +04:00
|
|
|
focusEventNotFired: aIsEditable && !aInDesignMode,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "select_multiple",
|
|
|
|
description: "select (list box)",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2012-11-09 12:40:40 +04:00
|
|
|
focusEventNotFired: aIsEditable && !aInDesignMode,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
|
|
|
|
// a element
|
|
|
|
{ id: "a_href",
|
|
|
|
description: "a[href]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aIsEditable && !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-05 10:15:23 +04:00
|
|
|
|
|
|
|
// ime-mode
|
|
|
|
{ id: "ime_mode_auto",
|
|
|
|
description: "input[type=text][style=\"ime-mode: auto;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal",
|
|
|
|
description: "input[type=text][style=\"ime-mode: normal;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active",
|
|
|
|
description: "input[type=text][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive",
|
|
|
|
description: "input[type=text][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled",
|
|
|
|
description: "input[type=text][style=\"ime-mode: disabled;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2010-11-23 09:48:45 +03:00
|
|
|
|
|
|
|
{ id: "ime_mode_auto_url",
|
|
|
|
description: "input[type=url][style=\"ime-mode: auto;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal_url",
|
|
|
|
description: "input[type=url][style=\"ime-mode: normal;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_url",
|
|
|
|
description: "input[type=url][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_url",
|
|
|
|
description: "input[type=url][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_url",
|
|
|
|
description: "input[type=url][style=\"ime-mode: disabled;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_email",
|
|
|
|
description: "input[type=email][style=\"ime-mode: auto;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal_email",
|
|
|
|
description: "input[type=email][style=\"ime-mode: normal;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_email",
|
|
|
|
description: "input[type=email][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_email",
|
|
|
|
description: "input[type=email][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_email",
|
|
|
|
description: "input[type=email][style=\"ime-mode: disabled;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_search",
|
|
|
|
description: "input[type=search][style=\"ime-mode: auto;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal_search",
|
|
|
|
description: "input[type=search][style=\"ime-mode: normal;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_search",
|
|
|
|
description: "input[type=search][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_search",
|
|
|
|
description: "input[type=search][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_search",
|
|
|
|
description: "input[type=search][style=\"ime-mode: disabled;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_tel",
|
|
|
|
description: "input[type=tel][style=\"ime-mode: auto;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal_tel",
|
|
|
|
description: "input[type=tel][style=\"ime-mode: normal;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_tel",
|
|
|
|
description: "input[type=tel][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_tel",
|
|
|
|
description: "input[type=tel][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_tel",
|
|
|
|
description: "input[type=tel][style=\"ime-mode: disabled;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_number",
|
|
|
|
description: "input[type=number][style=\"ime-mode: auto;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal_number",
|
|
|
|
description: "input[type=number][style=\"ime-mode: normal;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_number",
|
|
|
|
description: "input[type=number][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_number",
|
|
|
|
description: "input[type=number][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_number",
|
|
|
|
description: "input[type=number][style=\"ime-mode: disabled;\"]",
|
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "ime_mode_auto_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: auto;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "ime_mode_normal_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: normal;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: active;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: inactive;\"]",
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: disabled;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "ime_mode_auto",
|
|
|
|
description: "textarea[style=\"ime-mode: auto;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal",
|
|
|
|
description: "textarea[style=\"ime-mode: normal;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active",
|
|
|
|
description: "textarea[style=\"ime-mode: active;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive",
|
|
|
|
description: "textarea[style=\"ime-mode: inactive;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-05 10:15:23 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled",
|
|
|
|
description: "textarea[style=\"ime-mode: disabled;\"]",
|
2010-05-04 21:40:39 +04:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
|
|
|
|
|
|
|
// HTML editors
|
|
|
|
{ id: "contenteditableEditor",
|
|
|
|
description: "div[contenteditable=\"true\"]",
|
|
|
|
focusable: !aIsEditable && !aInDesignMode,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "designModeEditor",
|
|
|
|
description: "designMode editor",
|
|
|
|
focusable: true,
|
2013-03-23 18:20:31 +04:00
|
|
|
toDesignModeEditor: true,
|
2010-05-04 21:40:39 +04:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
2009-05-05 10:15:23 +04:00
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < kTests.length; i++) {
|
|
|
|
test(kTests[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-04 11:03:27 +03:00
|
|
|
function runPluginTest()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (navigator.platform.indexOf("Mac") == 0) {
|
|
|
|
// XXX on mac, currently, this test isn't passed because it doesn't return
|
|
|
|
// IME_STATUS_PLUGIN by its bug.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var plugin = document.getElementById("plugin");
|
|
|
|
|
|
|
|
document.activeElement.blur();
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
"runPluginTest: unexpected enabled state when no element has focus");
|
|
|
|
|
|
|
|
plugin.focus();
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN,
|
|
|
|
"runPluginTest: unexpected enabled state when plugin has focus");
|
|
|
|
|
|
|
|
plugin.blur();
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
"runPluginTest: unexpected enabled state when plugin has focus");
|
|
|
|
|
|
|
|
plugin.focus();
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_PLUGIN,
|
|
|
|
"runPluginTest: unexpected enabled state when plugin has focus #2");
|
|
|
|
|
|
|
|
var parent = plugin.parentNode;
|
|
|
|
parent.removeChild(plugin);
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
"runPluginTest: unexpected enabled state when plugin is removed from tree");
|
|
|
|
|
|
|
|
document.getElementById("text").focus();
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
"runPluginTest: unexpected enabled state when input[type=text] has focus");
|
|
|
|
}
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
function runTypeChangingTest()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const kInputControls = [
|
|
|
|
{ id: "text",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"text\"]" },
|
|
|
|
{ id: "text_readonly",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_DISABLED, isReadonly: true,
|
|
|
|
description: "[type=\"text\"][readonly]" },
|
|
|
|
{ id: "password",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_PASSWORD,
|
|
|
|
description: "[type=\"password\"]" },
|
|
|
|
{ id: "password_readonly",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_DISABLED, isReadonly: true,
|
|
|
|
description: "[type=\"password\"][readonly]" },
|
|
|
|
{ id: "checkbox",
|
|
|
|
type: "checkbox", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"checkbox\"]" },
|
|
|
|
{ id: "radio",
|
|
|
|
type: "radio", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"radio\"]" },
|
|
|
|
{ id: "submit",
|
|
|
|
type: "submit", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"submit\"]" },
|
|
|
|
{ id: "reset",
|
|
|
|
type: "reset", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"reset\"]" },
|
|
|
|
{ id: "file",
|
|
|
|
type: "file", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"file\"]" },
|
|
|
|
{ id: "ibutton",
|
|
|
|
type: "button", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"button\"]" },
|
|
|
|
{ id: "image",
|
|
|
|
type: "image", expected: gUtils.IME_STATUS_DISABLED,
|
|
|
|
description: "[type=\"image\"]" },
|
2010-11-23 09:48:45 +03:00
|
|
|
{ id: "url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"url\"]" },
|
|
|
|
{ id: "email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"email\"]" },
|
|
|
|
{ id: "search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"search\"]" },
|
|
|
|
{ id: "tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"tel\"]" },
|
|
|
|
{ id: "number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED,
|
|
|
|
description: "[type=\"number\"]" },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "ime_mode_auto",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"text\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"text\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"text\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"text\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"text\"][ime-mode: disabled;]" },
|
2010-11-23 09:48:45 +03:00
|
|
|
|
|
|
|
{ id: "ime_mode_auto_url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"url\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"url\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"url\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"url\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"url\"][ime-mode: disabled;]" },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"email\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"email\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"email\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"email\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"email\"][ime-mode: disabled;]" },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"search\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"search\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"search\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"search\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"search\"][ime-mode: disabled;]" },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"tel\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"tel\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"tel\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"tel\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"tel\"][ime-mode: disabled;]" },
|
|
|
|
|
|
|
|
{ id: "ime_mode_auto_number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"number\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"number\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"number\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"number\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"number\"][ime-mode: disabled;]" },
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "ime_mode_auto_p",
|
2010-05-04 21:40:39 +04:00
|
|
|
type: "password", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
2009-05-05 10:15:23 +04:00
|
|
|
description: "[type=\"password\"][ime-mode: auto;]" },
|
|
|
|
{ id: "ime_mode_normal_p",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"password\"][ime-mode: normal;]" },
|
|
|
|
{ id: "ime_mode_active_p",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"password\"][ime-mode: active;]" },
|
|
|
|
{ id: "ime_mode_inactive_p",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_ENABLED, imeMode: true,
|
|
|
|
description: "[type=\"password\"][ime-mode: inactive;]" },
|
|
|
|
{ id: "ime_mode_disabled_p",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
|
|
|
description: "[type=\"password\"][ime-mode: disabled;]" }
|
|
|
|
];
|
|
|
|
|
|
|
|
const kInputTypes = [
|
|
|
|
{ type: "", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "text", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "password", expected: gUtils.IME_STATUS_PASSWORD },
|
|
|
|
{ type: "checkbox", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "radio", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "submit", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "reset", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "file", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "button", expected: gUtils.IME_STATUS_DISABLED },
|
2010-11-23 09:48:45 +03:00
|
|
|
{ type: "image", expected: gUtils.IME_STATUS_DISABLED },
|
|
|
|
{ type: "url", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "email", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "search", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "tel", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ type: "number", expected: gUtils.IME_STATUS_ENABLED }
|
2009-05-05 10:15:23 +04:00
|
|
|
];
|
|
|
|
|
|
|
|
function getExpectedIMEEnabled(aNewType, aInputControl)
|
|
|
|
{
|
|
|
|
if (aNewType.expected == gUtils.IME_STATUS_DISABLED ||
|
2010-05-04 21:40:39 +04:00
|
|
|
aInputControl.isReadonly)
|
2009-05-05 10:15:23 +04:00
|
|
|
return gUtils.IME_STATUS_DISABLED;
|
|
|
|
return aInputControl.imeMode ? aInputControl.expected : aNewType.expected;
|
|
|
|
}
|
|
|
|
|
|
|
|
const kOpenedState = [ true, false ];
|
|
|
|
|
|
|
|
for (var i = 0; i < kOpenedState.length; i++) {
|
|
|
|
const kOpened = kOpenedState[i];
|
|
|
|
for (var j = 0; j < kInputControls.length; j++) {
|
|
|
|
const kInput = kInputControls[j];
|
|
|
|
var e = document.getElementById(kInput.id);
|
|
|
|
e.focus();
|
|
|
|
for (var k = 0; k < kInputTypes.length; k++) {
|
|
|
|
const kType = kInputTypes[k];
|
|
|
|
var typeChangingDescription =
|
|
|
|
"\"" + e.getAttribute("type") + "\" to \"" + kInput.type + "\"";
|
|
|
|
e.setAttribute("type", kInput.type);
|
|
|
|
is(gUtils.IMEStatus, kInput.expected,
|
2010-11-23 09:48:45 +03:00
|
|
|
"type attr changing test (IMEStatus): " + typeChangingDescription +
|
|
|
|
" (" + kInput.description + ")");
|
2011-03-25 18:03:33 +03:00
|
|
|
is(gUtils.focusedInputType, kInput.type,
|
2010-11-23 09:48:45 +03:00
|
|
|
"type attr changing test (type): " + typeChangingDescription +
|
2009-05-05 10:15:23 +04:00
|
|
|
" (" + kInput.description + ")");
|
|
|
|
|
|
|
|
const kTestOpenState = kIMEOpenSupported &&
|
|
|
|
gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED &&
|
|
|
|
getExpectedIMEEnabled(kType, kInput) == gUtils.IME_STATUS_ENABLED;
|
|
|
|
if (kTestOpenState) {
|
|
|
|
gUtils.IMEIsOpen = kOpened;
|
|
|
|
}
|
|
|
|
|
|
|
|
typeChangingDescription =
|
|
|
|
"\"" + e.getAttribute("type") + "\" to \"" + kType.type + "\"";
|
|
|
|
if (kType.type != "")
|
|
|
|
e.setAttribute("type", kType.type);
|
|
|
|
else
|
|
|
|
e.removeAttribute("type");
|
|
|
|
|
|
|
|
is(gUtils.IMEStatus, getExpectedIMEEnabled(kType, kInput),
|
2010-11-23 09:48:45 +03:00
|
|
|
"type attr changing test (IMEStatus): " + typeChangingDescription +
|
|
|
|
" (" + kInput.description + ")");
|
2011-03-25 18:03:33 +03:00
|
|
|
is(gUtils.focusedInputType, kType.type,
|
2010-11-23 09:48:45 +03:00
|
|
|
"type attr changing test (type): " + typeChangingDescription +
|
2009-05-05 10:15:23 +04:00
|
|
|
" (" + kInput.description + ")");
|
|
|
|
if (kTestOpenState && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) {
|
|
|
|
is(gUtils.IMEIsOpen, kOpened,
|
|
|
|
"type attr changing test (open state is changed): " +
|
|
|
|
typeChangingDescription + " (" + kInput.description + ")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// reset the type to default
|
|
|
|
e.setAttribute("type", kInput.type);
|
|
|
|
}
|
|
|
|
if (!kIMEOpenSupported)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function runReadonlyChangingTest()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const kInputControls = [
|
|
|
|
{ id: "text",
|
|
|
|
type: "text", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "password",
|
|
|
|
type: "password", expected: gUtils.IME_STATUS_PASSWORD },
|
2010-11-23 09:48:45 +03:00
|
|
|
{ id: "url",
|
|
|
|
type: "url", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "email",
|
|
|
|
type: "email", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "search",
|
|
|
|
type: "search", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "tel",
|
|
|
|
type: "tel", expected: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "number",
|
|
|
|
type: "number", expected: gUtils.IME_STATUS_ENABLED },
|
2009-05-05 10:15:23 +04:00
|
|
|
{ id: "textarea",
|
|
|
|
type: "textarea", expected: gUtils.IME_STATUS_ENABLED }
|
|
|
|
];
|
|
|
|
const kOpenedState = [ true, false ];
|
|
|
|
|
|
|
|
for (var i = 0; i < kOpenedState.length; i++) {
|
|
|
|
const kOpened = kOpenedState[i];
|
|
|
|
for (var j = 0; j < kInputControls.length; j++) {
|
|
|
|
const kInput = kInputControls[j];
|
|
|
|
var e = document.getElementById(kInput.id);
|
|
|
|
e.focus();
|
|
|
|
if (kIMEOpenSupported && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) {
|
|
|
|
gUtils.IMEIsOpen = kOpened;
|
|
|
|
}
|
|
|
|
e.setAttribute("readonly", "readonly");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
"readonly attr setting test: type=" + kInput.type);
|
|
|
|
e.removeAttribute("readonly");
|
|
|
|
is(gUtils.IMEStatus, kInput.expected,
|
|
|
|
"readonly attr removing test: type=" + kInput.type);
|
|
|
|
if (kIMEOpenSupported && gUtils.IMEStatus == gUtils.IME_STATUS_ENABLED) {
|
|
|
|
is(gUtils.IMEIsOpen, kOpened,
|
|
|
|
"readonly attr removing test (open state is changed): type=" +
|
|
|
|
kInput.type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!kIMEOpenSupported)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-04 21:40:39 +04:00
|
|
|
function runComplexContenteditableTests()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var description = "runReadonlyChangingOnContenteditable: ";
|
|
|
|
|
|
|
|
var container = document.getElementById("display");
|
|
|
|
var button = document.getElementById("button");
|
|
|
|
|
|
|
|
// the editor has focus directly.
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
container.focus();
|
|
|
|
|
|
|
|
is(gFM.focusedElement, container,
|
|
|
|
description + "The editor doesn't get focus");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "IME isn't enabled on HTML editor");
|
|
|
|
const kReadonly =
|
2018-02-28 20:51:33 +03:00
|
|
|
Ci.nsIPlaintextEditor.eEditorReadonlyMask;
|
2010-05-04 21:40:39 +04:00
|
|
|
var editor =
|
2018-02-28 20:51:33 +03:00
|
|
|
window.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebNavigation).
|
|
|
|
QueryInterface(Ci.nsIDocShell).editor;
|
2010-05-04 21:40:39 +04:00
|
|
|
var flags = editor.flags;
|
|
|
|
editor.flags = flags | kReadonly;
|
|
|
|
is(gFM.focusedElement, container,
|
|
|
|
description + "The editor loses focus by flag change");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
description + "IME is still enabled on readonly HTML editor");
|
|
|
|
editor.flags = flags;
|
|
|
|
is(gFM.focusedElement, container,
|
|
|
|
description + "The editor loses focus by flag change #2");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "IME is still disabled, the editor isn't readonly now");
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
todo_is(gFM.focusedElement, null,
|
|
|
|
description + "The container still has focus, the editor has been no editable");
|
|
|
|
todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
description + "IME is still enabled on the editor, the editor has been no editable");
|
|
|
|
|
|
|
|
// a button which is in the editor has focus
|
|
|
|
button.focus();
|
|
|
|
is(gFM.focusedElement, button,
|
|
|
|
description + "The button doesn't get focus");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
description + "IME is enabled on the button");
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
is(gFM.focusedElement, button,
|
|
|
|
description + "The button loses focus, the container is editable now");
|
|
|
|
todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "IME is still disabled on the button, the container is editable now");
|
|
|
|
editor =
|
2018-02-28 20:51:33 +03:00
|
|
|
window.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebNavigation).
|
|
|
|
QueryInterface(Ci.nsIDocShell).editor;
|
2010-05-04 21:40:39 +04:00
|
|
|
flags = editor.flags;
|
|
|
|
editor.flags = flags | kReadonly;
|
|
|
|
is(gFM.focusedElement, button,
|
|
|
|
description + "The button loses focus by changing editor flags");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
description + "IME is still enabled on the button, the container is readonly now");
|
|
|
|
editor.flags = flags;
|
|
|
|
is(gFM.focusedElement, button,
|
|
|
|
description + "The button loses focus by changing editor flags #2");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "IME is still disabled on the button, the container isn't readonly now");
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
is(gFM.focusedElement, button,
|
|
|
|
description + "The button loses focus, the container has been no editable");
|
|
|
|
todo_is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
|
|
|
description + "IME is still enabled on the button, the container has been no editable");
|
|
|
|
|
|
|
|
description = "testOnIndependentEditor: ";
|
|
|
|
function testOnIndependentEditor(aEditor, aEditorDescription)
|
|
|
|
{
|
|
|
|
var isReadonly = aEditor.readOnly;
|
|
|
|
var expectedState =
|
|
|
|
aEditor.readOnly ? gUtils.IME_STATUS_DISABLED : gUtils.IME_STATUS_ENABLED;
|
|
|
|
var unexpectedStateDescription =
|
|
|
|
expectedState != gUtils.IME_STATUS_ENABLED ? "enabled" : "disabled";
|
|
|
|
aEditor.focus();
|
|
|
|
is(gFM.focusedElement, aEditor,
|
|
|
|
description + "The " + aEditorDescription + " doesn't get focus");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME is " + unexpectedStateDescription +
|
|
|
|
" on the " + aEditorDescription);
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
is(gFM.focusedElement, aEditor,
|
|
|
|
description + "The " + aEditorDescription +
|
|
|
|
" loses focus, the container is editable now");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription +
|
|
|
|
" on the " + aEditorDescription + ", the container is editable now");
|
|
|
|
editor =
|
2018-02-28 20:51:33 +03:00
|
|
|
window.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebNavigation).
|
|
|
|
QueryInterface(Ci.nsIDocShell).editor;
|
2010-05-04 21:40:39 +04:00
|
|
|
flags = editor.flags;
|
|
|
|
editor.flags = flags | kReadonly;
|
|
|
|
is(gFM.focusedElement, aEditor,
|
|
|
|
description + "The " + aEditorDescription +
|
|
|
|
" loses focus by changing editor flags");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on the " +
|
|
|
|
aEditorDescription + ", the container is readonly now");
|
|
|
|
editor.flags = flags;
|
|
|
|
is(gFM.focusedElement, aEditor,
|
|
|
|
description + "The " + aEditorDescription +
|
|
|
|
" loses focus by changing editor flags #2");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on the " +
|
|
|
|
aEditorDescription + ", the container isn't readonly now");
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
is(gFM.focusedElement, aEditor,
|
|
|
|
description + "The " + aEditorDescription +
|
|
|
|
" loses focus, the container has been no editable");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on the " +
|
|
|
|
aEditorDescription + ", the container has been no editable");
|
|
|
|
}
|
|
|
|
|
|
|
|
// a textarea which is in the editor has focus
|
|
|
|
testOnIndependentEditor(document.getElementById("textarea"),
|
|
|
|
"textarea");
|
|
|
|
// a readonly textarea which is in the editor has focus
|
|
|
|
testOnIndependentEditor(document.getElementById("textarea_readonly"),
|
|
|
|
"textarea[readonly]");
|
|
|
|
// an input field which is in the editor has focus
|
|
|
|
testOnIndependentEditor(document.getElementById("text"),
|
|
|
|
"input[type=\"text\"]");
|
|
|
|
// a readonly input field which is in the editor has focus
|
|
|
|
testOnIndependentEditor(document.getElementById("text_readonly"),
|
|
|
|
"input[type=\"text\"][readonly]");
|
|
|
|
|
|
|
|
description = "testOnOutsideOfEditor: ";
|
|
|
|
function testOnOutsideOfEditor(aFocusNode, aFocusNodeDescription, aEditor)
|
|
|
|
{
|
|
|
|
if (aFocusNode) {
|
|
|
|
aFocusNode.focus();
|
|
|
|
is(gFM.focusedElement, aFocusNode,
|
|
|
|
description + "The " + aFocusNodeDescription + " doesn't get focus");
|
|
|
|
} else {
|
|
|
|
if (document.activeElement) {
|
|
|
|
document.activeElement.blur();
|
|
|
|
}
|
|
|
|
is(gFM.focusedElement, null,
|
|
|
|
description + "Unexpected element has focus");
|
|
|
|
}
|
|
|
|
var expectedState =
|
|
|
|
aFocusNode ? gUtils.IMEStatus : gUtils.IME_STATUS_DISABLED;
|
|
|
|
var unexpectedStateDescription =
|
|
|
|
expectedState != gUtils.IME_STATUS_ENABLED ? "enabled" : "disabled";
|
|
|
|
|
|
|
|
aEditor.setAttribute("contenteditable", "true");
|
|
|
|
is(gFM.focusedElement, aFocusNode,
|
|
|
|
description + "The " + aFocusNodeDescription +
|
|
|
|
" loses focus, a HTML editor is editable now");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription +
|
|
|
|
" on the " + aFocusNodeDescription +
|
|
|
|
", the HTML editor is editable now");
|
|
|
|
editor =
|
2018-02-28 20:51:33 +03:00
|
|
|
window.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebNavigation).
|
|
|
|
QueryInterface(Ci.nsIDocShell).editor;
|
2010-05-04 21:40:39 +04:00
|
|
|
flags = editor.flags;
|
|
|
|
editor.flags = flags | kReadonly;
|
|
|
|
is(gFM.focusedElement, aFocusNode,
|
|
|
|
description + aFocusNodeDescription +
|
|
|
|
" loses focus by changing HTML editor flags");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on " +
|
|
|
|
aFocusNodeDescription + ", the HTML editor is readonly now");
|
|
|
|
editor.flags = flags;
|
|
|
|
is(gFM.focusedElement, aFocusNode,
|
|
|
|
description + aFocusNodeDescription +
|
|
|
|
" loses focus by changing HTML editor flags #2");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on " +
|
|
|
|
aFocusNodeDescription + ", the HTML editor isn't readonly now");
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
is(gFM.focusedElement, aFocusNode,
|
|
|
|
description + aFocusNodeDescription +
|
|
|
|
" loses focus, the HTML editor has been no editable");
|
|
|
|
is(gUtils.IMEStatus, expectedState,
|
|
|
|
description + "IME becomes " + unexpectedStateDescription + " on " +
|
|
|
|
aFocusNodeDescription + ", the HTML editor has been no editable");
|
|
|
|
}
|
|
|
|
|
|
|
|
var div = document.getElementById("contenteditableEditor");
|
|
|
|
// a textarea which is outside of the editor has focus
|
|
|
|
testOnOutsideOfEditor(document.getElementById("textarea"), "textarea", div);
|
|
|
|
// a readonly textarea which is outside of the editor has focus
|
|
|
|
testOnOutsideOfEditor(document.getElementById("textarea_readonly"),
|
|
|
|
"textarea[readonly]", div);
|
|
|
|
// an input field which is outside of the editor has focus
|
|
|
|
testOnOutsideOfEditor(document.getElementById("text"),
|
|
|
|
"input[type=\"text\"]", div);
|
|
|
|
// a readonly input field which outside of the editor has focus
|
|
|
|
testOnOutsideOfEditor(document.getElementById("text_readonly"),
|
|
|
|
"input[type=\"text\"][readonly]", div);
|
|
|
|
// a readonly input field which outside of the editor has focus
|
|
|
|
testOnOutsideOfEditor(document.getElementById("button"), "button", div);
|
|
|
|
// nobody has focus.
|
|
|
|
testOnOutsideOfEditor(null, "nobody", div);
|
|
|
|
}
|
2010-04-21 17:13:08 +04:00
|
|
|
|
2010-05-27 06:04:14 +04:00
|
|
|
function runEditorFlagChangeTests()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var description = "runEditorFlagChangeTests: ";
|
|
|
|
|
|
|
|
var container = document.getElementById("display");
|
|
|
|
|
2016-03-16 21:20:30 +03:00
|
|
|
// Reset selection from previous tests.
|
|
|
|
window.getSelection().collapse(container, 0);
|
|
|
|
|
2010-05-27 06:04:14 +04:00
|
|
|
// the editor has focus directly.
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
container.focus();
|
|
|
|
|
|
|
|
is(gFM.focusedElement, container,
|
|
|
|
description + "The editor doesn't get focus");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "IME isn't enabled on HTML editor");
|
|
|
|
const kIMEStateChangeFlags =
|
2018-02-28 20:51:33 +03:00
|
|
|
Ci.nsIPlaintextEditor.eEditorPasswordMask |
|
|
|
|
Ci.nsIPlaintextEditor.eEditorReadonlyMask |
|
|
|
|
Ci.nsIPlaintextEditor.eEditorDisabledMask;
|
2010-05-27 06:04:14 +04:00
|
|
|
var editor =
|
2018-02-28 20:51:33 +03:00
|
|
|
window.QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIWebNavigation).
|
|
|
|
QueryInterface(Ci.nsIDocShell).editor;
|
2010-05-27 06:04:14 +04:00
|
|
|
var flags = editor.flags;
|
|
|
|
|
|
|
|
// input characters
|
2014-10-07 14:01:50 +04:00
|
|
|
synthesizeCompositionChange(
|
2010-05-27 06:04:14 +04:00
|
|
|
{ "composition":
|
|
|
|
{ "string": "\u3078\u3093\u3057\u3093",
|
|
|
|
"clauses":
|
|
|
|
[
|
2015-01-28 09:27:33 +03:00
|
|
|
{ "length": 4, "attr": COMPOSITION_ATTR_RAW_CLAUSE }
|
2010-05-27 06:04:14 +04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
"caret": { "start": 4, "length": 0 }
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.flags &= ~kIMEStateChangeFlags;
|
2016-12-20 15:47:31 +03:00
|
|
|
ok(editor.composing,
|
2010-05-27 06:04:14 +04:00
|
|
|
description + "#1 IME composition was committed unexpectedly");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "#1 IME isn't enabled on HTML editor");
|
|
|
|
|
|
|
|
editor.flags |= ~kIMEStateChangeFlags;
|
2016-12-20 15:47:31 +03:00
|
|
|
ok(editor.composing,
|
2010-05-27 06:04:14 +04:00
|
|
|
description + "#2 IME composition was committed unexpectedly");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "#2 IME isn't enabled on HTML editor");
|
|
|
|
|
|
|
|
editor.flags = flags;
|
2016-12-20 15:47:31 +03:00
|
|
|
ok(editor.composing,
|
2010-05-27 06:04:14 +04:00
|
|
|
description + "#3 IME composition was committed unexpectedly");
|
|
|
|
is(gUtils.IMEStatus, gUtils.IME_STATUS_ENABLED,
|
|
|
|
description + "#3 IME isn't enabled on HTML editor");
|
|
|
|
|
|
|
|
// cancel the composition
|
2014-11-25 08:02:32 +03:00
|
|
|
synthesizeComposition({ type: "compositioncommit", data: "" });
|
2010-05-27 06:04:14 +04:00
|
|
|
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
}
|
|
|
|
|
2010-04-21 17:13:08 +04:00
|
|
|
function runEditableSubframeTests()
|
|
|
|
{
|
|
|
|
window.open("window_imestate_iframes.html", "_blank",
|
|
|
|
"width=600,height=600");
|
|
|
|
}
|
|
|
|
|
2010-08-16 12:20:27 +04:00
|
|
|
function runTestPasswordFieldOnDialog()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (document.activeElement) {
|
|
|
|
document.activeElement.blur();
|
|
|
|
}
|
|
|
|
|
|
|
|
var dialog;
|
|
|
|
|
|
|
|
function WindowObserver()
|
|
|
|
{
|
2018-02-28 20:51:33 +03:00
|
|
|
Cc["@mozilla.org/observer-service;1"].
|
2018-02-28 20:51:34 +03:00
|
|
|
getService(Ci.nsIObserverService).
|
|
|
|
addObserver(this, "domwindowopened");
|
2010-08-16 12:20:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
WindowObserver.prototype = {
|
|
|
|
QueryInterface: function (iid)
|
|
|
|
{
|
2018-02-28 20:51:33 +03:00
|
|
|
if (iid.equals(Ci.nsIObserver) ||
|
|
|
|
iid.equals(Ci.nsISupports)) {
|
2010-08-16 12:20:27 +04:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
observe: function (subject, topic, data)
|
|
|
|
{
|
|
|
|
if (topic === "domwindowopened") {
|
|
|
|
ok(true, "dialog window is created");
|
2018-02-28 20:51:33 +03:00
|
|
|
dialog = subject.QueryInterface(Ci.nsIDOMWindow);
|
2017-01-17 13:50:25 +03:00
|
|
|
dialog.addEventListener("load", onPasswordDialogLoad);
|
2010-08-16 12:20:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var observer = new WindowObserver();
|
|
|
|
var arg1 = new Object(), arg2 = new Object();
|
2018-02-28 20:51:33 +03:00
|
|
|
Cc["@mozilla.org/embedcomp/prompt-service;1"].
|
2018-02-28 20:51:34 +03:00
|
|
|
getService(Ci.nsIPromptService).
|
|
|
|
promptPassword(window, "title", "text", arg1, "msg", arg2);
|
2010-08-16 12:20:27 +04:00
|
|
|
|
|
|
|
ok(true, "password dialog was closed");
|
|
|
|
|
2018-02-28 20:51:33 +03:00
|
|
|
Cc["@mozilla.org/observer-service;1"].
|
2018-02-28 20:51:34 +03:00
|
|
|
getService(Ci.nsIObserverService).
|
|
|
|
removeObserver(observer, "domwindowopened");
|
2010-08-16 12:20:27 +04:00
|
|
|
|
|
|
|
var passwordField;
|
|
|
|
|
|
|
|
function onPasswordDialogLoad()
|
|
|
|
{
|
|
|
|
ok(true, "onPasswordDialogLoad is called");
|
2017-01-17 13:50:25 +03:00
|
|
|
dialog.removeEventListener("load", onPasswordDialogLoad);
|
2010-08-16 12:20:27 +04:00
|
|
|
passwordField = dialog.document.getElementById("password1Textbox");
|
2017-01-17 13:50:25 +03:00
|
|
|
passwordField.addEventListener("focus", onPasswordFieldFocus);
|
2010-08-16 12:20:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onPasswordFieldFocus()
|
|
|
|
{
|
|
|
|
ok(true, "onPasswordFieldFocus is called");
|
2017-01-17 13:50:25 +03:00
|
|
|
passwordField.removeEventListener("focus", onPasswordFieldFocus);
|
2010-08-16 12:20:27 +04:00
|
|
|
var utils = dialog.
|
2018-02-28 20:51:33 +03:00
|
|
|
QueryInterface(Ci.nsIInterfaceRequestor).
|
|
|
|
getInterface(Ci.nsIDOMWindowUtils);
|
2010-08-16 12:20:27 +04:00
|
|
|
is(utils.IMEStatus, utils.IME_STATUS_PASSWORD,
|
|
|
|
"IME isn't disabled on a password field of password dialog");
|
|
|
|
synthesizeKey("VK_ESCAPE", { }, dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-18 04:15:01 +04:00
|
|
|
// Bug 580388 and bug 808287
|
|
|
|
function runEditorReframeTests(aCallback)
|
2012-11-09 12:40:40 +04:00
|
|
|
{
|
|
|
|
if (document.activeElement) {
|
|
|
|
document.activeElement.blur();
|
|
|
|
}
|
|
|
|
|
2015-05-26 10:45:26 +03:00
|
|
|
var IMEFocus = 0;
|
|
|
|
var IMEBlur = 0;
|
2012-11-09 12:40:40 +04:00
|
|
|
var IMEHasFocus = false;
|
2015-05-26 10:45:26 +03:00
|
|
|
var TIPCallback = function(aTIP, aNotification) {
|
|
|
|
switch (aNotification.type) {
|
|
|
|
case "request-to-commit":
|
|
|
|
aTIP.commitComposition();
|
|
|
|
break;
|
|
|
|
case "request-to-cancel":
|
|
|
|
aTIP.cancelComposition();
|
|
|
|
break;
|
|
|
|
case "notify-focus":
|
|
|
|
IMEFocus++;
|
2012-11-09 12:40:40 +04:00
|
|
|
IMEHasFocus = true;
|
|
|
|
break;
|
2015-05-26 10:45:26 +03:00
|
|
|
case "notify-blur":
|
|
|
|
IMEBlur++;
|
2012-11-09 12:40:40 +04:00
|
|
|
IMEHasFocus = false;
|
|
|
|
break;
|
|
|
|
}
|
2015-05-26 10:45:26 +03:00
|
|
|
return true;
|
2012-11-09 12:40:40 +04:00
|
|
|
};
|
|
|
|
|
2018-02-28 20:51:33 +03:00
|
|
|
var TIP = Cc["@mozilla.org/text-input-processor;1"]
|
|
|
|
.createInstance(Ci.nsITextInputProcessor);
|
2015-05-26 10:45:26 +03:00
|
|
|
if (!TIP.beginInputTransactionForTests(window, TIPCallback)) {
|
|
|
|
ok(false, "runEditorReframeTests(): failed to begin input transaction");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var input = document.getElementById("text");
|
|
|
|
input.focus();
|
|
|
|
|
|
|
|
is(IMEFocus, 1, "runEditorReframeTests(): IME should receive a focus notification by a call of <input>.focus()");
|
|
|
|
is(IMEBlur, 0, "runEditorReframeTests(): IME shouldn't receive a blur notification by a call of <input>.focus()");
|
|
|
|
ok(IMEHasFocus, "runEditorReframeTests(): IME should have focus because <input>.focus() is called");
|
|
|
|
|
|
|
|
IMEFocus = IMEBlur = 0;
|
|
|
|
|
|
|
|
input.style.overflow = "visible";
|
|
|
|
|
2012-11-09 12:40:40 +04:00
|
|
|
var onInput = function (aEvent) {
|
|
|
|
aEvent.target.style.overflow = "hidden";
|
|
|
|
}
|
|
|
|
input.addEventListener("input", onInput, true);
|
|
|
|
|
2015-05-26 10:45:26 +03:00
|
|
|
var AKey = new KeyboardEvent("", { key: "a", code: "KeyA", keyCode: KeyboardEvent.DOM_VK_A });
|
|
|
|
TIP.keydown(AKey);
|
|
|
|
TIP.keyup(AKey);
|
2012-11-09 12:40:40 +04:00
|
|
|
|
|
|
|
hitEventLoop(function () {
|
2015-05-26 10:45:26 +03:00
|
|
|
is(IMEFocus, 0, "runEditorReframeTests(): IME shouldn't receive a focus notification during reframing");
|
|
|
|
is(IMEBlur, 0, "runEditorReframeTests(): IME shouldn't receive a blur notification during reframing");
|
|
|
|
ok(IMEHasFocus, "runEditorReframeTests(): IME must have focus even after reframing");
|
|
|
|
|
|
|
|
var onFocus = function(aEvent) {
|
|
|
|
// Perform a style change and query during focus to trigger reframing
|
|
|
|
input.style.overflow = "visible";
|
|
|
|
synthesizeQuerySelectedText();
|
|
|
|
};
|
|
|
|
input.addEventListener("focus", onFocus);
|
|
|
|
IMEFocus = IMEBlur = 0;
|
2012-11-18 04:15:01 +04:00
|
|
|
|
|
|
|
input.blur();
|
|
|
|
input.focus();
|
2015-05-26 10:45:26 +03:00
|
|
|
TIP.keydown(AKey);
|
|
|
|
TIP.keyup(AKey);
|
2012-11-18 04:15:01 +04:00
|
|
|
|
|
|
|
hitEventLoop(function() {
|
2015-05-26 10:45:26 +03:00
|
|
|
is(IMEFocus, 1, "runEditorReframeTests(): IME should receive a focus notification at focus but shouldn't receive it during reframing");
|
|
|
|
is(IMEBlur, 1, "runEditorReframeTests(): IME should receive a blur notification at blur but shouldn't receive it during reframing");
|
|
|
|
ok(IMEHasFocus, "runEditorReframeTests(): IME sould have focus after reframing during focus");
|
|
|
|
|
|
|
|
input.removeEventListener("input", onInput, true);
|
|
|
|
input.removeEventListener("focus", onFocus);
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2015-05-26 10:45:26 +03:00
|
|
|
input.style.overflow = "visible";
|
|
|
|
input.value = "";
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2015-05-26 10:45:26 +03:00
|
|
|
TIP = null;
|
2012-11-09 12:40:40 +04:00
|
|
|
|
2015-05-26 10:45:26 +03:00
|
|
|
hitEventLoop(aCallback, 20);
|
2012-11-18 04:15:01 +04:00
|
|
|
}, 20);
|
2012-11-09 12:40:40 +04:00
|
|
|
}, 20);
|
|
|
|
}
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
function runTests()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported && !kIMEOpenSupported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// test for normal contents.
|
|
|
|
runBasicTest(false, false, "Testing of normal contents");
|
|
|
|
|
2009-12-04 11:03:27 +03:00
|
|
|
// test for plugin contents
|
|
|
|
runPluginTest();
|
|
|
|
|
2009-05-05 10:15:23 +04:00
|
|
|
var container = document.getElementById("display");
|
|
|
|
// test for contentEditable="true"
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
runBasicTest(true, false, "Testing [contentEditable=\"true\"]");
|
|
|
|
|
|
|
|
// test for contentEditable="false"
|
|
|
|
container.setAttribute("contenteditable", "false");
|
|
|
|
runBasicTest(false, false, "Testing [contentEditable=\"false\"]");
|
|
|
|
|
|
|
|
// test for removing contentEditable
|
|
|
|
container.setAttribute("contenteditable", "true");
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
runBasicTest(false, false, "Testing after contentEditable to be removed");
|
|
|
|
|
|
|
|
// test designMode
|
|
|
|
document.designMode = "on";
|
|
|
|
runBasicTest(true, true, "Testing designMode=\"on\"");
|
|
|
|
document.designMode = "off";
|
Bug 178324, refactor focus by moving all focus handling into one place and simplifying it, add many tests, fixes many other bugs too numerous to mention in this small checkin comment, r=josh,smichaud,ere,dbaron,marco,neil,gavin,smaug,sr=smaug (CLOSED TREE)
2009-06-10 22:00:39 +04:00
|
|
|
document.getElementById("text").focus();
|
2009-05-05 10:15:23 +04:00
|
|
|
runBasicTest(false, false, "Testing designMode=\"off\"");
|
|
|
|
|
|
|
|
// changing input[type] values
|
2010-05-04 21:40:39 +04:00
|
|
|
// XXX currently, type attribute changing doesn't work fine. bug 559728.
|
2009-05-05 10:15:23 +04:00
|
|
|
// runTypeChangingTest();
|
|
|
|
|
|
|
|
// changing readonly attribute
|
2010-05-04 21:40:39 +04:00
|
|
|
runReadonlyChangingTest();
|
|
|
|
|
|
|
|
// complex contenteditable editor's tests
|
|
|
|
runComplexContenteditableTests();
|
2009-05-05 10:15:23 +04:00
|
|
|
|
2010-05-27 06:04:14 +04:00
|
|
|
// test whether the IME state and composition are not changed unexpectedly
|
|
|
|
runEditorFlagChangeTests();
|
|
|
|
|
2010-08-16 12:20:27 +04:00
|
|
|
// test password field on dialog
|
2010-08-16 13:01:01 +04:00
|
|
|
// XXX temporary disable against failure
|
|
|
|
//runTestPasswordFieldOnDialog();
|
2010-08-16 12:20:27 +04:00
|
|
|
|
2012-11-09 12:40:40 +04:00
|
|
|
// Asynchronous tests
|
2012-11-18 04:15:01 +04:00
|
|
|
runEditorReframeTests(function () {
|
2012-11-09 12:40:40 +04:00
|
|
|
// This will call onFinish(), so, this test must be the last.
|
|
|
|
runEditableSubframeTests();
|
|
|
|
});
|
2010-04-21 17:13:08 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function onFinish()
|
|
|
|
{
|
2009-05-05 10:15:23 +04:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|