Closed Bug 1323615 Opened 3 years ago Closed 3 years ago

unexpected behavior with promise based code inside iterator

Categories

(Core :: JavaScript Engine, defect)

50 Branch
x86_64
Linux
defect
Not set

Tracking

()

RESOLVED DUPLICATE of bug 449811

People

(Reporter: djrmuv, Unassigned)

Details

Attachments

(1 file)

371 bytes, text/html
Details
Attached file 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
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
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).
oh yeah, it work on 53.0a1, sorry.
okay, thank you :)
Status: UNCONFIRMED → RESOLVED
Closed: 3 years 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.