Changeset 99611 in webkit
- Timestamp:
- Nov 8, 2011, 12:59:47 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r99609 r99611 1 2011-11-08 Adam Klein <adamk@chromium.org> 2 3 WebKitMutationObserver.observe should raise a DOMException if passed invalid arguments 4 https://bugs.webkit.org/show_bug.cgi?id=71596 5 6 Reviewed by Ryosuke Niwa. 7 8 * fast/mutation/observe-exceptions-expected.txt: 9 * fast/mutation/observe-exceptions.html: 10 1 11 2011-11-08 Joshua Bell <jsbell@chromium.org> 2 12 -
trunk/LayoutTests/fast/mutation/observe-exceptions-expected.txt
r97159 r99611 10 10 PASS observer.observe(document.body, null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 11 11 PASS observer.observe(document.body, undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. 12 PASS observer.observe(null, {attributes: true}) threw exception Error: NOT_FOUND_ERR: DOM Exception 8. 13 PASS observer.observe(undefined, {attributes: true}) threw exception Error: NOT_FOUND_ERR: DOM Exception 8. 14 PASS observer.observe(document.body, {subtree: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 15 PASS observer.observe(document.body, {childList: true, attributeOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 16 PASS observer.observe(document.body, {attributes: true, characterDataOldValue: true}) threw exception Error: SYNTAX_ERR: DOM Exception 12. 12 17 PASS successfullyParsed is true 13 18 -
trunk/LayoutTests/fast/mutation/observe-exceptions.html
r98407 r99611 19 19 shouldThrow('observer.observe(document.body, null)'); 20 20 shouldThrow('observer.observe(document.body, undefined)'); 21 shouldThrow('observer.observe(null, {attributes: true})'); 22 shouldThrow('observer.observe(undefined, {attributes: true})'); 23 shouldThrow('observer.observe(document.body, {subtree: true})'); 24 shouldThrow('observer.observe(document.body, {childList: true, attributeOldValue: true})'); 25 shouldThrow('observer.observe(document.body, {attributes: true, characterDataOldValue: true})'); 26 // FIXME: Uncomment the below when attributeFilter is supported. 27 //shouldThrow('observer.observe(document.body, {characterData: true, attributeFilter: ["id"]})'); 21 28 } 22 29 -
trunk/Source/WebCore/ChangeLog
r99609 r99611 1 2011-11-08 Adam Klein <adamk@chromium.org> 2 3 WebKitMutationObserver.observe should raise a DOMException if passed invalid arguments 4 https://bugs.webkit.org/show_bug.cgi?id=71596 5 6 Reviewed by Ryosuke Niwa. 7 8 Adds two cases where WebKitMutationObserver.observe throws an exception: 9 - When passed a null Node*. 10 - When passed options that don't make sense, e.g., 11 'attributeOldValue' but not 'attributes'. 12 13 * bindings/js/JSWebKitMutationObserverCustom.cpp: 14 (WebCore::JSWebKitMutationObserver::observe): 15 * bindings/v8/custom/V8WebKitMutationObserverCustom.cpp: 16 (WebCore::V8WebKitMutationObserver::observeCallback): 17 * dom/WebKitMutationObserver.cpp: 18 (WebCore::WebKitMutationObserver::validateOptions): 19 (WebCore::WebKitMutationObserver::observe): 20 * dom/WebKitMutationObserver.h: 21 * dom/WebKitMutationObserver.idl: 22 1 23 2011-11-08 Joshua Bell <jsbell@chromium.org> 2 24 -
trunk/Source/WebCore/bindings/js/JSWebKitMutationObserverCustom.cpp
r97714 r99611 94 94 return jsUndefined(); 95 95 96 impl()->observe(target, options); 96 ExceptionCode ec = 0; 97 impl()->observe(target, options, ec); 98 if (ec) 99 setDOMException(exec, ec); 97 100 return jsUndefined(); 98 101 } -
trunk/Source/WebCore/bindings/v8/custom/V8WebKitMutationObserverCustom.cpp
r98572 r99611 104 104 options |= WebKitMutationObserver::CharacterDataOldValue; 105 105 106 imp->observe(target, options); 106 ExceptionCode ec = 0; 107 imp->observe(target, options, ec); 108 if (ec) 109 V8Proxy::setDOMException(ec); 107 110 return v8::Handle<v8::Value>(); 108 111 } -
trunk/Source/WebCore/dom/WebKitMutationObserver.cpp
r99593 r99611 36 36 37 37 #include "Document.h" 38 #include "ExceptionCode.h" 38 39 #include "MutationCallback.h" 39 40 #include "MutationObserverRegistration.h" … … 59 60 } 60 61 61 void WebKitMutationObserver::observe(Node* node,MutationObserverOptions options)62 bool WebKitMutationObserver::validateOptions(MutationObserverOptions options) 62 63 { 64 return (options & (Attributes | CharacterData | ChildList)) 65 && ((options & Attributes) || !(options & AttributeOldValue)) 66 // FIXME: Uncomment the line below once attributeFilter is supported. 67 // && ((options & Attributes) || !(options & AttributeFilter)) 68 && ((options & CharacterData) || !(options & CharacterDataOldValue)); 69 } 70 71 void WebKitMutationObserver::observe(Node* node, MutationObserverOptions options, ExceptionCode& ec) 72 { 73 if (!node) { 74 ec = NOT_FOUND_ERR; 75 return; 76 } 77 78 if (!validateOptions(options)) { 79 // FIXME: Revisit this once the spec specifies the exception type; SYNTAX_ERR may not be appropriate. 80 ec = SYNTAX_ERR; 81 return; 82 } 83 63 84 MutationObserverRegistration* registration = node->registerMutationObserver(this); 64 85 registration->resetObservation(options); -
trunk/Source/WebCore/dom/WebKitMutationObserver.h
r99593 r99611 34 34 #if ENABLE(MUTATION_OBSERVERS) 35 35 36 #include "ExceptionCode.h" 36 37 #include <wtf/HashSet.h> 37 38 #include <wtf/PassRefPtr.h> … … 76 77 ~WebKitMutationObserver(); 77 78 78 void observe(Node*, MutationObserverOptions );79 void observe(Node*, MutationObserverOptions, ExceptionCode&); 79 80 void disconnect(); 80 81 void observationStarted(MutationObserverRegistration*); … … 85 86 WebKitMutationObserver(PassRefPtr<MutationCallback>); 86 87 void deliver(); 88 89 static bool validateOptions(MutationObserverOptions); 87 90 88 91 RefPtr<MutationCallback> m_callback; -
trunk/Source/WebCore/dom/WebKitMutationObserver.idl
r97159 r99611 35 35 CustomConstructor 36 36 ] WebKitMutationObserver { 37 [Custom] void observe(in Node target, in MutationObserverOptions options); 37 [Custom] void observe(in Node target, in MutationObserverOptions options) 38 raises(DOMException); 38 39 void disconnect(); 39 40 };
Note:
See TracChangeset
for help on using the changeset viewer.