Bug 35205

Summary: [Chromium API] Disambiguate allowJavaScript from didFailToExecuteJavaScript
Product: WebKit Reporter: Adam Barth <abarth>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Severity: Normal CC: fishd, pkasting
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Other   
OS: OS X 10.5   
Description Flags
patch v3
patch v4 fishd: review+, fishd: commit-queue+

Description Adam Barth 2010-02-20 22:04:14 PST
[Chromium API] Disambiguous allowJavaScript from didFailToExecuteJavaScript
Comment 1 Adam Barth 2010-02-20 22:06:39 PST
Created attachment 49141 [details]
Comment 2 Peter Kasting 2010-02-20 22:48:10 PST
You might want to comment more (perhaps in comments on the function declarations?) on why a piece of code would care whether it can execute script if it doesn't actually intend to execute script.  There are other possible APIs here whose usefulness probably depends on the answer.

(I'm mostly worried about future code calling allowJavaScript() without calling didFailToExecuteJavaScript() when it should.  Perhaps we should create a single access point you call when you want to run script that checks if it's legal and calls this callback if not, or something.)
Comment 3 Adam Barth 2010-02-20 23:55:00 PST
Comment on attachment 49141 [details]

This patch is wrong because V8 cheatzors.
Comment 4 Adam Barth 2010-02-21 01:03:06 PST
Created attachment 49146 [details]
Comment 5 Adam Barth 2010-02-21 01:04:02 PST
Done and done.  This patch got a bit bigger and probably harder to merge, but I think you're right that we should force clients to be explicit about this bit so we do the right thing in the future.
Comment 6 Peter Kasting 2010-02-22 15:45:18 PST
Comment on attachment 49146 [details]

> +enum ReasonForCallingCanExecuteScripts {
> +    AboutToExecuteScript,
> +    NotAboutToExecuteScript
> +};

I wonder if there could be a better name for the second choice... "NotPlanningToExecuteScript"?  "JustCuriousAboutCurrentSetting"?  I dunno :(.  In any case it seems like rationale for this enum should be given in comments above it.
Comment 7 Darin Fisher (:fishd, Google) 2010-02-23 14:38:48 PST
Comment on attachment 49146 [details]

> +        [Chromium API] Disambiguate allowJavaScript from didFailToExecuteJavaScript

As discussed elsewhere, I'd still much prefer a name for didFailToExecuteJavaScript
that better indicates failure due to a policy decision as opposed to other problems
such as a syntax error.

How about renaming this method to didNotAllowScript?  That nicely corresponds with
Comment 8 Peter Kasting 2010-02-24 14:17:01 PST
Created attachment 49435 [details]
patch v3

Renamed didFailToExecuteJavaScript() to didNotAllowScript().  Updated patch to apply against current tree.
Comment 9 Peter Kasting 2010-02-24 14:34:45 PST
Created attachment 49440 [details]
patch v4

Last patch didn't fix everywhere because I didn't realize the first patch used two different function names (for no good reason)
Comment 10 Peter Kasting 2010-02-24 16:33:15 PST
Landed in r55207.