<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - iOS WKWebView window.onerror Callback Doesn't Get a Useful msg"
href="https://bugs.webkit.org/show_bug.cgi?id=147753">147753</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>iOS WKWebView window.onerror Callback Doesn't Get a Useful msg
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>528+ (Nightly build)
</td>
</tr>
<tr>
<th>Hardware</th>
<td>iOS
</td>
</tr>
<tr>
<th>OS</th>
<td>iOS 8.2
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>WebCore JavaScript
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kroach@crittercism.com
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=258414" name="attach_258414" title="JavaScript alert inside WKWebView displaying window.onerror args">attachment 258414</a> <a href="attachment.cgi?id=258414&action=edit" title="JavaScript alert inside WKWebView displaying window.onerror args">[details]</a></span>
JavaScript alert inside WKWebView displaying window.onerror args
Unhandled JavaScript exceptions occurring in JavaScript code
inside a iOS WKWebView doesn't generate useful information to window.onerror
beyond msg = "Script error". It's a pity because older UIWebView does
get better information.
Unhandled JavaScript exceptions call user's window.onerror function
if there is a function installed. For example, include
function errorHandler(msg, url, line, col, errorObj) {
try {
alert(("msg: " + msg)
+ ("\nurl: " + url)
+ ("\nline: " + line)
+ ("\ncol: " + col)
+ ("\nerrorObj: " + errorObj));
} catch (e) {
}
return true;
}
window.onerror = errorHandler;
along with other JavaScript code inside a <script> tag in an HTML
file.
In case of iOS UIWebView, we at least get a msg string
with some variety indicative of the type of unhanded JavaScript
exception which occurred. Examples:
"INVALID_NODE_TYPE_ERR: DOM Range Exception 2: The container ..."
"HierarchyRequestError: DOM Exception 3: A Node was inserted ..."
"ReferenceError: Can't find variable: garbage"
in addition to some line and col which generally are both non-zero
integers.
However, in case of iOS WKWebView, we find we are ALWAYS
getting only the following values passed to our errorHandler:
msg: Script error.
url: [blank]
line: 0
col: 0
errorObj: undefined
This is still the case as of iOS 9 beta 4 . We'd prefer to get
at least as much information unhandled JavaScript exceptions
when using WKWebView as we do get when using UIWebView .
One of my coworkers spoke to an Apple representative at the
most recent WWDC about this matter. We're informed that the
Apple representative thought it was a bug which should be reported.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>