Bug 145900 - -[WKWebView evaluateJavaScript] provides a misleading error when the return cannot be serialized
Summary: -[WKWebView evaluateJavaScript] provides a misleading error when the return c...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alexey Proskuryakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-11 16:19 PDT by Alexey Proskuryakov
Modified: 2015-06-15 09:58 PDT (History)
4 users (show)

See Also:


Attachments
proposed fix (15.54 KB, patch)
2015-06-11 16:23 PDT, Alexey Proskuryakov
sam: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexey Proskuryakov 2015-06-11 16:19:37 PDT
-[WKWebView evaluateJavaScript] can't return nodes, because they cannot be sent to UI process. But we currently claim that there was a JavaScript exception, which is super misleading.
Comment 1 Alexey Proskuryakov 2015-06-11 16:23:33 PDT
Created attachment 254765 [details]
proposed fix
Comment 2 WebKit Commit Bot 2015-06-11 16:25:53 PDT
Attachment 254765 [details] did not pass style-queue:


ERROR: Source/WebKit2/UIProcess/WebPageProxy.cpp:2574:  Extra space before ( in function call  [whitespace/parens] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewEvaluateJavaScript.mm:70:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKWebViewEvaluateJavaScript.mm:81:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
ERROR: Source/WebKit2/UIProcess/WebPageProxy.h:762:  Extra space before ( in function call  [whitespace/parens] [4]
Total errors found: 4 in 13 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 mitz 2015-06-11 17:27:51 PDT
The new API needs an availability macro.
Comment 4 Alexey Proskuryakov 2015-06-11 17:33:10 PDT
> The new API needs an availability macro.

Why?
Comment 5 Anders Carlsson 2015-06-12 10:37:14 PDT
(In reply to comment #4)
> > The new API needs an availability macro.
> 
> Why?

So people who deploy against older versions of OS X and iOS get the right compiler warnings/errors.
Comment 6 Anders Carlsson 2015-06-12 10:37:29 PDT
This also needs to go through internal API review.
Comment 7 Alexey Proskuryakov 2015-06-12 10:45:40 PDT
> So people who deploy against older versions of OS X and iOS get the right compiler warnings/errors.

Can you please be more specific? I know what an availability macro is, but don't know what situation you have in mind.

Perhaps a code snippet where a warning would be helpful.
Comment 8 Anders Carlsson 2015-06-12 10:50:43 PDT
(In reply to comment #7)
> > So people who deploy against older versions of OS X and iOS get the right compiler warnings/errors.
> 
> Can you please be more specific? I know what an availability macro is, but
> don't know what situation you have in mind.
> 
> Perhaps a code snippet where a warning would be helpful.

Imagine someone writing an iOS app using the latest SDK but deploying back to 10.10 and iOS 8. In that case, this API is not available so attempting to use it should be an error.

I'm sure Dan could be more specific if I we asked him nicely :)
Comment 9 Alexey Proskuryakov 2015-06-12 11:18:33 PDT
I don't think that there is any helpful way to express a change like this via availability macros. For someone who already looks at the error values, no longer reporting the condition as WKErrorJavaScriptExceptionOccurred would be quite harmful too.

In person, Anders told me that he would prefer to have an availability macro just for consistency, which is OK with me, but I don't think that there is a true need for it here.
Comment 10 mitz 2015-06-12 11:55:06 PDT
Anders is right, the compiler is not going to emit a warning or generate different code, but the availability information is still useful to developers ("why am I not getting this error when doing this thing on this platform, but I do get it on that platform?") and to WebKit contributors. It is also the convention across all Cocoa API.
Comment 11 Alexey Proskuryakov 2015-06-15 09:58:25 PDT
Committed r185554 with Gtk build fixes and with the still questionable availability macro.