2 <html style=
"ime-mode: disabled;">
5 <title>Test for IME state management on focus move in parent process
</title>
6 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
7 <script src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
8 <script src=
"file_ime_state_test_helper.js"></script>
9 <script src=
"file_test_ime_state_on_focus_move.js"></script>
10 <link rel=
"stylesheet" href=
"chrome://mochikit/content/tests/SimpleTest/test.css">
12 <body style=
"ime-mode: disabled;">
13 <div style=
"ime-mode: disabled;"></div>
17 /* import-globals-from file_ime_state_test_helper.js */
18 /* import-globals-from file_test_ime_state_on_focus_move.js */
20 SimpleTest
.waitForExplicitFinish();
21 SimpleTest
.waitForFocus(async () => {
22 const tipWrapper
= new TIPWrapper(window
);
23 ok(tipWrapper
.isAvailable(), "TextInputProcessor should've been initialized");
25 const container
= document
.querySelector("div");
26 async
function runIMEStateOnFocusMoveTests(aDescription
) {
28 const runnerAndChecker
= new IMEStateWhenNoActiveElementTester(aDescription
);
29 const expectedData
= await runnerAndChecker
.run(document
);
30 runnerAndChecker
.check(expectedData
);
32 for (let index
= 0; index
< IMEStateOnFocusMoveTester
.numberOfTests
; ++index
) {
33 const runnerAndChecker
= new IMEStateOnFocusMoveTester(aDescription
, index
);
34 const expectedData
= await runnerAndChecker
.prepareToRun(container
);
35 runnerAndChecker
.prepareToCheck(expectedData
, tipWrapper
);
36 await runnerAndChecker
.run();
37 runnerAndChecker
.check(expectedData
);
38 if (runnerAndChecker
.canTestOpenCloseState(expectedData
)) {
39 for (const defaultOpenState
of [false, true]) {
40 const expectedOpenStateData
=
41 await runnerAndChecker
.prepareToRunOpenCloseTest(container
);
42 runnerAndChecker
.prepareToCheckOpenCloseTest(
46 await runnerAndChecker
.runOpenCloseTest();
47 runnerAndChecker
.checkOpenCloseTest(expectedOpenStateData
);
50 runnerAndChecker
.destroy();
54 // test for normal contents.
55 await
runIMEStateOnFocusMoveTests("in non-editable container");
57 // test for contentEditable="true"
58 container
.setAttribute("contenteditable", "true");
59 await
runIMEStateOnFocusMoveTests("in div[contenteditable]");
61 // test for contentEditable="false"
62 container
.setAttribute("contenteditable", "false");
63 await
runIMEStateOnFocusMoveTests('in div[contenteditable="false"]');
65 // test for removing contentEditable
66 container
.setAttribute("contenteditable", "true");
68 await
new Promise(resolve
=>
69 requestAnimationFrame(
70 () => requestAnimationFrame(resolve
)
73 container
.removeAttribute("contenteditable");
74 await
runIMEStateOnFocusMoveTests("after removing contenteditable from the container");
77 document
.designMode
= "on";
78 await
runIMEStateOnFocusMoveTests('in designMode="on"');
79 document
.designMode
= "off";
80 await
runIMEStateOnFocusMoveTests('in designMode="off"');