Catching JavaScript error messages.
-
wrote on 12 Jan 2017, 13:47 last edited by McLion 1 Dec 2017, 14:32
Hi,
To catch JavaScript alert message boxes I reimplemented
javaScriptAlert(QWebFrame * frame, const QString & msg)
to catch alert messages - works as supposed.Do I need to reimplement some other function to catch ALL message boxes?
I need to catch the follwoing message as well that seem to occur from time to time but I can not simulate it here in the lab:
The script on this page appears to have a problem. Do you want to stop the script.
The tite of the Message box says JavaScript Problem - IP ....
Is this covered by reimplementingjavaScriptAlert(QWebFrame * frame, const QString & msg)
I see there a some other like:
javaScriptConfirm(QWebFrame * frame, const QString & msg) javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result) shouldInterruptJavaScript()
Do I need to reimplement these too?
Thanks
McL -
Hi,
To catch JavaScript alert message boxes I reimplemented
javaScriptAlert(QWebFrame * frame, const QString & msg)
to catch alert messages - works as supposed.Do I need to reimplement some other function to catch ALL message boxes?
I need to catch the follwoing message as well that seem to occur from time to time but I can not simulate it here in the lab:
The script on this page appears to have a problem. Do you want to stop the script.
The tite of the Message box says JavaScript Problem - IP ....
Is this covered by reimplementingjavaScriptAlert(QWebFrame * frame, const QString & msg)
I see there a some other like:
javaScriptConfirm(QWebFrame * frame, const QString & msg) javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result) shouldInterruptJavaScript()
Do I need to reimplement these too?
Thanks
McLwrote on 12 Jan 2017, 15:47 last edited by@McLion Each of listed methods implements its own kind of dialog box, so e.g. to have customized dialogs with your own style you have to implement them all.
Message box you see now ("The script on this page appears to have a problem....") is provided by default implementation of QWebPage::shouldInterruptJavaScript
-
wrote on 12 Jan 2017, 15:51 last edited by
Konstantin,
Thanks for the info, specially to which implementation this specific message belongs.
Need to re-implement them all, I guess.Cheers, McL
-
wrote on 12 Jan 2017, 16:20 last edited by McLion 1 Dec 2017, 16:25
Follow up:
- Any idea how I can simulate this case?
I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS. - Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
- Any idea how I can simulate this case?
-
Follow up:
- Any idea how I can simulate this case?
I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS. - Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
wrote on 12 Jan 2017, 16:34 last edited by@McLion said in Catching JavaScript error messages.:
- Any idea how I can simulate this case?
I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.
You don't need any server as QtWebKit can load files from file system or qrc resources. To reproduce just put infinite cycle into some event hanler, e.g. into onclick handler of button
- Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished
- Any idea how I can simulate this case?
-
@McLion said in Catching JavaScript error messages.:
- Any idea how I can simulate this case?
I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.
You don't need any server as QtWebKit can load files from file system or qrc resources. To reproduce just put infinite cycle into some event hanler, e.g. into onclick handler of button
- Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished
wrote on 12 Jan 2017, 16:43 last edited by@Konstantin-Tokarev said in Catching JavaScript error messages.:
load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished
OK ... on second thought that's actually clear.
This means I'll have to take care and initiate a reload for instance.Thanks, McL
- Any idea how I can simulate this case?
-
@Konstantin-Tokarev said in Catching JavaScript error messages.:
load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished
OK ... on second thought that's actually clear.
This means I'll have to take care and initiate a reload for instance.Thanks, McL
wrote on 12 Jan 2017, 16:52 last edited by@McLion said in Catching JavaScript error messages.:
This means I'll have to take care and initiate a reload for instance.
No need to reload page, you can just stop running script
-
@McLion said in Catching JavaScript error messages.:
This means I'll have to take care and initiate a reload for instance.
No need to reload page, you can just stop running script
wrote on 13 Jan 2017, 07:56 last edited by@Konstantin-Tokarev
For normal web browsing that would be sufficient, yes.
In my case we use a web-driven GUI. If I stop the script that needed too long (due to some network error or whatever) the GUI is missing on the device.
1/8