<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_text_control_on_reframe.js"></script>
  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<script>
"use strict";

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

SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  const tipWrapper = new TIPWrapper(window);
  const tester = new IMEStateInTextControlOnReframeTester();
  for (let index = 0;
        index < IMEStateInTextControlOnReframeTester.numberOfTextControlTypes;
        index++) {
    tipWrapper.clearFocusBlurNotifications();
    const expectedData1 = await tester.prepareToRun(index, document);
    tipWrapper.typeA();
    await new Promise(resolve => requestAnimationFrame(
      () => requestAnimationFrame(resolve)
    )); // Flush IME content observer notifications.
    tester.checkResultAfterTypingA(expectedData1, window, tipWrapper);

    const expectedData2 = await tester.prepareToRun2(index, document);
    tipWrapper.typeA();
    await new Promise(resolve => requestAnimationFrame(
      () => requestAnimationFrame(resolve)
    )); // Flush IME content observer notifications.
    tester.checkResultAfterTypingA2(expectedData2);
  }

  SimpleTest.finish();
});
</script>
<body></body>
</html>
