MCPcopy Create free account
hub / github.com/LeFroid/Viper-Browser / runJavaScriptBlocking

Method runJavaScriptBlocking

src/core/web/WebPage.cpp:167–190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167QVariant 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
192void WebPage::javaScriptConsoleMessage(WebPage::JavaScriptConsoleMessageLevel level, const QString &message, int lineId, const QString &sourceId)
193{

Callers 1

WebHitTestResultMethod · 0.80

Calls 2

execMethod · 0.80
dataMethod · 0.45

Tested by 1

WebHitTestResultMethod · 0.64