Bug 1049979 - Fix 'functions may be declared only at top level or immediately within another function' warnings. r=gavin
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Sun, 10 Aug 2014 11:16:32 -0700
changeset 198801 30445fb9d44f8273e071c3d7c05eebc1b7f8a832
parent 198800 2334cddcd2c3ef3c8fc96be8f3e81aa26665e61d
child 198802 04e5f312664f9c6fecddbb71eab9241c0bbdc1f0
push id27286
push usernigelbabu@gmail.com
push dateMon, 11 Aug 2014 06:26:45 +0000
treeherdermozilla-central@8c4a1b3a2a8b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs1049979
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1049979 - Fix 'functions may be declared only at top level or immediately within another function' warnings. r=gavin
browser/components/nsBrowserGlue.js
toolkit/components/places/PlacesUtils.jsm
toolkit/components/search/nsSearchService.js
toolkit/components/url-classifier/content/moz/debug.js
toolkit/components/url-classifier/content/moz/observer.js
toolkit/components/url-classifier/content/moz/preferences.js
toolkit/components/url-classifier/content/moz/protocol4.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1412,23 +1412,23 @@ BrowserGlue.prototype = {
       // If the user does not have a persisted value for the toolbar's
       // "collapsed" attribute, try to determine whether it's customized.
       if (collapsed === null) {
         // We consider the toolbar customized if it has more than
         // 3 children, or if it has a persisted currentset value.
         let currentsetResource = this._rdf.GetResource("currentset");
         let toolbarIsCustomized = !!this._getPersist(toolbarResource,
                                                      currentsetResource);
-        function getToolbarFolderCount() {
+        let getToolbarFolderCount = function () {
           let toolbarFolder =
             PlacesUtils.getFolderContents(PlacesUtils.toolbarFolderId).root;
           let toolbarChildCount = toolbarFolder.childCount;
           toolbarFolder.containerOpen = false;
           return toolbarChildCount;
-        }
+        };
 
         if (toolbarIsCustomized || getToolbarFolderCount() > 3) {
           this._setPersist(toolbarResource, collapsedResource, "false");
         }
       }
     }
 
     if (currentUIVersion < 8) {
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -530,44 +530,44 @@ this.PlacesUtils = {
         let [node, shouldClose] = convertNode(aNode);
         this._serializeNodeAsJSONToOutputStream(node, writer);
         if (shouldClose)
           node.containerOpen = false;
 
         return writer.value;
       }
       case this.TYPE_X_MOZ_URL: {
-        function gatherDataUrl(bNode) {
+        let gatherDataUrl = function (bNode) {
           if (isLivemark(bNode)) {
             return gatherLivemarkUrl(bNode) + NEWLINE + bNode.title;
           }
 
           if (PlacesUtils.nodeIsURI(bNode))
             return (aOverrideURI || bNode.uri) + NEWLINE + bNode.title;
           // ignore containers and separators - items without valid URIs
           return "";
-        }
+        };
 
         let [node, shouldClose] = convertNode(aNode);
         let dataUrl = gatherDataUrl(node);
         if (shouldClose)
           node.containerOpen = false;
 
         return dataUrl;
       }
       case this.TYPE_HTML: {
-        function gatherDataHtml(bNode) {
-          function htmlEscape(s) {
+        let gatherDataHtml = function (bNode) {
+          let htmlEscape = function (s) {
             s = s.replace(/&/g, "&amp;");
             s = s.replace(/>/g, "&gt;");
             s = s.replace(/</g, "&lt;");
             s = s.replace(/"/g, "&quot;");
             s = s.replace(/'/g, "&apos;");
             return s;
-          }
+          };
           // escape out potential HTML in the title
           let escapedTitle = bNode.title ? htmlEscape(bNode.title) : "";
 
           if (isLivemark(bNode)) {
             return "<A HREF=\"" + gatherLivemarkUrl(bNode) + "\">" + escapedTitle + "</A>" + NEWLINE;
           }
 
           if (PlacesUtils.nodeIsContainer(bNode)) {
--- a/toolkit/components/search/nsSearchService.js
+++ b/toolkit/components/search/nsSearchService.js
@@ -1579,17 +1579,17 @@ Engine.prototype = {
       case "ftp":
         // No use downloading the icon if the engine file is read-only
         if (!this._readOnly ||
             getBoolPref(BROWSER_SEARCH_PREF + "cache.enabled", true)) {
           LOG("_setIcon: Downloading icon: \"" + uri.spec +
               "\" for engine: \"" + this.name + "\"");
           var chan = NetUtil.ioService.newChannelFromURI(uri);
 
-          function iconLoadCallback(aByteArray, aEngine) {
+          let iconLoadCallback = function (aByteArray, aEngine) {
             // This callback may run after we've already set a preferred icon,
             // so check again.
             if (aEngine._hasPreferredIcon && !aIsPreferred)
               return;
 
             if (!aByteArray || aByteArray.length > MAX_ICON_SIZE) {
               LOG("iconLoadCallback: load failed, or the icon was too large!");
               return;
@@ -4733,17 +4733,17 @@ var engineMetadataService = {
     LOG("metadata _commit: start");
     if (!this._store) {
       LOG("metadata _commit: nothing to do");
       return;
     }
 
     if (!this._lazyWriter) {
       LOG("metadata _commit: initializing lazy writer");
-      function writeCommit() {
+      let writeCommit = function () {
         LOG("metadata writeCommit: start");
         let data = gEncoder.encode(JSON.stringify(engineMetadataService._store));
         let path = engineMetadataService._jsonFile;
         LOG("metadata writeCommit: path " + path);
         let promise = OS.File.writeAtomic(path, data, { tmpPath: path + ".tmp" });
         promise = promise.then(
           function onSuccess() {
             Services.obs.notifyObservers(null,
--- a/toolkit/components/url-classifier/content/moz/debug.js
+++ b/toolkit/components/url-classifier/content/moz/debug.js
@@ -706,17 +706,17 @@ G_Loggifier.prototype.loggify = function
     this.mark_(obj);
 
     // Helper function returns an instrumented version of
     // objName.meth, with "this" bound properly. (BTW, because we're
     // in a conditional here, functions will only be defined as
     // they're encountered during execution, so declare this helper
     // before using it.)
 
-    function wrap(meth, objName, methName) {
+    let wrap = function (meth, objName, methName) {
       return function() {
         
         // First output the call along with actual parameters
         var args = new Array(arguments.length);
         var argsString = "";
         for (var i = 0; i < args.length; i++) {
           args[i] = arguments[i];
           argsString += (i == 0 ? "" : ", ");
--- a/toolkit/components/url-classifier/content/moz/observer.js
+++ b/toolkit/components/url-classifier/content/moz/observer.js
@@ -107,21 +107,21 @@ function TEST_G_Observer() {
     var z = "observer UNITTEST";
     G_debugService.enableZone(z);
 
     G_Debug(z, "Starting");
 
     var regularObserverRan = 0;
     var observerServiceObserverRan = 0;
 
-    function regularObserver() {
+    let regularObserver = function () {
       regularObserverRan++;
     };
 
-    function observerServiceObserver() {
+    let observerServiceObserver = function () {
       observerServiceObserverRan++;
     };
 
     var service = Cc["@mozilla.org/observer-service;1"]
                   .getService(Ci.nsIObserverService);
     var topic = "google-observer-test";
 
     var o1 = new G_ObserverWrapper(topic, regularObserver);
--- a/toolkit/components/url-classifier/content/moz/preferences.js
+++ b/toolkit/components/url-classifier/content/moz/preferences.js
@@ -239,17 +239,17 @@ function TEST_G_Preferences() {
 
     var p = new G_Preferences();
     
     var testPref = "test-preferences-unittest";
     var noSuchPref = "test-preferences-unittest-aypabtu";
     
     // Used to test observing
     var observeCount = 0;
-    function observe(prefChanged) {
+    let observe = function (prefChanged) {
       G_Assert(z, prefChanged == testPref, "observer broken");
       observeCount++;
     };
 
     // Test setting, getting, and observing
     p.addObserver(testPref, observe);
     p.setPref(testPref, true);
     G_Assert(z, p.getPref(testPref), "get or set broken");
--- a/toolkit/components/url-classifier/content/moz/protocol4.js
+++ b/toolkit/components/url-classifier/content/moz/protocol4.js
@@ -84,17 +84,17 @@ function TEST_G_Protocol4Parser() {
   if (G_GDEBUG) {
     var z = "protocol4 UNITTEST";
     G_debugService.enableZone(z);
 
     G_Debug(z, "Starting");
 
     var p = new G_Protocol4Parser();
     
-    function isEmpty(map) {
+    let isEmpty = function (map) {
       for (var key in map) 
         return false;
       return true;
     };
 
     G_Assert(z, isEmpty(p.parse(null)), "Parsing null broken");
     G_Assert(z, isEmpty(p.parse("")), "Parsing nothing broken");