Closed Bug 914066 Opened 6 years ago Closed 6 years ago

chrome://global/content/bindings/preferences.xml:696, in strict mode code, functions may be declared only at top level or immediately within another function

Categories

(Firefox :: Preferences, defect)

All
Linux
defect
Not set

Tracking

()

RESOLVED FIXED
Firefox 26

People

(Reporter: ishikawa, Assigned: ishikawa)

Details

Attachments

(1 file)

I got the following warning with DEBUG BUILD of comm-central thunderbird.
The warning comes from preferences.xml.

chrome://global/content/bindings/preferences.xml:696,  in strict mode code, functions may be declared only at top level or immediately within another function.

I see a few different perferences.xml files:
mozilla/mobile/android/base/resources/xml/preferences.xml.in
mozilla/mobile/android/base/resources/xml-v11/preferences.xml
mozilla/toolkit/content/widgets/preferences.xml

Since I was building and testing for Debian GNU/Linux 32 bits,
I assume the last file is the one that caused the printing of the warning.
The line number may be slightly off in the current code.
The code around the line 696 on my copy is as follows.
(mxr.mozilla.org shows similar code at
http://mxr.mozilla.org/comm-central/source/mozilla/toolkit/content/widgets/preferences.xml#733
)
 

      <method name="showPane">
        <parameter name="aPaneElement"/>
        <body>
        <![CDATA[
          if (!aPaneElement)
            return;

          this._selector.selectedItem = document.getAnonymousElementByAttribute(this, "pane", aPaneElement.id);
          if (!aPaneElement.loaded) {
--->        function OverlayLoadObserver(aPane)
            {
              this._pane = aPane;
            }
            OverlayLoadObserver.prototype = { 
              _outer: this,
              observe: function (aSubject, aTopic, aData) 
              {
                this._pane.loaded = true;
                this._outer._fireEvent("paneload", this._pane);
                this._outer._selectPane(this._pane);
              }
            };
            
            var obs = new OverlayLoadObserver(aPaneElement);
            document.loadOverlay(aPaneElement.src, obs);
          }
          else
            this._selectPane(aPaneElement);
        ]]>
        </body>
      </method>

The code looks clever, but since this is one of the few files that
triggered this warning, I think it ought to be fixed to suppress the warning.
But I am not sure how to rewrite the code for this type of embedded javascript.
So I defer the modification to people in the know.

TIA
This is easy to fix:

replace "function OverlayLoadObserver(aPane)" with "let OverlayLoadObserver = function(aPane)"
Component: Preferences: Backend → Preferences
Product: Core → Firefox
OK, here is the patch that fixes the issue.
I tested it by running |make mozmill| locally and there is no more warning of this type.

TIA
Attachment #802063 - Flags: review?(benjamin)
Assignee: nobody → ishikawa
Attachment #802063 - Flags: review?(benjamin) → review+
Thank you. I will put in the checkin-needed keyword.
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/c3384a3b4280
Status: NEW → RESOLVED
Closed: 6 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Whiteboard: [fixed-in-fx-team]
Target Milestone: --- → Firefox 26
You need to log in before you can comment on or make changes to this bug.