Closed Bug 791352 Opened 12 years ago Closed 9 years ago

Replace for-each statement to for-of statement in toolkit/content/widgets/

Categories

(Toolkit :: XUL Widgets, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1217082

People

(Reporter: tetsuharu, Assigned: tetsuharu)

References

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
Blocks: 791348
Attached patch patch (obsolete) (deleted) β€” β€” Splinter Review
Attached patch patch rev2 (deleted) β€” β€” Splinter Review
ECMA-357(E4X) is deprecated.
We should use for-of statement instead of for-each statement.
Attachment #661346 - Attachment is obsolete: true
Attachment #661459 - Flags: review?(dolske)
Comment on attachment 661459 [details] [diff] [review]
patch rev2

Review of attachment 661459 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with the one change, all the callers are indeed passing in arrays.

::: toolkit/content/widgets/videocontrols.xml
@@ +658,3 @@
>                          element.item.removeEventListener(element.event, element.func, false);
>  
> +                    this.controlListeners = [];

Why this change? Seems unrelated, so please revert to |delete this.controlListeners|.
Attachment #661459 - Flags: review?(dolske) → review+
Assignee: nobody → saneyuki.s.snyk
Component: XP Toolkit/Widgets: XUL → XUL Widgets
Product: Core → Toolkit
(In reply to Justin Dolske [:Dolske] from comment #3)
> Comment on attachment 661459 [details] [diff] [review]
> patch rev2
> 
> Review of attachment 661459 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> r+ with the one change, all the callers are indeed passing in arrays.
> 
> ::: toolkit/content/widgets/videocontrols.xml
> @@ +658,3 @@
> >                          element.item.removeEventListener(element.event, element.func, false);
> >  
> > +                    this.controlListeners = [];
> 
> Why this change? Seems unrelated, so please revert to |delete
> this.controlListeners|.

This is a safety guard.
for-of statement is different from for-each, so it occur the error if the iteration target has no property; like "TypeError: (this.controlListeners) is not iterable".

I know that we will avoid it with using the syntax like:

  for (let [,i] of Iterator(this.controlListeners)) {
  ...
  }

But this is not clearly. I don't like this.

Or should I write following?:

  if (this.controlListeners) {
    for (let element of this.controlListeners) {
    ...
    }
  }
(In reply to OHZEKI Tetsuharu [:saneyuki_s] from comment #4)
 
> > > +                    this.controlListeners = [];
> > 
> > Why this change? Seems unrelated, so please revert to |delete
> > this.controlListeners|.
> 
> This is a safety guard.

Ah. It shouldn't be needed, though... terminateEventListeners() is only called when the video controls are being torn down, after which no further code form that context should be running. I'd consider it a bug if anything was to reference controlListeners after this point.
(In reply to Justin Dolske [:Dolske] from comment #5)
> Ah. It shouldn't be needed, though... terminateEventListeners() is only
> called when the video controls are being torn down, after which no further
> code form that context should be running. I'd consider it a bug if anything
> was to reference controlListeners after this point.

Previously, I had tested this patch, this parts caused the error. So I insert its guard. Even so should we fix to reference controlListeners after this point? Or make the patch to fix it at now?
Can you reproduce the error? How?

It shouldn't be happening, so if it is there's a (separate) bug going on. I'd like to understand what's happening... Then I can either fix it or let you land with the workaround.
This is the result which I tried on try-server:
https://tbpl.mozilla.org/?tree=Try&rev=3b2e59478b7d

From the result, it looks videocontrols.xml is failed on relating in mochitest-1.
Blocks: 825801
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: