Bug 718239. (Bv1a) accessible/tests/mochitest/events.js: Use Services.jsm. r=surkov.alexander.
authorSerge Gautherie <sgautherie.bz@free.fr>
Fri, 20 Jan 2012 12:49:41 +0100
changeset 86163 6af8c11d727ab056898c3139fdb71d6a381fe8c0
parent 86162 eb0fb073ac35e561a7dfa144a3e398096eb86ce1
child 86164 7edc6c4cf83d12ecb16b685dc374c22f8c61cb5e
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs718239
milestone12.0a1
Bug 718239. (Bv1a) accessible/tests/mochitest/events.js: Use Services.jsm. r=surkov.alexander.
accessible/tests/mochitest/events.js
--- a/accessible/tests/mochitest/events.js
+++ b/accessible/tests/mochitest/events.js
@@ -26,16 +26,18 @@ const EVENT_TEXT_CARET_MOVED = nsIAccess
 const EVENT_TEXT_INSERTED = nsIAccessibleEvent.EVENT_TEXT_INSERTED;
 const EVENT_TEXT_REMOVED = nsIAccessibleEvent.EVENT_TEXT_REMOVED;
 const EVENT_TEXT_SELECTION_CHANGED = nsIAccessibleEvent.EVENT_TEXT_SELECTION_CHANGED;
 const EVENT_VALUE_CHANGE = nsIAccessibleEvent.EVENT_VALUE_CHANGE;
 
 ////////////////////////////////////////////////////////////////////////////////
 // General
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 /**
  * Set up this variable to dump events into DOM.
  */
 var gA11yEventDumpID = "";
 
 /**
  * Set up this variable to dump event processing into console.
  */
@@ -1409,34 +1411,28 @@ function expandedStateChecker(aIsEnabled
 ////////////////////////////////////////////////////////////////////////////////
 // General
 
 var gA11yEventListeners = {};
 var gA11yEventApplicantsCount = 0;
 
 var gA11yEventObserver =
 {
-  // The service reference needs to live in the observer, instead of as a global var,
-  //   to be available in observe() catch case too.
-  observerService :
-    Components.classes["@mozilla.org/observer-service;1"]
-              .getService(nsIObserverService),
-
   observe: function observe(aSubject, aTopic, aData)
   {
     if (aTopic != "accessible-event")
       return;
 
     var event;
     try {
       event = aSubject.QueryInterface(nsIAccessibleEvent);
     } catch (ex) {
       // After a test is aborted (i.e. timed out by the harness), this exception is soon triggered.
       // Remove the leftover observer, otherwise it "leaks" to all the following tests.
-      this.observerService.removeObserver(this, "accessible-event");
+      Services.obs.removeObserver(this, "accessible-event");
       // Forward the exception, with added explanation.
       throw "[accessible/events.js, gA11yEventObserver.observe] This is expected if a previous test has been aborted... Initial exception was: [ " + ex + " ]";
     }
     var listenersArray = gA11yEventListeners[event.eventType];
 
     var eventFromDumpArea = false;
     if (gLogger.isEnabled()) { // debug stuff
       eventFromDumpArea = true;
@@ -1480,24 +1476,22 @@ var gA11yEventObserver =
   }
 };
 
 function listenA11yEvents(aStartToListen)
 {
   if (aStartToListen) {
     // Add observer when adding the first applicant only.
     if (!(gA11yEventApplicantsCount++))
-      gA11yEventObserver.observerService
-                        .addObserver(gA11yEventObserver, "accessible-event", false);
+      Services.obs.addObserver(gA11yEventObserver, "accessible-event", false);
   } else {
     // Remove observer when there are no more applicants only.
     // '< 0' case should not happen, but just in case: removeObserver() will throw.
     if (--gA11yEventApplicantsCount <= 0)
-      gA11yEventObserver.observerService
-                        .removeObserver(gA11yEventObserver, "accessible-event");
+      Services.obs.removeObserver(gA11yEventObserver, "accessible-event");
   }
 }
 
 function addA11yEventListener(aEventType, aEventHandler)
 {
   if (!(aEventType in gA11yEventListeners))
     gA11yEventListeners[aEventType] = new Array();
 
@@ -1596,29 +1590,26 @@ var gLogger =
 
   /**
    * Log message to console.
    */
   logToConsole: function logger_logToConsole(aMsg)
   {
     if (gA11yEventDumpToConsole)
       dump("\n" + aMsg + "\n");
-  },
+  }
 
   /**
    * Log message to error console.
    */
   logToAppConsole: function logger_logToAppConsole(aMsg)
   {
     if (gA11yEventDumpToAppConsole)
-      consoleService.logStringMessage("events: " + aMsg);
+      Services.console.logStringMessage("events: " + aMsg);
   },
-
-  consoleService: Components.classes["@mozilla.org/consoleservice;1"].
-    getService(Components.interfaces.nsIConsoleService)
 };
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // Sequence
 
 /**
  * Base class of sequence item.