Bug 1239118 - Export an object named after module in NewTabRemoteResource r?ursula draft
authorOlivier Yiptong <olivier@olivieryiptong.com>
Thu, 03 Mar 2016 15:51:38 -0500 (2016-03-03)
changeset 337003 04a4f82f4b74c72e52e2aa2afbc1684822707401
parent 336966 e7319545eb3819da67ffe1d4233022ae71e3a9a1
child 337004 8cc59631f432096df9956fc6abcfc579416f78b9
child 338132 377e58add1ae821a45f1c06d87b7412babc4f43b
child 338187 fcae42ec34743edf473c12b1b0ea4aeb548b2436
child 338191 c73060a32dd2cf1a17dec421a76e0919637a0052
push id12245
push userolivier@olivieryiptong.com
push dateFri, 04 Mar 2016 18:38:32 +0000 (2016-03-04)
reviewersursula
bugs1239118
milestone47.0a1
Bug 1239118 - Export an object named after module in NewTabRemoteResource r?ursula MozReview-Commit-ID: EB7Or6jhoN7
browser/components/newtab/NewTabRemoteResources.jsm
browser/components/newtab/aboutNewTabService.js
--- a/browser/components/newtab/NewTabRemoteResources.jsm
+++ b/browser/components/newtab/NewTabRemoteResources.jsm
@@ -1,13 +1,15 @@
-/* exported MODE_CHANNEL_MAP */
+/* exported NewTabRemoteResources */
 
 "use strict";
 
-this.EXPORTED_SYMBOLS = ["MODE_CHANNEL_MAP"];
+this.EXPORTED_SYMBOLS = ["NewTabRemoteResources"];
 
-const MODE_CHANNEL_MAP = {
-  "production": {origin: "https://content.cdn.mozilla.net"},
-  "staging": {origin: "https://content-cdn.stage.mozaws.net"},
-  "test": {origin: "https://example.com"},
-  "test2": {origin: "http://mochi.test:8888"},
-  "dev": {origin: "http://localhost:8888"}
+const NewTabRemoteResources = {
+  MODE_CHANNEL_MAP: {
+    production: {origin: "https://content.cdn.mozilla.net"},
+    staging: {origin: "https://content-cdn.stage.mozaws.net"},
+    test: {origin: "https://example.com"},
+    test2: {origin: "http://mochi.test:8888"},
+    dev: {origin: "http://localhost:8888"}
+  }
 };
--- a/browser/components/newtab/aboutNewTabService.js
+++ b/browser/components/newtab/aboutNewTabService.js
@@ -1,31 +1,31 @@
 /*
  * 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/.
 */
 
 /* globals XPCOMUtils, NewTabPrefsProvider, Services,
-  Locale, UpdateUtils, MODE_CHANNEL_MAP
+  Locale, UpdateUtils, NewTabRemoteResources
 */
 "use strict";
 
 const {utils: Cu, interfaces: Ci} = Components;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Services.jsm");
 
 XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils",
                                   "resource://gre/modules/UpdateUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NewTabPrefsProvider",
                                   "resource:///modules/NewTabPrefsProvider.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Locale",
                                   "resource://gre/modules/Locale.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "MODE_CHANNEL_MAP",
+XPCOMUtils.defineLazyModuleGetter(this, "NewTabRemoteResources",
                                   "resource:///modules/NewTabRemoteResources.jsm");
 
 const LOCAL_NEWTAB_URL = "chrome://browser/content/newtab/newTab.xhtml";
 
 const REMOTE_NEWTAB_PATH = "/v%VERSION%/%CHANNEL%/%LOCALE%/index.html";
 
 const ABOUT_URL = "about:newtab";
 
@@ -153,20 +153,20 @@ AboutNewTabService.prototype = {
    */
   generateRemoteURL() {
     let releaseName = this.releaseFromUpdateChannel(UpdateUtils.UpdateChannel);
     let path = REMOTE_NEWTAB_PATH
       .replace("%VERSION%", REMOTE_NEWTAB_VERSION)
       .replace("%LOCALE%", Locale.getLocale())
       .replace("%CHANNEL%", releaseName);
     let mode = Services.prefs.getCharPref(PREF_REMOTE_MODE, "production");
-    if (!(mode in MODE_CHANNEL_MAP)) {
+    if (!(mode in NewTabRemoteResources.MODE_CHANNEL_MAP)) {
       mode = "production";
     }
-    return MODE_CHANNEL_MAP[mode].origin + path;
+    return NewTabRemoteResources.MODE_CHANNEL_MAP[mode].origin + path;
   },
 
   /*
    * Returns the default URL.
    *
    * This URL only depends on the browser.newtabpage.remote pref. Overriding
    * the newtab page has no effect on the result of this function.
    *