Backed out changeset 916c30e50af1: Bug 1347515 which was backed out from M-B. a=jorgk
authorJorg K
Tue, 14 Nov 2017 15:28:42 +0100
changeset 29376 778fc98a593fac351fedb4477fd2ce39629bc9cd
parent 29375 a53e3e2a9ba92ac4d8d4190d03222043004afa48
child 29377 b4b33e1604e113149a9c5401f8248b687a0dd79e
push id2071
push usermozilla@jorgk.com
push dateTue, 14 Nov 2017 14:31:20 +0000
treeherdercomm-beta@b4b33e1604e1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1347515
backs out916c30e50af1a63a49ffc17935c985e9602b39aa
Backed out changeset 916c30e50af1: Bug 1347515 which was backed out from M-B. a=jorgk
calendar/test/unit/head_consts.js
chat/modules/imSmileys.jsm
--- a/calendar/test/unit/head_consts.js
+++ b/calendar/test/unit/head_consts.js
@@ -6,23 +6,18 @@
  *          readJSONFile, ics_unfoldline, compareItemsSpecific, getStorageCal,
  *          getMemoryCal, createTodoFromIcalString, createEventFromIcalString,
  *          createDate, Cc, Ci, Cr, Cu
  */
 
 Components.utils.import("resource://gre/modules/Services.jsm");
 Components.utils.import("resource://gre/modules/Preferences.jsm");
 Components.utils.import("resource://gre/modules/FileUtils.jsm");
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
 
 Components.utils.import("resource://testing-common/AppInfo.jsm");
-
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
-
 updateAppInfo();
 
 var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components;
 
 (function() {
     let bindir = Services.dirsvc.get("CurProcD", Components.interfaces.nsIFile);
     bindir.append("extensions");
     bindir.append("{e2fda1a4-762b-4020-b5ad-a41df1933103}");
@@ -195,18 +190,18 @@ function ics_unfoldline(aLine) {
 
 /**
  * Read a JSON file and return the JS object
  */
 function readJSONFile(aFile) {
     let stream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
     try {
         stream.init(aFile, FileUtils.MODE_RDONLY, FileUtils.PERMS_FILE, 0);
-        let bytes = NetUtil.readInputStream(stream, stream.available());
-        let data = JSON.parse((new TextDecoder()).decode(bytes));
+        let json = Cc["@mozilla.org/dom/json;1"].createInstance(Components.interfaces.nsIJSON);
+        let data = json.decodeFromStream(stream, stream.available());
         return data;
     } catch (ex) {
         dump("readJSONFile: Error reading JSON file: " + ex);
     } finally {
         stream.close();
     }
     return false;
 }
--- a/chat/modules/imSmileys.jsm
+++ b/chat/modules/imSmileys.jsm
@@ -1,21 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 Components.utils.import("resource:///modules/imServices.jsm");
-Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyGetter(this, "gTextDecoder", () => {
-  return new TextDecoder();
-});
-
-XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
-                                  "resource://gre/modules/NetUtil.jsm");
 
 this.EXPORTED_SYMBOLS = [
   "smileImMarkup", // used to add smile:// img tags into IM markup.
   "smileTextNode", // used to add smile:// img tags to the content of a textnode
   "smileString", // used to add smile:// img tags into a string without parsing it as HTML. Be sure the string doesn't contain HTML tags.
   "getSmileRealURI", // used to retrive the chrome URI for a smile:// URI
   "getSmileyList" // used to display a list of smileys in the UI
 ];
@@ -87,18 +79,19 @@ function getTheme(aName)
     theme.baseUri = "chrome://" + theme.name + "/skin/";
   try {
     let channel = Services.io.newChannel2(theme.baseUri + kThemeFile, null, null, null,
                                           Services.scriptSecurityManager.getSystemPrincipal(),
                                           null,
                                           Components.interfaces.nsILoadInfo.SEC_ALLOW_CROSS_ORIGIN_DATA_IS_NULL,
                                           Components.interfaces.nsIContentPolicy.TYPE_IMAGE);
     let stream = channel.open();
-    let bytes = NetUtil.readInputStream(stream, stream.available());
-    theme.json = JSON.parse(gTextDecoder.decode(bytes));
+    let json = Components.classes["@mozilla.org/dom/json;1"]
+                         .createInstance(Components.interfaces.nsIJSON);
+    theme.json = json.decodeFromStream(stream, stream.available());
     stream.close();
     theme.iconsHash = {};
     for (let smiley of theme.json.smileys) {
       for (let textCode of smiley.textCodes)
         theme.iconsHash[textCode] = smiley;
     }
   } catch(e) {
     Components.utils.reportError(e);