Backed out changeset 5f63100d5531 (bug 1269209)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Fri, 28 Oct 2016 00:38:25 +0200
changeset 319773 09e1379801c10db4980da97757416fb23c71c24c
parent 319772 53bb4e1916307ea601a13cee5fb946ad24095abb
child 319774 4d44d784fa155136b064582e637c33bf9dff49de
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)
bugs1269209
milestone52.0a1
backs out5f63100d5531dd4ce5d53bc1f0afac0957cff670
Backed out changeset 5f63100d5531 (bug 1269209) MozReview-Commit-ID: Jl5DGq5SSIb
editor/composer/test/chrome.ini
editor/composer/test/mochitest.ini
editor/composer/test/test_bug1200533.html
--- a/editor/composer/test/chrome.ini
+++ b/editor/composer/test/chrome.ini
@@ -1,8 +1,9 @@
 [DEFAULT]
 skip-if = buildapp == 'b2g' || os == 'android'
 
 [test_bug434998.xul]
+[test_bug1200533.html]
 [test_bug1205983.html]
 [test_bug1209414.html]
 [test_bug1219928.html]
 [test_bug1266815.html]
--- a/editor/composer/test/mochitest.ini
+++ b/editor/composer/test/mochitest.ini
@@ -19,10 +19,9 @@ support-files =
 [test_bug384147.html]
 [test_bug389350.html]
 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]
--- a/editor/composer/test/test_bug1200533.html
+++ b/editor/composer/test/test_bug1200533.html
@@ -1,17 +1,17 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=1200533
 -->
 <head>
   <title>Test for Bug 1200533</title>
-  <script src="/tests/SimpleTest/SimpleTest.js"></script>
-  <link rel="stylesheet" href="/tests/SimpleTest/test.css">
+  <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" />
 </head>
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1200533">Mozilla Bug 1200533</a>
 <p id="display"></p>
 <iframe id="content"></iframe>
 
 </div>
 <pre id="test">
@@ -43,71 +43,61 @@ var tests = [
     // Result: Random en-*.
     [ "en-ZA-not-avail", "de-DE", "*" ],
     [ "en-generic",      "de-DE", "*" ],
     // Result: Preference value.
     [ "ko-not-avail",    "de-DE", "de-DE" ],
   ];
 
 var loadCount = 0;
-var script;
+var en_GB;
+var en_AU;
+var en_DE;
+var hunspell;
 
 var loadListener = function(evt) {
+  Components.utils.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm");
+  Components.utils.import("resource://gre/modules/Services.jsm");
+
   if (loadCount == 0) {
-    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 hunspell = Components.classes["@mozilla.org/spellchecker/engine;1"]
-                               .getService(Components.interfaces.mozISpellCheckingEngine);
+    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");
 
-      // Install en-GB, en-AU and de-DE dictionaries.
-      var en_GB = dir.clone();
-      var en_AU = dir.clone();
-      var de_DE = dir.clone();
-      en_GB.append("en-GB");
-      en_AU.append("en-AU");
-      de_DE.append("de-DE");
-      hunspell.addDirectory(en_GB);
-      hunspell.addDirectory(en_AU);
-      hunspell.addDirectory(de_DE);
+    hunspell = Components.classes["@mozilla.org/spellchecker/engine;1"]
+                         .getService(Components.interfaces.mozISpellCheckingEngine);
 
-      addMessageListener("check-existence",
-                         () => [en_GB.exists(), en_AU.exists(),
-                                de_DE.exists()]);
-      addMessageListener("destroy", () => {
-        hunspell.removeDirectory(en_GB);
-        hunspell.removeDirectory(en_AU);
-        hunspell.removeDirectory(de_DE);
-      });
-    });
-    var existenceChecks = script.sendSyncMessage("check-existence")[0][0];
-    is(existenceChecks[0], true, "true expected (en-GB directory should exist)");
-    is(existenceChecks[1], true, "true expected (en-AU directory should exist)");
-    is(existenceChecks[2], true, "true expected (de-DE directory should exist)");
+    // Install en-GB, en-AU and de-DE dictionaries.
+    en_GB = dir.clone();
+    en_AU = dir.clone();
+    de_DE = dir.clone();
+    en_GB.append("en-GB");
+    en_AU.append("en-AU");
+    de_DE.append("de-DE");
+    is(en_GB.exists(), true, "true expected (en-GB directory should exist)");
+    is(en_AU.exists(), true, "true expected (en-AU directory should exist)");
+    is(de_DE.exists(), true, "true expected (de-DE directory should exist)");
+    hunspell.addDirectory(en_GB);
+    hunspell.addDirectory(en_AU);
+    hunspell.addDirectory(de_DE);
   }
 
-  SpecialPowers.pushPrefEnv({set: [["spellchecker.dictionary", tests[loadCount][1]]]},
-                            function() { continueTest(evt) });
-}
+  Services.prefs.setCharPref("spellchecker.dictionary", tests[loadCount][1]);
 
-function continueTest(evt) {
   var doc = evt.target.contentDocument;
   var elem = doc.getElementById(tests[loadCount][0]);
-  var editor = SpecialPowers.wrap(elem).QueryInterface(SpecialPowers.Ci.nsIDOMNSEditableElement).editor;
+  var editor = elem.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
   editor.setSpellcheckUserOverride(true);
   var inlineSpellChecker = editor.getInlineSpellChecker(true);
 
-  SpecialPowers.Cu.import("resource://gre/modules/AsyncSpellCheckTestHelper.jsm")
-  .onSpellCheck(elem, function () {
+  onSpellCheck(elem, function () {
     var spellchecker = inlineSpellChecker.spellChecker;
     try {
       var dict = spellchecker.GetCurrentDictionary();
     } catch(e) {}
 
     if (tests[loadCount][2] != "*") {
       is (dict, tests[loadCount][2], "expected " + tests[loadCount][2]);
     } else {
@@ -116,17 +106,22 @@ function continueTest(evt) {
     }
 
     loadCount++;
     if (loadCount < tests.length) {
       // Load the iframe again.
       content.src = 'http://mochi.test:8888/tests/editor/composer/test/bug1200533_subframe.html?firstload=false';
     } else {
       // Remove the fake  dictionaries again, since it's otherwise picked up by later tests.
-      script.sendSyncMessage("destroy");
+      hunspell.removeDirectory(en_GB);
+      hunspell.removeDirectory(en_AU);
+      hunspell.removeDirectory(de_DE);
+
+      // Reset the preference, so the last value we set doesn't collide with the next test.
+      Services.prefs.setCharPref("spellchecker.dictionary", "");
 
       SimpleTest.finish();
     }
   });
 
 }
 
 content.addEventListener('load', loadListener, false);