Bug 71596

Summary: WebKitMutationObserver.observe should raise a DOMException if passed invalid arguments
Product: WebKit Reporter: Adam Klein <adamk>
Component: DOMAssignee: Adam Klein <adamk>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, japhet, ojan, rafaelw, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 68729    
Attachments:
Description Flags
Patch
none
Patch for landing
none
Patch for landing none

Description Adam Klein 2011-11-04 17:04:26 PDT
For example, a null Node currently leads to a crash. We should also validate the options argument.
Comment 1 Adam Klein 2011-11-07 13:54:35 PST
Created attachment 113923 [details]
Patch
Comment 2 Ryosuke Niwa 2011-11-07 21:31:33 PST
Comment on attachment 113923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=113923&action=review

> Source/WebCore/ChangeLog:9
> +        exception:

Could you fit "exception:" on the previous line specially because the bug title is already longer than the previous line?

> Source/WebCore/dom/WebKitMutationObserver.cpp:78
> +        ec = NOT_FOUND_ERR;
> +        return;
> +    }
> +
> +    if (!validateOptions(options)) {
> +        ec = SYNTAX_ERR;

We should really agree which exceptions are thrown for each one of cases we're throwing on public-webapps.

> Source/WebCore/dom/WebKitMutationObserver.h:51
> +typedef int ExceptionCode;
> +

Please include ExceptionCode.h instead. r=me provided this change.
Comment 3 Adam Klein 2011-11-08 09:28:02 PST
Comment on attachment 113923 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=113923&action=review

>> Source/WebCore/dom/WebKitMutationObserver.cpp:78
>> +        ec = SYNTAX_ERR;
> 
> We should really agree which exceptions are thrown for each one of cases we're throwing on public-webapps.

Yeah, I'll ask Anne for his opinion on these (right now the spec says these throw an "Error", which isn't right).  NOT_FOUND_ERR was picked to be consistent with other Node-typed arguments, but SYNTAX_ERR may well be wrong here; added a FIXME.

>> Source/WebCore/dom/WebKitMutationObserver.h:51
>> +
> 
> Please include ExceptionCode.h instead. r=me provided this change.

Done. I'll send you a separate patch to get rid of the rest of these typedefs in WebCore (the typedef is about as common as the include).
Comment 4 Adam Klein 2011-11-08 09:33:50 PST
Created attachment 114094 [details]
Patch for landing
Comment 5 WebKit Review Bot 2011-11-08 10:45:30 PST
Comment on attachment 114094 [details]
Patch for landing

Rejecting attachment 114094 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
n/master/.rev_map.268f45cc-cd09-0410-ab3c-d52691b4dbfc
First, rewinding head to replay your work on top of it...
Fast-forwarded master to refs/remotes/origin/master.
Updating chromium port dependencies using gclient...

________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'

________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
Updating webkit projects from gyp files...

Full output: http://queues.webkit.org/results/10375151
Comment 6 Adam Klein 2011-11-08 12:13:38 PST
Created attachment 114131 [details]
Patch for landing
Comment 7 WebKit Review Bot 2011-11-08 13:00:06 PST
Comment on attachment 114131 [details]
Patch for landing

Clearing flags on attachment: 114131

Committed r99611: <http://trac.webkit.org/changeset/99611>
Comment 8 WebKit Review Bot 2011-11-08 13:00:11 PST
All reviewed patches have been landed.  Closing bug.