mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1806756 - part 3: Make runPluginTest
in test_ime_state_in_parent.html
run as both mochitest-chrome and mochitest-browser-chrome r=m_kato
We won't support plugins. Therefore, the tests won't be maintained, thus, I just copied them instead of creating complicated shared JS file. Differential Revision: https://phabricator.services.mozilla.com/D171198
This commit is contained in:
parent
54f0b5675a
commit
a7747aae95
@ -25,6 +25,9 @@ support-files =
|
||||
file_ime_state_tests.html
|
||||
../file_ime_state_test_helper.js
|
||||
../file_test_ime_state_on_focus_move.js
|
||||
[browser_test_ime_state_in_plugin_in_remote_content.js]
|
||||
support-files =
|
||||
../file_ime_state_test_helper.js
|
||||
[browser_test_InputContextURI.js]
|
||||
[browser_test_swipe_gesture.js]
|
||||
run-if = (os == 'mac' || os == 'win' || os == 'linux')
|
||||
|
@ -0,0 +1,119 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../file_ime_state_test_helper.js */
|
||||
|
||||
Services.scriptloader.loadSubScript(
|
||||
"chrome://mochitests/content/browser/widget/tests/browser/file_ime_state_test_helper.js",
|
||||
this
|
||||
);
|
||||
add_task(async function() {
|
||||
await BrowserTestUtils.withNewTab(
|
||||
"https://example.com/browser/toolkit/content/tests/browser/file_empty.html",
|
||||
async function(browser) {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
ok(
|
||||
tipWrapper.isAvailable(),
|
||||
"TextInputProcessor should've been initialized"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.wrappedJSObject.waitForIMEContentObserverSendingNotifications = () => {
|
||||
return new content.window.Promise(resolve =>
|
||||
content.window.requestAnimationFrame(() =>
|
||||
content.window.requestAnimationFrame(resolve)
|
||||
)
|
||||
);
|
||||
};
|
||||
content.document.body.innerHTML =
|
||||
'<input><object type="application/x-test"></object>';
|
||||
});
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.activeElement?.blur();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when no element has focus"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when no element has focus"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.querySelector("object").focus();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin has focus"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME enabled state should not have focus when an <object> for plugin has focus"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.querySelector("object").blur();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin gets blurred"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when an <object> for plugin gets blurred"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.querySelector("object").focus();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin gets focused again"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when an <object> for plugin gets focused again"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.querySelector("object").remove();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when focused <object> for plugin is removed from the document"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when focused <object> for plugin is removed from the document"
|
||||
);
|
||||
|
||||
await SpecialPowers.spawn(browser, [], () => {
|
||||
content.document.querySelector("input").focus();
|
||||
return content.wrappedJSObject.waitForIMEContentObserverSendingNotifications();
|
||||
});
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
|
||||
"IME enabled state should be enabled after <input> gets focus"
|
||||
);
|
||||
ok(
|
||||
tipWrapper.IMEHasFocus,
|
||||
"IME should have focus after <input> gets focus"
|
||||
);
|
||||
}
|
||||
);
|
||||
});
|
@ -25,6 +25,9 @@ support-files = window_bug593307_offscreen.xhtml window_bug593307_centerscreen.x
|
||||
support-files = window_wheeltransaction.xhtml
|
||||
[test_ime_state_in_parent.html]
|
||||
support-files = window_imestate_iframes.html
|
||||
[test_ime_state_in_plugin_in_parent.html]
|
||||
support-files =
|
||||
file_ime_state_test_helper.js
|
||||
[test_ime_state_on_editable_state_change_in_parent.html]
|
||||
support-files =
|
||||
file_ime_state_test_helper.js
|
||||
|
@ -83,9 +83,6 @@
|
||||
<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/>
|
||||
|
||||
<!-- plugin -->
|
||||
<object type="application/x-test" id="plugin"></object><br/>
|
||||
|
||||
<!-- contenteditable editor -->
|
||||
<div id="contenteditableEditor" contenteditable="true"></div>
|
||||
</div>
|
||||
@ -110,38 +107,6 @@ function hitEventLoop(aFunc, aTimes) {
|
||||
var gUtils = window.windowUtils;
|
||||
var gFM = Services.focus;
|
||||
|
||||
function runPluginTest() {
|
||||
var plugin = document.getElementById("plugin");
|
||||
|
||||
// Plugins are not supported and their elements should not accept focus;
|
||||
// therefore, IME should not enable when we play with it.
|
||||
|
||||
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_DISABLED,
|
||||
"runPluginTest: unexpected enabled state when attempting to give focus to plugin");
|
||||
|
||||
plugin.blur();
|
||||
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
||||
"runPluginTest: unexpected enabled state after unfocusing plugin");
|
||||
|
||||
plugin.focus();
|
||||
is(gUtils.IMEStatus, gUtils.IME_STATUS_DISABLED,
|
||||
"runPluginTest: unexpected enabled state when attempting to give focus to plugin #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");
|
||||
}
|
||||
|
||||
function runTypeChangingTest() {
|
||||
const kInputControls = [
|
||||
{ id: "text",
|
||||
@ -850,9 +815,6 @@ async function runTests() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.forms.always_allow_key_and_focus_events.enabled", true]],
|
||||
});
|
||||
// test for plugin contents
|
||||
runPluginTest();
|
||||
|
||||
// changing input[type] values
|
||||
// XXX currently, type attribute changing doesn't work fine. bug 559728.
|
||||
// runTypeChangingTest();
|
||||
|
92
widget/tests/test_ime_state_in_plugin_in_parent.html
Normal file
92
widget/tests/test_ime_state_in_plugin_in_parent.html
Normal file
@ -0,0 +1,92 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for IME state on plugin</title>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="file_ime_state_test_helper.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
</head>
|
||||
<body>
|
||||
<input>
|
||||
<object type="application/x-test"></object>
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.waitForFocus(() => {
|
||||
const tipWrapper = new TIPWrapper(window);
|
||||
const plugin = document.querySelector("object");
|
||||
|
||||
// Plugins are not supported and their elements should not accept focus;
|
||||
// therefore, IME should not enable when we play with it.
|
||||
|
||||
document.activeElement?.blur();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when no element has focus"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when no element has focus"
|
||||
);
|
||||
|
||||
plugin.focus();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin has focus"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when an <object> for plugin has focus"
|
||||
);
|
||||
|
||||
plugin.blur();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin gets blurred"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when an <object> for plugin gets blurred"
|
||||
);
|
||||
|
||||
plugin.focus();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when an <object> for plugin gets focused again"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when an <object> for plugin gets focused again"
|
||||
);
|
||||
|
||||
plugin.remove();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_DISABLED,
|
||||
"IME enabled state should be disabled when focused <object> for plugin is removed from the document"
|
||||
);
|
||||
ok(
|
||||
!tipWrapper.IMEHasFocus,
|
||||
"IME should not have focus when focused <object> for plugin is removed from the document"
|
||||
);
|
||||
|
||||
document.querySelector("input").focus();
|
||||
is(
|
||||
window.windowUtils.IMEStatus,
|
||||
Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
|
||||
"IME enabled state should be enabled after <input> gets focus"
|
||||
);
|
||||
ok(
|
||||
tipWrapper.IMEHasFocus,
|
||||
"IME should have focus after <input> gets focus"
|
||||
);
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user