tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug1170484.html (2172B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=1170484
      5 -->
      6 <head>
      7  <meta charset="utf-8">
      8  <title>Test for Bug 1170484</title>
      9  <script src="/tests/SimpleTest/SimpleTest.js"></script>
     10  <script src="/tests/SimpleTest/EventUtils.js"></script>
     11  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     12  <script type="application/javascript">
     13 
     14  /** Test for Bug 1170484 */
     15  SimpleTest.waitForExplicitFinish();
     16 
     17  var { maybeOnSpellCheck } = SpecialPowers.ChromeUtils.importESModule(
     18    "resource://testing-common/AsyncSpellCheckTestHelper.sys.mjs"
     19  );
     20 
     21  SimpleTest.waitForFocus(doTest, window);
     22  function doTest() {
     23    var mutations = 0;
     24    var observer = new MutationObserver(() => { mutations++; });
     25    observer.observe($('area'), { childList: true, characterData: true, characterDataOldValue: true, subtree: true });
     26    var inputEvents = 0;
     27    $('area').addEventListener('input', () => ++inputEvents);
     28 
     29    // Clicking the contentEditable during onload doesn't seem  to do anything.
     30    // Not sure why, but postponing through the event loop seems to be enough.
     31    SimpleTest.executeSoon(function() {
     32      synthesizeMouseAtCenter($('misspelled'), {}, window);
     33      maybeOnSpellCheck($('area'), function() {
     34        synthesizeMouseAtCenter($('misspelled'), {type: 'contextmenu'}, window);
     35        var mm = SpecialPowers.loadChromeScript(SimpleTest.getTestFileURL('helper_bug1170484.js'))
     36        info("Loaded chrome script");
     37        mm.addMessageListener('spellingCorrected', function() {
     38          is($('area').textContent, 'testing spellcheck', "Spelling corrected properly");
     39          is(mutations, 1, "Got correct number of mutations");
     40          is(inputEvents, 1, "Got correct number of input events");
     41          SimpleTest.finish();
     42        });
     43      });
     44    });
     45  }
     46 
     47  </script>
     48 </head>
     49 <body>
     50 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1170484">Mozilla Bug 1170484</a>
     51 <p id="display"></p>
     52 <div id="content" style="display: none">
     53 
     54 </div>
     55 <pre id="test">
     56  <div id="area" contenteditable="true">testing <span id="misspelled">spellechek</span></div>
     57 </pre>
     58 </body>
     59 </html>