window.open and requestAnimationFrame
window.open and requestAnimationFrame bug in FireFox
HTML
<h3>
Firefox bug with requestAnimationFrame and window.open
</h3>
<span>Allow popups to test the bug</span>
<div>Expected sequence:<br>
i0
i1
i2
1
2
</div>
<div>
Actual sequence:
</div>
<div id="out"></div>
JavaScript
const out = document.querySelector('#out');
let a = 0;
function test() {
debugger;
a++;
if(a < 2) {
requestAnimationFrame(test);
}
if(a === 1) {
for(let i=0; i<3; i++) {
if(i == 1) {
// window.open act like calling test()
window.open('https://www.google.it/');
}
out.innerHTML += 'i' + i + ' ';
console.log('i' + i);
}
}
out.innerHTML += a + ' ';
console.log(a);
}
requestAnimationFrame(test);