summaryrefslogtreecommitdiffstats
path: root/widget/tests/test_ime_state_in_contenteditable_on_readonly_change_in_parent.html
blob: 8d8662a8d8f68739156cc8595042c0be0cb3f0f8 (plain)
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
<html>
<head>
  <title>Test for IME state of contenteditable on readonly state change</title>
  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
  <script src="file_ime_state_test_helper.js"></script>
  <script src="file_test_ime_state_in_contenteditable_on_readonly_change.js"></script>
  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
<script>
"use strict";

/* import-globals-from file_ime_state_test_helper.js */
/* import-globals-from file_test_ime_state_in_contenteditable_on_readonly_change.js */

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  const tipWrapper = new TIPWrapper(window);
  const editingHost = document.querySelector("div[contenteditable]");
  await (async function test_ime_state_in_contenteditable_on_readonly_change() {
    const tester = new IMEStateInContentEditableOnReadonlyChangeTester();
    tester.checkResultOfPreparation(await tester.prepareToRun(editingHost, editingHost), window, tipWrapper);
    tester.checkResultOfMakingHTMLEditorReadonly(await tester.runToMakeHTMLEditorReadonly());
    tester.checkResultOfMakingHTMLEditorEditable(await tester.runToMakeHTMLEditorEditable());
    tester.checkResultOfRemovingContentEditableAttribute(await tester.runToRemoveContentEditableAttribute());
    tester.clear();
  })();

  await (async function test_ime_state_in_button_in_contenteditable_on_readonly_change() {
    const tester = new IMEStateInContentEditableOnReadonlyChangeTester();
    const button = editingHost.querySelector("button");
    tester.checkResultOfPreparation(await tester.prepareToRun(editingHost, button), window, tipWrapper);
    tester.checkResultOfMakingHTMLEditorReadonly(await tester.runToMakeHTMLEditorReadonly());
    tester.checkResultOfMakingHTMLEditorEditable(await tester.runToMakeHTMLEditorEditable());
    tester.checkResultOfRemovingContentEditableAttribute(await tester.runToRemoveContentEditableAttribute());
    tester.clear();
  })();

  await (async function test_ime_state_of_text_controls_in_contenteditable_on_readonly_change() {
    const tester = new IMEStateOfTextControlInContentEditableOnReadonlyChangeTester();
    for (let index = 0;
         index < IMEStateOfTextControlInContentEditableOnReadonlyChangeTester.numberOfTextControlTypes;
         index++) {
      tester.checkResultOfPreparation(await tester.prepareToRun(index, editingHost), window, tipWrapper);
      tester.checkResultOfMakingParentEditingHost(await tester.runToMakeParentEditingHost());
      tester.checkResultOfMakingHTMLEditorReadonly(await tester.runToMakeHTMLEditorReadonly());
      tester.checkResultOfMakingHTMLEditorEditable(await tester.runToMakeHTMLEditorEditable());
      tester.checkResultOfMakingParentNonEditable(await tester.runToMakeParentNonEditingHost());
      tester.clear();
    }
    editingHost.setAttribute("contenteditable", "");
  })();

  await (async function test_ime_state_outside_contenteditable_on_readonly_change() {
    const tester = new IMEStateOutsideContentEditableOnReadonlyChangeTester();
    for (let index = 0;
         index < IMEStateOutsideContentEditableOnReadonlyChangeTester.numberOfFocusTargets;
         index++) {
      tester.checkResultOfPreparation(await tester.prepareToRun(index, editingHost), window, tipWrapper);
      tester.checkResultOfMakingParentEditingHost(await tester.runToMakeParentEditingHost());
      tester.checkResultOfMakingHTMLEditorReadonly(await tester.runToMakeHTMLEditorReadonly());
      tester.checkResultOfMakingHTMLEditorEditable(await tester.runToMakeHTMLEditorEditable());
      tester.checkResultOfMakingParentNonEditable(await tester.runToMakeParentNonEditingHost());
      tester.clear();
    }
    editingHost.setAttribute("contenteditable", "");
  })();

  SimpleTest.finish();
});
</script>
</head>
<body><div contenteditable><br><button>button</button></div></body>
</html>