editor/libeditor/html/tests/test_bug366682.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=366682
     5 -->
     6 <head>
     7   <title>Test for Bug 366682</title>
     8   <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
    10   <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366682">Mozilla Bug 366682</a>
    14 <p id="display"></p>
    15 <div id="content" style="display: none">
    16 </div>
    17 <pre id="test">
    18 <script type="application/javascript">
    20 /** Test for Bug 366682 **/
    22 SimpleTest.waitForExplicitFinish();
    23 addLoadEvent(runTest);
    25 var gMisspeltWords;
    27 function getEdit() {
    28   return document.getElementById('edit');
    29 }
    31 function editDoc() {
    32   return getEdit().contentDocument;
    33 }
    35 function getSpellCheckSelection() {
    36   var Ci = Components.interfaces;
    37   var win = editDoc().defaultView;
    38   var editingSession = win.QueryInterface(Ci.nsIInterfaceRequestor)
    39                           .getInterface(Ci.nsIWebNavigation)
    40                           .QueryInterface(Ci.nsIInterfaceRequestor)
    41                           .getInterface(Ci.nsIEditingSession);
    42   var editor = editingSession.getEditorForWindow(win);
    43   var selcon = editor.selectionController;
    44   return selcon.getSelection(selcon.SELECTION_SPELLCHECK);
    45 }
    47 function runTest() {
    48   editDoc().body.innerHTML = "<div>errror and an other errror</div>";
    49   gMisspeltWords = ["errror", "errror"];
    50   editDoc().designMode = "on";
    52   Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
    53   onSpellCheck(editDoc().documentElement, evalTest);
    54 }
    56 function evalTest() {
    57   is(isSpellingCheckOk(), true, "All misspellings accounted for.");
    58   SimpleTest.finish();
    59 }
    61 function isSpellingCheckOk() {
    62   var sel = getSpellCheckSelection();
    63   var numWords = sel.rangeCount;
    65   is(numWords, gMisspeltWords.length, "Correct number of misspellings and words.");
    67   if (numWords != gMisspeltWords.length)
    68     return false;
    70   for (var i=0; i<numWords; i++) {
    71     var word = sel.getRangeAt(i);
    72     is (word, gMisspeltWords[i], "Misspelling is what we think it is.");
    73     if (word != gMisspeltWords[i])
    74       return false;
    75   }
    76   return true;
    77 }
    79 </script>
    80 </pre>
    82 <iframe id="edit" width="200" height="100" src="about:blank"></iframe>
    84 </body>
    85 </html>

mercurial