I'm trying to run Javascript code containing await
in Qt's web engine. Here is a minimal example illustrating what I'm trying to do:
QWebEngineView webView;
webView.page()->runJavaScript("await (new Promise(r => setTimeout(r, 100)))");
The problem is that when I run this, I get the following Javascript error (which Qt logs in Qt Creator's console):
js: Uncaught ReferenceError: await is not defined
When I first saw this, I thought it was because Qt Web Engine uses an older version of Chromium that doesn't support await
. But using the method from my answer here, I found out that that the version of Chromium it was using was Chromium 80, and according to caniuse, await
is supported in Chromium 55 and later, so it should be supported in Chromium 80.
So my question is, why do I get this error even though it's using a version of Chromium that should support await
, and how do I fix this?