Bug 1269209 - Port test_bug1205983.html from chrome to plain; r=masayuki
☠☠ backed out by 53bb4e191630 ☠ ☠
authorAryeh Gregor <ayg@aryeh.name>
Mon, 22 Aug 2016 21:08:52 +0300
changeset 319736 104c0aa107474ba9058625f793f78c73e5ccf062
parent 319735 5f63100d5531dd4ce5d53bc1f0afac0957cff670
child 319737 cea0421beffa3dde557dfd1edc1a780e7a0fbd92
push id20748
push userphilringnalda@gmail.com
push dateFri, 28 Oct 2016 03:39:55 +0000
treeherderfx-team@715360440695 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1269209, 1205983
milestone52.0a1
Bug 1269209 - Port test_bug1205983.html from chrome to plain; r=masayuki MozReview-Commit-ID: FPFRvbOftw4
editor/composer/test/chrome.ini
editor/composer/test/mochitest.ini
editor/composer/test/test_bug1205983.html
--- a/editor/composer/test/chrome.ini
+++ b/editor/composer/test/chrome.ini
@@ -1,8 +1,7 @@
 [DEFAULT]
 skip-if = buildapp == 'b2g' || os == 'android'
 
 [test_bug434998.xul]
-[test_bug1205983.html]
 [test_bug1209414.html]
 [test_bug1219928.html]
 [test_bug1266815.html]
--- a/editor/composer/test/mochitest.ini
+++ b/editor/composer/test/mochitest.ini
@@ -21,8 +21,9 @@ support-files =
 skip-if = toolkit == 'android'
 [test_bug519928.html]
 [test_bug678842.html]
 [test_bug697981.html]
 [test_bug717433.html]
 [test_bug738440.html]
 [test_bug1200533.html]
 [test_bug1204147.html]
+[test_bug1205983.html]
--- a/editor/composer/test/test_bug1205983.html
+++ b/editor/composer/test/test_bug1205983.html
@@ -1,70 +1,78 @@
 <!DOCTYPE html>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=1205983
 -->
 <head>
   <title>Test for Bug 1205983</title>
-  <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
+  <script src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1205983">Mozilla Bug 1205983</a>
 <p id="display"></p>
 </div>
 
 <div contenteditable id="de-DE" lang="de-DE" onfocus="deFocus()">German heute ist ein guter Tag</div>
 <textarea id="en-US" lang="en-US" onfocus="enFocus()">Nogoodword today is a nice day</textarea>
 
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 function getMisspelledWords(editor) {
-  return editor.selectionController.getSelection(Components.interfaces.nsISelectionController.SELECTION_SPELLCHECK).toString();
+  return editor.selectionController.getSelection(SpecialPowers.Ci.nsISelectionController.SELECTION_SPELLCHECK).toString();
 }
 
 var elem_de;
 var editor_de;
 var selcon_de;
-var de_DE;
-var hunspell;
+var script;
+
+var onSpellCheck =
+  SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm")
+               .onSpellCheck;
 
 /** Test for Bug 1205983 **/
 SimpleTest.waitForExplicitFinish();
 SimpleTest.waitForFocus(function() {
-  Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
+  script = SpecialPowers.loadChromeScript(function() {
+    var dir = Components.classes["@mozilla.org/file/directory_service;1"]
+                        .getService(Components.interfaces.nsIProperties)
+                        .get("CurWorkD", Components.interfaces.nsIFile);
+    dir.append("tests");
+    dir.append("editor");
+    dir.append("composer");
+    dir.append("test");
 
-  var dir = Components.classes["@mozilla.org/file/directory_service;1"]
-                      .getService(Components.interfaces.nsIProperties)
-                      .get("CurWorkD", Components.interfaces.nsIFile);
-  dir.append("tests");
-  dir.append("editor");
-  dir.append("composer");
-  dir.append("test");
+    var hunspell = Components.classes["@mozilla.org/spellchecker/engine;1"]
+                             .getService(Components.interfaces.mozISpellCheckingEngine);
 
-  hunspell = Components.classes["@mozilla.org/spellchecker/engine;1"]
-                       .getService(Components.interfaces.mozISpellCheckingEngine);
+    // Install de-DE dictionary.
+    var de_DE = dir.clone();
+    de_DE.append("de-DE");
+    hunspell.addDirectory(de_DE);
 
-  // Install de-DE dictionary.
-  de_DE = dir.clone();
-  de_DE.append("de-DE");
-  is(de_DE.exists(), true, "true expected (de_DE directory should exist)");
-  hunspell.addDirectory(de_DE);
+    addMessageListener("de_DE-exists", () => de_DE.exists());
+    addMessageListener("destroy", () => hunspell.removeDirectory(de_DE));
+  });
+  is(script.sendSyncMessage("de_DE-exists")[0][0], true,
+     "true expected (de_DE directory should exist)");
 
   document.getElementById('de-DE').focus();
 });
 
 function deFocus() {
   elem_de = document.getElementById('de-DE');
 
   onSpellCheck(elem_de, function () {
-    var Ci = Components.interfaces;
-    var editingSession = window.QueryInterface(Ci.nsIInterfaceRequestor)
+    var Ci = SpecialPowers.Ci;
+    var editingSession = SpecialPowers.wrap(window)
+                               .QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIWebNavigation)
                                .QueryInterface(Ci.nsIInterfaceRequestor)
                                .getInterface(Ci.nsIEditingSession);
     editor_de = editingSession.getEditorForWindow(window);
     selcon_de = editor_de.selectionController;
     var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
 
     // Check that we spelled in German, so there is only one misspelled word.
@@ -72,17 +80,20 @@ function deFocus() {
 
     // Now focus the textarea, which requires English spelling.
     document.getElementById('en-US').focus();
   });
 }
 
 function enFocus() {
   var elem_en = document.getElementById('en-US');
-  var editor_en = elem_en.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
+  var editor_en =
+    SpecialPowers.wrap(elem_en)
+                 .QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement)
+                 .editor;
   editor_en.setSpellcheckUserOverride(true);
   var inlineSpellChecker = editor_en.getInlineSpellChecker(true);
 
   onSpellCheck(elem_en, function () {
     var spellchecker = inlineSpellChecker.spellChecker;
     try {
       currentDictonary = spellchecker.GetCurrentDictionary();
     } catch(e) {}
@@ -93,17 +104,17 @@ function enFocus() {
 
     // So far all was boring. The important thing is whether the spell check result
     // in the de-DE editor is still the same. After losing focus, no spell check
     // updates should take place there.
     var sel = selcon_de.getSelection(selcon_de.SELECTION_SPELLCHECK);
     is(sel.toString(), "German", "one misspelled word expected: German");
 
     // Remove the fake de_DE dictionary again.
-    hunspell.removeDirectory(de_DE);
+    script.sendSyncMessage("destroy");
 
     // Focus again, so the spelling gets updated, but before we need to kill the focus handler.
     elem_de.onfocus = null;
     elem_de.blur();
     elem_de.focus();
 
     // After removal, the de_DE editor should refresh the spelling with en-US.
     onSpellCheck(elem_de, function () {