2010-05-04 10:40:39 -07:00
|
|
|
<html style="ime-mode: disabled;">
|
2009-05-04 23:15:23 -07:00
|
|
|
<head>
|
|
|
|
<title>Test for IME state controling</title>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
|
|
|
<script type="text/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
2010-05-26 19:04:14 -07:00
|
|
|
<script type="text/javascript"
|
|
|
|
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
|
2009-05-04 23:15:23 -07:00
|
|
|
<link rel="stylesheet" type="text/css"
|
|
|
|
href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
2010-05-04 10:40:39 -07:00
|
|
|
<body onload="setTimeout(runTests, 0);" style="ime-mode: disabled;">
|
|
|
|
<div id="display" style="ime-mode: disabled;">
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07: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 10:40:39 -07:00
|
|
|
<a id="a_href" href="about:blank">a[href]</a><br/>
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07: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 00:03:27 -08:00
|
|
|
|
|
|
|
<!-- plugin -->
|
|
|
|
<object type="application/x-test" id="plugin"></object><br/>
|
2010-05-04 10:40:39 -07: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-04 23:15:23 -07: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 11:00:39 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
2009-05-04 23:15:23 -07:00
|
|
|
var gUtils = window.
|
|
|
|
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
2010-11-22 22:48:45 -08:00
|
|
|
var gUtils2 = gUtils.QueryInterface(Components.interfaces.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
|
|
|
|
/*
|
|
|
|
var gUtils2 = window.
|
|
|
|
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIDOMWindowUtils_MOZILLA_2_0_BRANCH);
|
|
|
|
*/
|
2010-05-04 10:40:39 -07:00
|
|
|
var gFM = Components.classes["@mozilla.org/focus-manager;1"].
|
|
|
|
getService(Components.interfaces.nsIFocusManager);
|
2009-05-04 23:15:23 -07: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)
|
|
|
|
{
|
|
|
|
function test(aTest)
|
|
|
|
{
|
|
|
|
function moveFocus(aTest)
|
|
|
|
{
|
2010-05-04 10:40:39 -07: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-04 23:15:23 -07:00
|
|
|
} else {
|
2010-05-04 10:40:39 -07:00
|
|
|
document.getElementById("text").focus();
|
|
|
|
}
|
|
|
|
var previousFocusedElement = gFM.focusedElement;
|
|
|
|
var element = document.getElementById(aTest.id);
|
|
|
|
if (element.contentDocument) {
|
|
|
|
element = element.contentDocument.documentElement;
|
|
|
|
}
|
|
|
|
element.focus();
|
|
|
|
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-04 23:15:23 -07:00
|
|
|
}
|
2010-05-04 10:40:39 -07:00
|
|
|
is(focusedElement, previousFocusedElement,
|
|
|
|
aDescription + ": " + aTest.description + ", focus moved as unexpected");
|
|
|
|
return (previousFocusedElement == focusedElement);
|
2009-05-04 23:15:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function testOpened(aTest, aOpened)
|
|
|
|
{
|
|
|
|
document.getElementById("text").focus();
|
|
|
|
gUtils.IMEIsOpen = aOpened;
|
2010-05-04 10:40:39 -07:00
|
|
|
if (!moveFocus(aTest)) {
|
|
|
|
return;
|
|
|
|
}
|
2009-05-04 23:15:23 -07: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) {
|
2010-05-04 10:40:39 -07:00
|
|
|
if (!moveFocus(aTest)) {
|
|
|
|
return;
|
|
|
|
}
|
2009-05-04 23:15:23 -07:00
|
|
|
enabled = gUtils.IMEStatus;
|
2010-11-22 22:48:45 -08:00
|
|
|
inputtype = gUtils2.focusedInputType;
|
2010-05-04 10:40:39 -07:00
|
|
|
is(enabled, aTest.expectedEnabled,
|
2009-05-04 23:15:23 -07:00
|
|
|
aDescription + ": " + aTest.description + ", wrong enabled state");
|
2010-11-22 22:48:45 -08: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-04 23:15:23 -07: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 10:40:39 -07: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 11:00:39 -07:00
|
|
|
document.activeElement.blur();
|
2010-05-04 10:40:39 -07:00
|
|
|
is(gUtils.IMEStatus,
|
|
|
|
aInDesignMode ? gUtils.IME_STATUS_ENABLED : gUtils.IME_STATUS_DISABLED,
|
2009-05-04 23:15:23 -07:00
|
|
|
aDescription + ": unexpected enabled state when no element has focus");
|
|
|
|
}
|
|
|
|
|
2010-05-04 10:40:39 -07: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-04 23:15:23 -07:00
|
|
|
const kTests = [
|
|
|
|
{ id: "text",
|
|
|
|
description: "input[type=text]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2010-11-22 22:48:45 -08:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
expectedType: "text" },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "text_readonly",
|
|
|
|
description: "input[type=text][readonly]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "password",
|
|
|
|
description: "input[type=password]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2010-11-22 22:48:45 -08:00
|
|
|
expectedEnabled: kEnabledStateOnPasswordField,
|
|
|
|
expectedType: "password" },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "password_readonly",
|
|
|
|
description: "input[type=password][readonly]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "checkbox",
|
|
|
|
description: "input[type=checkbox]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "radio",
|
|
|
|
description: "input[type=radio]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "submit",
|
|
|
|
description: "input[type=submit]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "reset",
|
|
|
|
description: "input[type=reset]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "file",
|
|
|
|
description: "input[type=file]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "button",
|
|
|
|
description: "input[type=button]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "image",
|
|
|
|
description: "input[type=image]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2010-11-22 22:48:45 -08: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-04 23:15:23 -07:00
|
|
|
|
|
|
|
// form controls
|
|
|
|
{ id: "button",
|
|
|
|
description: "button",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "textarea",
|
|
|
|
description: "textarea",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "textarea_readonly",
|
|
|
|
description: "textarea[readonly]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnReadonlyField },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "select",
|
|
|
|
description: "select (dropdown list)",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "select_multiple",
|
|
|
|
description: "select (list box)",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
|
|
|
|
// a element
|
|
|
|
{ id: "a_href",
|
|
|
|
description: "a[href]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aIsEditable && !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnNonEditableElement },
|
2009-05-04 23:15:23 -07:00
|
|
|
|
|
|
|
// ime-mode
|
|
|
|
{ id: "ime_mode_auto",
|
|
|
|
description: "input[type=text][style=\"ime-mode: auto;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal",
|
|
|
|
description: "input[type=text][style=\"ime-mode: normal;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07: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 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07: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 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled",
|
|
|
|
description: "input[type=text][style=\"ime-mode: disabled;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2010-11-22 22:48:45 -08: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-04 23:15:23 -07:00
|
|
|
{ id: "ime_mode_auto_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: auto;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "ime_mode_normal_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: normal;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07: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 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07: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 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled_p",
|
|
|
|
description: "input[type=password][style=\"ime-mode: disabled;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
|
|
|
expectedEnabled: kEnabledStateOnPasswordField },
|
2009-05-04 23:15:23 -07:00
|
|
|
{ id: "ime_mode_auto",
|
|
|
|
description: "textarea[style=\"ime-mode: auto;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_normal",
|
|
|
|
description: "textarea[style=\"ime-mode: normal;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
|
|
|
{ id: "ime_mode_active",
|
|
|
|
description: "textarea[style=\"ime-mode: active;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
changeOpened: true, expectedOpened: true },
|
|
|
|
{ id: "ime_mode_inactive",
|
|
|
|
description: "textarea[style=\"ime-mode: inactive;\"]",
|
2010-05-04 10:40:39 -07:00
|
|
|
focusable: !aInDesignMode,
|
2009-05-04 23:15:23 -07:00
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED,
|
|
|
|
changeOpened: true, expectedOpened: false },
|
|
|
|
{ id: "ime_mode_disabled",
|
|
|
|
description: "textarea[style=\"ime-mode: disabled;\"]",
|
2010-05-04 10:40:39 -07: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,
|
|
|
|
expectedEnabled: gUtils.IME_STATUS_ENABLED },
|
2009-05-04 23:15:23 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
for (var i = 0; i < kTests.length; i++) {
|
|
|
|
test(kTests[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-04 00:03:27 -08: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-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07:00
|
|
|
{ id: "ime_mode_auto_p",
|
2010-05-04 10:40:39 -07:00
|
|
|
type: "password", expected: gUtils.IME_STATUS_PASSWORD, imeMode: true,
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07:00
|
|
|
];
|
|
|
|
|
|
|
|
function getExpectedIMEEnabled(aNewType, aInputControl)
|
|
|
|
{
|
|
|
|
if (aNewType.expected == gUtils.IME_STATUS_DISABLED ||
|
2010-05-04 10:40:39 -07:00
|
|
|
aInputControl.isReadonly)
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08:00
|
|
|
"type attr changing test (IMEStatus): " + typeChangingDescription +
|
|
|
|
" (" + kInput.description + ")");
|
|
|
|
is(gUtils2.focusedInputType, kInput.type,
|
|
|
|
"type attr changing test (type): " + typeChangingDescription +
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08:00
|
|
|
"type attr changing test (IMEStatus): " + typeChangingDescription +
|
|
|
|
" (" + kInput.description + ")");
|
|
|
|
is(gUtils2.focusedInputType, kType.type,
|
|
|
|
"type attr changing test (type): " + typeChangingDescription +
|
2009-05-04 23:15:23 -07: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-22 22:48:45 -08: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-04 23:15:23 -07: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 10:40:39 -07: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 =
|
|
|
|
Components.interfaces.nsIPlaintextEditor.eEditorReadonlyMask;
|
|
|
|
var editor =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIEditorDocShell).editor;
|
|
|
|
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 =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIEditorDocShell).editor;
|
|
|
|
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 =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIEditorDocShell).editor;
|
|
|
|
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 =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIEditorDocShell).editor;
|
|
|
|
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 06:13:08 -07:00
|
|
|
|
2010-05-26 19:04:14 -07:00
|
|
|
function runEditorFlagChangeTests()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var description = "runEditorFlagChangeTests: ";
|
|
|
|
|
|
|
|
var container = document.getElementById("display");
|
|
|
|
|
|
|
|
// 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 =
|
|
|
|
Components.interfaces.nsIPlaintextEditor.eEditorPasswordMask |
|
|
|
|
Components.interfaces.nsIPlaintextEditor.eEditorReadonlyMask |
|
|
|
|
Components.interfaces.nsIPlaintextEditor.eEditorDisabledMask;
|
|
|
|
var editor =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIWebNavigation).
|
|
|
|
QueryInterface(Components.interfaces.nsIEditorDocShell).editor;
|
|
|
|
var editorIMESupport =
|
|
|
|
editor.QueryInterface(Components.interfaces.nsIEditorIMESupport);
|
|
|
|
var flags = editor.flags;
|
|
|
|
|
|
|
|
// start composition
|
|
|
|
synthesizeComposition(true);
|
|
|
|
|
|
|
|
// input characters
|
|
|
|
synthesizeText(
|
|
|
|
{ "composition":
|
|
|
|
{ "string": "\u3078\u3093\u3057\u3093",
|
|
|
|
"clauses":
|
|
|
|
[
|
|
|
|
{ "length": 4, "attr": gUtils.COMPOSITION_ATTR_RAWINPUT }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"caret": { "start": 4, "length": 0 }
|
|
|
|
});
|
|
|
|
|
|
|
|
editor.flags &= ~kIMEStateChangeFlags;
|
|
|
|
ok(editorIMESupport.composing,
|
|
|
|
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;
|
|
|
|
ok(editorIMESupport.composing,
|
|
|
|
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;
|
|
|
|
ok(editorIMESupport.composing,
|
|
|
|
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
|
|
|
|
synthesizeText(
|
|
|
|
{ "composition":
|
|
|
|
{ "string": "",
|
|
|
|
"clauses":
|
|
|
|
[
|
|
|
|
{ "length": 0, "attr": 0 }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"caret": { "start": 0, "length": 0 }
|
|
|
|
});
|
|
|
|
|
|
|
|
synthesizeComposition(false);
|
|
|
|
|
|
|
|
container.removeAttribute("contenteditable");
|
|
|
|
}
|
|
|
|
|
2010-04-21 06:13:08 -07:00
|
|
|
function runEditableSubframeTests()
|
|
|
|
{
|
|
|
|
window.open("window_imestate_iframes.html", "_blank",
|
|
|
|
"width=600,height=600");
|
|
|
|
}
|
|
|
|
|
2010-08-16 01:20:27 -07:00
|
|
|
function runTestPasswordFieldOnDialog()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (document.activeElement) {
|
|
|
|
document.activeElement.blur();
|
|
|
|
}
|
|
|
|
|
|
|
|
var dialog;
|
|
|
|
|
|
|
|
function WindowObserver()
|
|
|
|
{
|
|
|
|
Components.classes["@mozilla.org/observer-service;1"].
|
|
|
|
getService(Components.interfaces.nsIObserverService).
|
|
|
|
addObserver(this, "domwindowopened", false);
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowObserver.prototype = {
|
|
|
|
QueryInterface: function (iid)
|
|
|
|
{
|
|
|
|
if (iid.equals(Components.interfaces.nsIObserver) ||
|
|
|
|
iid.equals(Components.interfaces.nsISupports)) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
observe: function (subject, topic, data)
|
|
|
|
{
|
|
|
|
if (topic === "domwindowopened") {
|
|
|
|
ok(true, "dialog window is created");
|
|
|
|
dialog = subject.QueryInterface(Components.interfaces.nsIDOMWindow);
|
|
|
|
dialog.addEventListener("load", onPasswordDialogLoad, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var observer = new WindowObserver();
|
|
|
|
var arg1 = new Object(), arg2 = new Object();
|
|
|
|
Components.classes["@mozilla.org/embedcomp/prompt-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPromptService).
|
|
|
|
promptPassword(window, "title", "text", arg1, "msg", arg2);
|
|
|
|
|
|
|
|
ok(true, "password dialog was closed");
|
|
|
|
|
|
|
|
Components.classes["@mozilla.org/observer-service;1"].
|
|
|
|
getService(Components.interfaces.nsIObserverService).
|
|
|
|
removeObserver(observer, "domwindowopened");
|
|
|
|
|
|
|
|
var passwordField;
|
|
|
|
|
|
|
|
function onPasswordDialogLoad()
|
|
|
|
{
|
|
|
|
ok(true, "onPasswordDialogLoad is called");
|
|
|
|
dialog.removeEventListener("load", onPasswordDialogLoad, false);
|
|
|
|
passwordField = dialog.document.getElementById("password1Textbox");
|
|
|
|
passwordField.addEventListener("focus", onPasswordFieldFocus, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPasswordFieldFocus()
|
|
|
|
{
|
|
|
|
ok(true, "onPasswordFieldFocus is called");
|
|
|
|
passwordField.removeEventListener("focus", onPasswordFieldFocus, false);
|
|
|
|
var utils = dialog.
|
|
|
|
QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
|
|
|
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
|
|
|
is(utils.IMEStatus, utils.IME_STATUS_PASSWORD,
|
|
|
|
"IME isn't disabled on a password field of password dialog");
|
|
|
|
synthesizeKey("VK_ESCAPE", { }, dialog);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-04 23:15:23 -07:00
|
|
|
function runTests()
|
|
|
|
{
|
|
|
|
if (!kIMEEnabledSupported && !kIMEOpenSupported)
|
|
|
|
return;
|
|
|
|
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
|
|
|
|
// test for normal contents.
|
|
|
|
runBasicTest(false, false, "Testing of normal contents");
|
|
|
|
|
2009-12-04 00:03:27 -08:00
|
|
|
// test for plugin contents
|
|
|
|
runPluginTest();
|
|
|
|
|
2009-05-04 23:15:23 -07: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 11:00:39 -07:00
|
|
|
document.getElementById("text").focus();
|
2009-05-04 23:15:23 -07:00
|
|
|
runBasicTest(false, false, "Testing designMode=\"off\"");
|
|
|
|
|
|
|
|
// changing input[type] values
|
2010-05-04 10:40:39 -07:00
|
|
|
// XXX currently, type attribute changing doesn't work fine. bug 559728.
|
2009-05-04 23:15:23 -07:00
|
|
|
// runTypeChangingTest();
|
|
|
|
|
|
|
|
// changing readonly attribute
|
2010-05-04 10:40:39 -07:00
|
|
|
runReadonlyChangingTest();
|
|
|
|
|
|
|
|
// complex contenteditable editor's tests
|
|
|
|
runComplexContenteditableTests();
|
2009-05-04 23:15:23 -07:00
|
|
|
|
2010-05-26 19:04:14 -07:00
|
|
|
// test whether the IME state and composition are not changed unexpectedly
|
|
|
|
runEditorFlagChangeTests();
|
|
|
|
|
2010-08-16 01:20:27 -07:00
|
|
|
// test password field on dialog
|
2010-08-16 02:01:01 -07:00
|
|
|
// XXX temporary disable against failure
|
|
|
|
//runTestPasswordFieldOnDialog();
|
2010-08-16 01:20:27 -07:00
|
|
|
|
2010-04-21 06:13:08 -07:00
|
|
|
runASyncTests();
|
|
|
|
}
|
|
|
|
|
|
|
|
function runASyncTests()
|
|
|
|
{
|
|
|
|
// The tests must call onFinish() method.
|
|
|
|
runEditableSubframeTests();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFinish()
|
|
|
|
{
|
2009-05-04 23:15:23 -07:00
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
|
|
|
|
</html>
|