1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* 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"
);
}
);
});
|