QWebEngineScript execution order
-
Is the order in which the
QWebEngineScript
s that are added to theQWebEngineScriptCollection &QWebEnginePage::scripts()
execute always the same?I have two scripts added to the list and they seemingly get executed in random order, is there any way to enforce the order in which the scripts get executed?
-
I just read through this page: https://wiki.qt.io/QtWebEngine/ScriptsAndExtensions
And it states that
Second, the scripts are executed in an undefined, essentially pseudo-random, order
Which clears it up!
Although I'd be interested in why this is the case as Windows' WebView2 seems to follow the order in which the scripts were added to their injection list.
-
I found a workaround for this, it isn't the best but I'll explain it for those interested:
You register only one script to be executed for each
injection-point
, you then assign that script a specific name.
If you want to inject another script you then search the script in the page script-collection, remove it from the list, append the new script code to the previous script and then insert it back into the list