Bug 1882714 [wpt PR 44850] - Update wpt metadata, a=testonly
[gecko.git] / widget / tests / test_ime_state_on_focus_move_in_parent.html
blobfd74d61c7ed54c613e5d876ed31e156dacadb27b
1 <!doctype html>
2 <html style="ime-mode: disabled;">
3 <head>
4 <meta charset="utf-8">
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">
11 </head>
12 <body style="ime-mode: disabled;">
13 <div style="ime-mode: disabled;"></div>
14 <script>
15 "use strict";
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(
43 defaultOpenState,
44 expectedOpenStateData
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");
67 container.focus();
68 await new Promise(resolve =>
69 requestAnimationFrame(
70 () => requestAnimationFrame(resolve)
73 container.removeAttribute("contenteditable");
74 await runIMEStateOnFocusMoveTests("after removing contenteditable from the container");
76 // test designMode
77 document.designMode = "on";
78 await runIMEStateOnFocusMoveTests('in designMode="on"');
79 document.designMode = "off";
80 await runIMEStateOnFocusMoveTests('in designMode="off"');
82 tipWrapper.destroy();
84 SimpleTest.finish();
85 });
86 </script>
87 </body>
88 </html>