unexpected behavior with promise based code inside iterator

RESOLVED DUPLICATE of bug 449811

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 449811
a year ago
a year ago

People

(Reporter: djrmuv, Unassigned)

Tracking

50 Branch
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

371 bytes, text/html
Details
(Reporter)

Description

a year ago
Created attachment 8818749 [details]
t.html

User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0
Build ID: 20161130084355

Steps to reproduce:

ALSO check the attached file

var arr = ['a', 'b', 'c']

		for (let item of arr) {
			new Promise((resolve, reject) => {
				window.setTimeout(function() {
	                resolve(item);
	            }, Math.random() * 200);
			}).then((v) => {
				console.log(v);
			})
		}


Actual results:

so in chrome it prints a permutation of the arr elements, whereas in firefox it always prints "c" three times. i dont know which should be the correct behavior but the chrome one seems more intuitive

this problem is also present in firefix nightly


Expected results:

logging a permutation of arr
(Reporter)

Updated

a year ago
OS: Unspecified → Linux
Hardware: Unspecified → x86_64
It should be fixed in Firefox 51 (bug 449811)
can you check if it works as expected on Firefox 51 beta?
Flags: needinfo?(djrmuv)
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
(Reporter)

Comment 2

a year ago
mm yeah it works on the developer edition 51.0a2, but it does not on nightly, but i guess it will also be fixed there thanks.
if it doesn't work on nightly, can you post the standalone testcase?
and also what's the version and build date of the nightly you've tested?

when I evaluate the code in web console, it prints permutation of arr.
I've tested on 53.0a1 (2016-12-13) (64-bit).
(Reporter)

Comment 5

a year ago
oh yeah, it work on 53.0a1, sorry.
okay, thank you :)
Status: UNCONFIRMED → RESOLVED
Last Resolved: a year ago
Flags: needinfo?(djrmuv)
Resolution: --- → DUPLICATE
Duplicate of bug: 449811
You need to log in before you can comment on or make changes to this bug.