Bug 1297446 - Shimwaiver for l10n. r=billm a=lizzard
authorGabor Krizsanits <gkrizsanits@mozilla.com>
Wed, 31 Aug 2016 10:59:28 +0200
changeset 347968 8fd9e2518fc2730431cca774b377ed5f7bf577fe
parent 347967 6c81e14892719ff017d92f61dff2f41f57b764e0
child 347969 a46345ccdae2f09ab412abe89ae28281419d0565
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, lizzard
bugs1297446
milestone50.0a2
Bug 1297446 - Shimwaiver for l10n. r=billm a=lizzard
addon-sdk/source/lib/sdk/content/l10n-html.js
--- a/addon-sdk/source/lib/sdk/content/l10n-html.js
+++ b/addon-sdk/source/lib/sdk/content/l10n-html.js
@@ -2,21 +2,25 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 "use strict";
 
 module.metadata = {
   "stability": "unstable"
 };
 
-const { Ci } = require("chrome");
+const { Ci, Cc, Cu } = require("chrome");
 const core = require("../l10n/core");
 const { loadSheet, removeSheet } = require("../stylesheet/utils");
 const { process, frames } = require("../remote/child");
-const { Services } = require("resource://gre/modules/Services.jsm");
+var observerService = Cc["@mozilla.org/observer-service;1"]
+                      .getService(Ci.nsIObserverService);
+const { ShimWaiver } = Cu.import("resource://gre/modules/ShimWaiver.jsm");
+const addObserver = ShimWaiver.getProperty(observerService, "addObserver");
+const removeObserver = ShimWaiver.getProperty(observerService, "removeObserver");
 
 const assetsURI = require('../self').data.url();
 
 const hideSheetUri = "data:text/css,:root {visibility: hidden !important;}";
 
 function translateElementAttributes(element) {
   // Translateable attributes
   const attrList = ['title', 'accesskey', 'alt', 'label', 'placeholder'];
@@ -110,20 +114,20 @@ function onContentWindow(document) {
 
 // Listen to creation of content documents in order to translate them as soon
 // as possible in their loading process
 const ON_CONTENT = "document-element-inserted";
 let enabled = false;
 function enable() {
   if (enabled)
     return;
-  Services.obs.addObserver(onContentWindow, ON_CONTENT, false);
+  addObserver(onContentWindow, ON_CONTENT, false);
   enabled = true;
 }
 process.port.on("sdk/l10n/html/enable", enable);
 
 function disable() {
   if (!enabled)
     return;
-  Services.obs.removeObserver(onContentWindow, ON_CONTENT);
+  removeObserver(onContentWindow, ON_CONTENT);
   enabled = false;
 }
 process.port.on("sdk/l10n/html/disable", disable);