Backed out changeset 35178de36bd3 (bug 855704) for frequent mochitest failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Mon, 08 Apr 2013 19:50:03 -0400
changeset 134852 5a821a7b43ae10e51db0d3a1ed2fcdf3ff70decd
parent 134851 ab64b048ad04f74a4d4fc1bec56fcc85c59ee93c
child 134853 456c148977b3372f7ba4d2684e4d9f20584f3b43
push id3752
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 17:21:10 +0000
treeherdermozilla-aurora@1580544aef0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs855704
milestone23.0a1
backs out35178de36bd3217eb83cacf6e3f2e1123693c6fc
Backed out changeset 35178de36bd3 (bug 855704) for frequent mochitest failures.
content/media/webspeech/recognition/test/head.js
content/media/webspeech/recognition/test/test_abort.html
content/media/webspeech/recognition/test/test_audio_capture_error.html
content/media/webspeech/recognition/test/test_call_start_from_end_handler.html
content/media/webspeech/recognition/test/test_preference_enable.html
content/media/webspeech/recognition/test/test_recognition_service_error.html
content/media/webspeech/recognition/test/test_success_without_recognition_service.html
content/media/webspeech/recognition/test/test_timeout.html
--- a/content/media/webspeech/recognition/test/head.js
+++ b/content/media/webspeech/recognition/test/head.js
@@ -12,16 +12,18 @@ var errorCodes = {
   NOT_ALLOWED : 4,
   SERVICE_NOT_ALLOWED : 5,
   BAD_GRAMMAR : 6,
   LANGUAGE_NOT_SUPPORTED : 7
 };
 
 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 Components.utils.import("resource://gre/modules/Services.jsm");
+SpecialPowers.setBoolPref("media.webspeech.recognition.enable", true);
+SpecialPowers.setBoolPref("media.webspeech.test.enable", true);
 
 function EventManager(sr) {
   var self = this;
   var nEventsExpected = 0;
   self.eventsReceived = [];
 
   var allEvents = [
     "audiostart",
@@ -116,52 +118,50 @@ function EventManager(sr) {
                                  eventName);
   }
 
   self.requestTestEnd = function EventManager_requestTestEnd() {
     Services.obs.notifyObservers(null, SPEECH_RECOGNITION_TEST_END_TOPIC, null);
   }
 }
 
+function resetPrefs() {
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", false);
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", false);
+}
+
 function buildResultCallback(transcript) {
   return (function(evt) {
     is(evt.results[0][0].transcript, transcript, "expect correct transcript");
   });
 }
 
 function buildErrorCallback(errcode) {
   return (function(err) {
     is(err.error, errcode, "expect correct error code");
   });
 }
 
-function performTest(options) {
-  var prefs = options.prefs;
+function performTest(eventsToRequest, expectedEvents, doneFunc, audioSampleFile) {
+  var sr = new SpeechRecognition();
+  var em = new EventManager(sr);
 
-  prefs.unshift(
-    ["media.webspeech.recognition.enable", true],
-    ["media.webspeech.test.enable", true]
-  );
-
-  SpecialPowers.pushPrefEnv({set: prefs}, function() {
-    var sr = new SpeechRecognition();
-    var em = new EventManager(sr);
+  for (var eventName in expectedEvents) {
+    var cb = expectedEvents[eventName];
+    em.expect(eventName, cb);
+  }
 
-    for (var eventName in options.expectedEvents) {
-      var cb = options.expectedEvents[eventName];
-      em.expect(eventName, cb);
-    }
-
-    em.done = function() {
-      em.requestTestEnd();
-      options.doneFunc();
-    }
+  em.done = function() {
+    em.requestTestEnd();
+    resetPrefs();
+    doneFunc();
+  }
 
-    em.audioSampleFile = DEFAULT_AUDIO_SAMPLE_FILE;
-    if (options.audioSampleFile) {
-      em.audioSampleFile = options.audioSampleFile;
-    }
+  if (!audioSampleFile) {
+    audioSampleFile = DEFAULT_AUDIO_SAMPLE_FILE;
+  }
 
-    for (var i = 0; i < options.eventsToRequest.length; i++) {
-      em.requestFSMEvent(options.eventsToRequest[i]);
-    }
-  });
+  em.audioSampleFile = audioSampleFile;
+
+  for (var i = 0; i < eventsToRequest.length; i++) {
+    em.requestFSMEvent(eventsToRequest[i]);
+  }
 }
--- a/content/media/webspeech/recognition/test/test_abort.html
+++ b/content/media/webspeech/recognition/test/test_abort.html
@@ -28,16 +28,19 @@ https://bugzilla.mozilla.org/show_bug.cg
     "start",
     "audiostart",
     "speechstart",
     "speechend",
     "audioend"
   ];
 
   function doNextTest() {
+    SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+    SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
+
     var nextEvent = eventsToAbortOn[nextEventIdx];
     var expectedEvents = {
       "start": null,
       "audiostart": null,
       "audioend": null,
       "end": null
     };
 
@@ -51,21 +54,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     info("Aborting on " + nextEvent);
     expectedEvents[nextEvent] = function(evt, sr) {
       sr.abort();
     };
 
     nextEventIdx++;
 
-    performTest({
-      eventsToRequest: ["EVENT_START", "EVENT_AUDIO_DATA"],
-      expectedEvents: expectedEvents,
-      doneFunc: (nextEventIdx < eventsToAbortOn.length) ? doNextTest : SimpleTest.finish,
-      prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
-    });
+    performTest([
+      "EVENT_START",
+      "EVENT_AUDIO_DATA"
+      ],
+      expectedEvents,
+      (nextEventIdx < eventsToAbortOn.length) ? doNextTest : SimpleTest.finish);
   }
 
   doNextTest();
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_audio_capture_error.html
+++ b/content/media/webspeech/recognition/test/test_audio_capture_error.html
@@ -15,21 +15,21 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
-  performTest({
-    eventsToRequest: ['EVENT_START', 'EVENT_AUDIO_ERROR'],
-    expectedEvents: {
-      'error': buildErrorCallback(errorCodes.AUDIO_CAPTURE),
-      'end': null
-    },
-    doneFunc: SimpleTest.finish,
-    prefs: [["media.webspeech.test.fake_fsm_events", true]]
-  });
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+
+  performTest([
+    'EVENT_START',
+    'EVENT_AUDIO_ERROR'
+  ], {
+    'error': buildErrorCallback(errorCodes.AUDIO_CAPTURE),
+    'end': null
+  }, SimpleTest.finish);
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_call_start_from_end_handler.html
+++ b/content/media/webspeech/recognition/test/test_call_start_from_end_handler.html
@@ -15,41 +15,39 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
+
   function endHandler(evt, sr) {
     try {
       sr.start(); // shouldn't fail
     } catch (err) {
       ok(false, "Failed to start() from end() callback");
     }
 
     info("Successfully start() from end() callback");
   }
 
-  performTest({
-    eventsToRequest: [
-      'EVENT_START',
-      'EVENT_AUDIO_DATA',
-      'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
-    ],
-    expectedEvents: {
-      'start': null,
-      'audiostart': null,
-      'speechstart': null,
-      'speechend': null,
-      'audioend': null,
-      'result': buildResultCallback("Mock final result"),
-      'end': endHandler,
-    },
-    doneFunc: SimpleTest.finish,
-    prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
-  });
+  performTest([
+    'EVENT_START',
+    'EVENT_AUDIO_DATA',
+    'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
+  ], {
+    'start': null,
+    'audiostart': null,
+    'speechstart': null,
+    'speechend': null,
+    'audioend': null,
+    'result': buildResultCallback("Mock final result"),
+    'end': endHandler,
+  }, SimpleTest.finish);
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_preference_enable.html
+++ b/content/media/webspeech/recognition/test/test_preference_enable.html
@@ -12,28 +12,26 @@ https://bugzilla.mozilla.org/show_bug.cg
 <body>
 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=650295">Mozilla Bug 650295</a>
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
-  SpecialPowers.pushPrefEnv({
-    set: [["media.webspeech.recognition.enable", false]]
-  }, function() {
-    var objects = [
-      "SpeechRecognition",
-      "SpeechGrammar",
-      "SpeechRecognitionResult",
-      "SpeechRecognitionResultList",
-      "SpeechRecognitionAlternative"
-    ];
+  SpecialPowers.setBoolPref("media.webspeech.recognition.enable", false);
 
-    for (var i = 0; i < objects.length; i++) {
-      is(window[objects[i]], undefined,
-         objects[i] + " should be undefined with pref off");
-    }
-  });
+  var objects = [
+    "SpeechRecognition",
+    "SpeechGrammar",
+    "SpeechRecognitionResult",
+    "SpeechRecognitionResultList",
+    "SpeechRecognitionAlternative"
+  ];
+
+  for (var i = 0; i < objects.length; i++) {
+    is(window[objects[i]], undefined,
+       objects[i] + " should be undefined with pref off");
+  }
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_recognition_service_error.html
+++ b/content/media/webspeech/recognition/test/test_recognition_service_error.html
@@ -15,31 +15,29 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
-  performTest({
-    eventsToRequest: [
-      'EVENT_START',
-      'EVENT_AUDIO_DATA',
-      'EVENT_RECOGNITIONSERVICE_ERROR'
-    ],
-    expectedEvents: {
-      'start': null,
-      'audiostart': null,
-      'speechstart': null,
-      'speechend': null,
-      'audioend': null,
-      'error': buildErrorCallback(errorCodes.NETWORK),
-      'end': null
-    },
-    doneFunc: SimpleTest.finish,
-    prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
-  });
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
+
+  performTest([
+    'EVENT_START',
+    'EVENT_AUDIO_DATA',
+    'EVENT_RECOGNITIONSERVICE_ERROR'
+  ], {
+    'start': null,
+    'audiostart': null,
+    'speechstart': null,
+    'speechend': null,
+    'audioend': null,
+    'error': buildErrorCallback(errorCodes.NETWORK),
+    'end': null
+  }, SimpleTest.finish);
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_success_without_recognition_service.html
+++ b/content/media/webspeech/recognition/test/test_success_without_recognition_service.html
@@ -15,31 +15,29 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
-  performTest({
-    eventsToRequest: [
-      'EVENT_START',
-      'EVENT_AUDIO_DATA',
-      'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
-    ],
-    expectedEvents: {
-      'start': null,
-      'audiostart': null,
-      'speechstart': null,
-      'speechend': null,
-      'audioend': null,
-      'result': buildResultCallback("Mock final result"),
-      'end': null
-    },
-    doneFunc:SimpleTest.finish,
-    prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
-  });
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
+
+  performTest([
+    'EVENT_START',
+    'EVENT_AUDIO_DATA',
+    'EVENT_RECOGNITIONSERVICE_FINAL_RESULT'
+  ], {
+    'start': null,
+    'audiostart': null,
+    'speechstart': null,
+    'speechend': null,
+    'audioend': null,
+    'result': buildResultCallback("Mock final result"),
+    'end': null
+  }, SimpleTest.finish);
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/media/webspeech/recognition/test/test_timeout.html
+++ b/content/media/webspeech/recognition/test/test_timeout.html
@@ -15,29 +15,26 @@ https://bugzilla.mozilla.org/show_bug.cg
 <p id="display"></p>
 <div id="content" style="display: none">
 
 </div>
 <pre id="test">
 <script type="text/javascript">
   SimpleTest.waitForExplicitFinish();
 
-  performTest({
-    eventsToRequest: [
-      "EVENT_START",
-      "EVENT_AUDIO_DATA"
-    ],
-    expectedEvents: {
-      "start": null,
-      "audiostart": null,
-      "audioend": null,
-      "error": buildErrorCallback(errorCodes.NO_SPEECH),
-      "end": null
-    },
-    doneFunc: SimpleTest.finish,
-    audioSampleFile: "silence.ogg",
-    prefs: [["media.webspeech.test.fake_fsm_events", true], ["media.webspeech.test.fake_recognition_service", true]]
-  });
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_fsm_events", true);
+  SpecialPowers.setBoolPref("media.webspeech.test.fake_recognition_service", true);
+
+  performTest([
+    "EVENT_START",
+    "EVENT_AUDIO_DATA"
+  ], {
+    "start": null,
+    "audiostart": null,
+    "audioend": null,
+    "error": buildErrorCallback(errorCodes.NO_SPEECH),
+    "end": null
+  }, SimpleTest.finish, "silence.ogg");
 
 </script>
 </pre>
 </body>
 </html>