| 165 | } |
| 166 | |
| 167 | QVariant WebPage::runJavaScriptBlocking(const QString &scriptSource) |
| 168 | { |
| 169 | QPointer<QEventLoop> loop = new QEventLoop(); |
| 170 | QVariant result; |
| 171 | |
| 172 | runJavaScript(scriptSource, [&result, loop](const QVariant &returnValue){ |
| 173 | if (!loop.isNull() && loop->isRunning()) |
| 174 | { |
| 175 | result = returnValue; |
| 176 | loop->quit(); |
| 177 | } |
| 178 | }); |
| 179 | |
| 180 | connect(this, &WebPage::renderProcessTerminated, this, [&loop](RenderProcessTerminationStatus terminationStatus, int /*exitCode*/){ |
| 181 | if (!loop.isNull() && terminationStatus != WebPage::NormalTerminationStatus) |
| 182 | loop->quit(); |
| 183 | }); |
| 184 | connect(this, &WebPage::destroyed, loop.data(), &QEventLoop::quit); |
| 185 | |
| 186 | loop->exec(QEventLoop::ExcludeUserInputEvents); |
| 187 | delete loop; |
| 188 | |
| 189 | return result; |
| 190 | } |
| 191 | |
| 192 | void WebPage::javaScriptConsoleMessage(WebPage::JavaScriptConsoleMessageLevel level, const QString &message, int lineId, const QString &sourceId) |
| 193 | { |