WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch for landing
bug-71596-20111108121337.patch (text/plain), 9.43 KB, created by
Adam Klein
on 2011-11-08 12:13:38 PST
(
hide
)
Description:
Patch for landing
Filename:
MIME Type:
Creator:
Adam Klein
Created:
2011-11-08 12:13:38 PST
Size:
9.43 KB
patch
obsolete
>Subversion Revision: 99594 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index c7081183b5aa63ad1cde4d971479c28655a743c1..434b71454d92b00f07f5c979be81b02038b2741a 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,25 @@ >+2011-11-07 Adam Klein <adamk@chromium.org> >+ >+ WebKitMutationObserver.observe should raise a DOMException if passed invalid arguments >+ https://bugs.webkit.org/show_bug.cgi?id=71596 >+ >+ Reviewed by Ryosuke Niwa. >+ >+ Adds two cases where WebKitMutationObserver.observe throws an exception: >+ - When passed a null Node*. >+ - When passed options that don't make sense, e.g., >+ 'attributeOldValue' but not 'attributes'. >+ >+ * bindings/js/JSWebKitMutationObserverCustom.cpp: >+ (WebCore::JSWebKitMutationObserver::observe): >+ * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp: >+ (WebCore::V8WebKitMutationObserver::observeCallback): >+ * dom/WebKitMutationObserver.cpp: >+ (WebCore::WebKitMutationObserver::validateOptions): >+ (WebCore::WebKitMutationObserver::observe): >+ * dom/WebKitMutationObserver.h: >+ * dom/WebKitMutationObserver.idl: >+ > 2011-11-07 Ryosuke Niwa <rniwa@webkit.org> > > Indent command can insert block quote in non editable content >diff --git a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp >index cd613ff160e577723f35cf22e51b1d618b50c321..018ee424e912b035f6b35cc46b1acdde10f5075d 100644 >--- a/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp >+++ b/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp >@@ -93,7 +93,10 @@ JSValue JSWebKitMutationObserver::observe(ExecState* exec) > if (exec->hadException()) > return jsUndefined(); > >- impl()->observe(target, options); >+ ExceptionCode ec = 0; >+ impl()->observe(target, options, ec); >+ if (ec) >+ setDOMException(exec, ec); > return jsUndefined(); > } > >diff --git a/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp b/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp >index ef53eaf27ef1053ce70eade9d4c773cb43c34874..966dcf8838a7410a793a13f65f0ba3602390fd88 100644 >--- a/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp >+++ b/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp >@@ -103,7 +103,10 @@ v8::Handle<v8::Value> V8WebKitMutationObserver::observeCallback(const v8::Argume > if (optionsObject.get("characterDataOldValue", option) && option) > options |= WebKitMutationObserver::CharacterDataOldValue; > >- imp->observe(target, options); >+ ExceptionCode ec = 0; >+ imp->observe(target, options, ec); >+ if (ec) >+ V8Proxy::setDOMException(ec); > return v8::Handle<v8::Value>(); > } > >diff --git a/Source/WebCore/dom/WebKitMutationObserver.cpp b/Source/WebCore/dom/WebKitMutationObserver.cpp >index a01d245c25905b19bc3f6aa37f8ed70c4057d8f5..7ca7612dcaf69924aacb9caad257396948ed381a 100644 >--- a/Source/WebCore/dom/WebKitMutationObserver.cpp >+++ b/Source/WebCore/dom/WebKitMutationObserver.cpp >@@ -35,6 +35,7 @@ > #include "WebKitMutationObserver.h" > > #include "Document.h" >+#include "ExceptionCode.h" > #include "MutationCallback.h" > #include "MutationObserverRegistration.h" > #include "MutationRecord.h" >@@ -58,8 +59,28 @@ WebKitMutationObserver::~WebKitMutationObserver() > ASSERT(m_registrations.isEmpty()); > } > >-void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options) >+bool WebKitMutationObserver::validateOptions(MutationObserverOptions options) > { >+ return (options & (Attributes | CharacterData | ChildList)) >+ && ((options & Attributes) || !(options & AttributeOldValue)) >+ // FIXME: Uncomment the line below once attributeFilter is supported. >+ // && ((options & Attributes) || !(options & AttributeFilter)) >+ && ((options & CharacterData) || !(options & CharacterDataOldValue)); >+} >+ >+void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options, ExceptionCode& ec) >+{ >+ if (!node) { >+ ec = NOT_FOUND_ERR; >+ return; >+ } >+ >+ if (!validateOptions(options)) { >+ // FIXME: Revisit this once the spec specifies the exception type; SYNTAX_ERR may not be appropriate. >+ ec = SYNTAX_ERR; >+ return; >+ } >+ > MutationObserverRegistration* registration = node->registerMutationObserver(this); > registration->resetObservation(options); > >diff --git a/Source/WebCore/dom/WebKitMutationObserver.h b/Source/WebCore/dom/WebKitMutationObserver.h >index 49899547518bbcddb0ca7fab8eb48004932e7c78..5c4e220fbccf5ad082f7eac570f09a3a3bc5e532 100644 >--- a/Source/WebCore/dom/WebKitMutationObserver.h >+++ b/Source/WebCore/dom/WebKitMutationObserver.h >@@ -33,6 +33,7 @@ > > #if ENABLE(MUTATION_OBSERVERS) > >+#include "ExceptionCode.h" > #include <wtf/HashSet.h> > #include <wtf/PassRefPtr.h> > #include <wtf/RefCounted.h> >@@ -75,7 +76,7 @@ public: > > ~WebKitMutationObserver(); > >- void observe(Node*, MutationObserverOptions); >+ void observe(Node*, MutationObserverOptions, ExceptionCode&); > void disconnect(); > void observationStarted(MutationObserverRegistration*); > void observationEnded(MutationObserverRegistration*); >@@ -85,6 +86,8 @@ private: > WebKitMutationObserver(PassRefPtr<MutationCallback>); > void deliver(); > >+ static bool validateOptions(MutationObserverOptions); >+ > RefPtr<MutationCallback> m_callback; > Vector<RefPtr<MutationRecord> > m_records; > HashSet<MutationObserverRegistration*> m_registrations; >diff --git a/Source/WebCore/dom/WebKitMutationObserver.idl b/Source/WebCore/dom/WebKitMutationObserver.idl >index da6e8c7eec00a0b001519f1c33456285873656a7..b54575f5a695caa9f706a7b310030756e3e902fa 100644 >--- a/Source/WebCore/dom/WebKitMutationObserver.idl >+++ b/Source/WebCore/dom/WebKitMutationObserver.idl >@@ -34,7 +34,8 @@ module core { > CanBeConstructed, > CustomConstructor > ] WebKitMutationObserver { >- [Custom] void observe(in Node target, in MutationObserverOptions options); >+ [Custom] void observe(in Node target, in MutationObserverOptions options) >+ raises(DOMException); > void disconnect(); > }; > } >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 5a7fda45ae841e6dde6259ff3d717190fe9706c2..39cdf19f2cf5a46023716ad8d319b25ce135ceca 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2011-11-07 Adam Klein <adamk@chromium.org> >+ >+ WebKitMutationObserver.observe should raise a DOMException if passed invalid arguments >+ https://bugs.webkit.org/show_bug.cgi?id=71596 >+ >+ Reviewed by Ryosuke Niwa. >+ >+ * fast/mutation/observe-exceptions-expected.txt: >+ * fast/mutation/observe-exceptions.html: >+ > 2011-11-07 Ryosuke Niwa <rniwa@webkit.org> > > Indent command can insert block quote in non editable content >diff --git a/LayoutTests/fast/mutation/observe-exceptions-expected.txt b/LayoutTests/fast/mutation/observe-exceptions-expected.txt >index 3f4e3cd1ed7367c12cbd5760525764fad8e8eb74..5390120da891051f516e1983944d690b8bbfab72 100644 >--- a/LayoutTests/fast/mutation/observe-exceptions-expected.txt >+++ b/LayoutTests/fast/mutation/observe-exceptions-expected.txt >@@ -9,6 +9,11 @@ PASS observer.observe(undefined) threw exception TypeError: Not enough arguments > PASS observer.observe(document.body) threw exception TypeError: Not enough arguments. > PASS observer.observe(document.body, null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. > PASS observer.observe(document.body, undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. >+PASS observer.observe(null, {attributes: true}) threw exception Error: NOT_FOUND_ERR: DOM Exception 8. >+PASS observer.observe(undefined, {attributes: true}) threw exception Error: NOT_FOUND_ERR: DOM Exception 8. >+PASS observer.observe(document.body, {subtree: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. >+PASS observer.observe(document.body, {childList: true, attributeOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. >+PASS observer.observe(document.body, {attributes: true, characterDataOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. > PASS successfullyParsed is true > > TEST COMPLETE >diff --git a/LayoutTests/fast/mutation/observe-exceptions.html b/LayoutTests/fast/mutation/observe-exceptions.html >index a3491d2e8e126bdce483b5ae23b526c5ab85861d..a525a492ce9253d44c07ecf66fcefdda67aa57a0 100644 >--- a/LayoutTests/fast/mutation/observe-exceptions.html >+++ b/LayoutTests/fast/mutation/observe-exceptions.html >@@ -18,6 +18,13 @@ function runTest() { > shouldThrow('observer.observe(document.body)'); > shouldThrow('observer.observe(document.body, null)'); > shouldThrow('observer.observe(document.body, undefined)'); >+ shouldThrow('observer.observe(null, {attributes: true})'); >+ shouldThrow('observer.observe(undefined, {attributes: true})'); >+ shouldThrow('observer.observe(document.body, {subtree: true})'); >+ shouldThrow('observer.observe(document.body, {childList: true, attributeOldValue: true})'); >+ shouldThrow('observer.observe(document.body, {attributes: true, characterDataOldValue: true})'); >+ // FIXME: Uncomment the below when attributeFilter is supported. >+ //shouldThrow('observer.observe(document.body, {characterData: true, attributeFilter: ["id"]})'); > } > > description('Test that WebKitMutationObserver.observe throws exceptions appropriately');
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 71596
:
113923
|
114094
| 114131