Delayed BoundFunctionObject callback fails silently when website uses a script inside an iframe to modify the parent DOM
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
People
(Reporter: christophg+mozilla, Unassigned)
Details
User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0
Steps to reproduce:
I've not been able to create a minimal reproducible example yet, but it can be reproduced on online shops using the Ecwid shop system with a LegacyFrontend script, e.g.:
BoundFunctionObjects passed as callbacks to native functions that execute after some delay (addEventListener, requestAnimationFrame, setTimeout, etc.) are (almost always, seemingly non-deterministically) not executed on the affected websites.
These websites run a script that creates a new iframe and inserts HTML that loads another script (https://d11s7fcxy18ubx.cloudfront.net/node/static/2024/2024-20917-g8034a8bca79801/ru.cdev.xnext.frontend.LegacyFrontend/48410E1E88A2B23ABE7FAE61EF15766C.cache.js) that accesses the DOM of the parent document. When this script is loaded, the described issue appears. It doesn't happen in Google Chrome. As far as I could check the script doesn't interfere with requestAnimationFrame etc. directly. The affected functions are not wrapped/overwritten.
To reproduce:
- Open one of the mentioned affected websites:
- Move the mouse cursor inside the content window to let their delayed scripts load.
- Open the console in developer tools.
- Enter the following Javascript code.
requestAnimationFrame(function () {
requestAnimationFrame(function () { console.log("ok"); }.bind(this))
}.bind(document.body));
Actual results:
The callback passed to the inner requestAnimationFrame is not executed, "ok" is not printed to the console.
The same happens for similar code using setTimeout or addEventListener when the passed callback is a BoundFunctionObject.
Expected results:
The callback passed to the inner requestAnimationFrame should have been executed after two frames. "ok" should have been printed to the console.
Comment 1•1 year ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Widget: Gtk' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.
| Reporter | ||
Updated•1 year ago
|
Comment 2•1 year ago
|
||
Olli, do you know if this is a DOM issue or a....JS scope thingy?
Comment 3•1 year ago
|
||
Is the iframe removed from DOM at some point before the functions should be executed?
Updated•1 year ago
|
| Reporter | ||
Comment 4•1 year ago
|
||
Is the iframe removed from DOM at some point before the functions should be executed?
As far as I can tell it isn't removed from the DOM. And even if I manually remove it from the DOM, all Javascript code in the context of the main window stays affected once the iframe's script had executed.
Updated•1 year ago
|
Description
•