Source/WebCore/ChangeLog

 12012-03-21 Rafael Weinstein <rafaelw@chromium.org>
 2
 3 [MutationObservers] attributeFilter should be case sensitive at all times
 4 https://bugs.webkit.org/show_bug.cgi?id=81822
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 This removes the behavior in MutationObserverRegistration which treats
 9 attributeFilter as case insensitive for HTML elements in HTML documents.
 10
 11 Relevant tests have been updated.
 12
 13 * dom/MutationObserverRegistration.cpp:
 14 (WebCore::MutationObserverRegistration::resetObservation):
 15 (WebCore::MutationObserverRegistration::shouldReceiveMutationFrom):
 16 * dom/MutationObserverRegistration.h:
 17 (MutationObserverRegistration):
 18
1192012-03-21 Zeno Albisser <zeno@webkit.org>
220
321 [Qt][Mac] ranlib segfaults when creating symbol tables for libWebCore.a.

Source/WebCore/dom/MutationObserverRegistration.cpp

@@void MutationObserverRegistration::resetObservation(MutationObserverOptions opti
6363 clearTransientRegistrations();
6464 m_options = options;
6565 m_attributeFilter = attributeFilter;
66  m_caseInsensitiveAttributeFilter.clear();
6766}
6867
6968void MutationObserverRegistration::observedSubtreeNodeWillDetach(PassRefPtr<Node> node)

@@bool MutationObserverRegistration::shouldReceiveMutationFrom(Node* node, WebKitM
115114 if (type != WebKitMutationObserver::Attributes || !(m_options & WebKitMutationObserver::AttributeFilter))
116115 return true;
117116
118  if (m_attributeFilter.contains(attributeName))
119  return true;
120 
121  if (node->document()->isHTMLDocument() && node->isHTMLElement())
122  return caseInsensitiveAttributeFilter().contains(attributeName);
123 
124  return false;
125 }
126 
127 const HashSet<AtomicString>& MutationObserverRegistration::caseInsensitiveAttributeFilter()
128 {
129  if (m_caseInsensitiveAttributeFilter)
130  return *m_caseInsensitiveAttributeFilter;
131 
132  m_caseInsensitiveAttributeFilter = adoptPtr(new HashSet<AtomicString>());
133  for (HashSet<AtomicString>::const_iterator iter = m_attributeFilter.begin(); iter != m_attributeFilter.end(); ++iter) {
134  AtomicString attributeNameLower = iter->lower();
135  if ((*iter) != attributeNameLower)
136  m_caseInsensitiveAttributeFilter->add(attributeNameLower);
137  }
138 
139  return *m_caseInsensitiveAttributeFilter;
 117 return (m_attributeFilter.contains(attributeName));
140118}
141119
142120} // namespace WebCore

Source/WebCore/dom/MutationObserverRegistration.h

@@private:
7272
7373 MutationObserverOptions m_options;
7474 HashSet<AtomicString> m_attributeFilter;
75  OwnPtr<HashSet<AtomicString> > m_caseInsensitiveAttributeFilter;
7675};
7776
7877} // namespace WebCore

LayoutTests/ChangeLog

 12012-03-21 Rafael Weinstein <rafaelw@chromium.org>
 2
 3 [MutationObservers] attributeFilter should be case sensitive at all times
 4 https://bugs.webkit.org/show_bug.cgi?id=81822
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * fast/mutation/observe-attributes-expected.txt:
 9 * fast/mutation/observe-attributes.html:
 10
1112012-03-21 Mark Hahnenberg <mhahnenberg@apple.com>
212
313 Checking in updated test expectations

LayoutTests/fast/mutation/observe-attributes-expected.txt

@@PASS mutations[2].type is "attributes"
101101PASS mutations[2].attributeName is "id"
102102PASS mutations[2].oldValue is "bar"
103103
104 Testing that attributeFilter works as expected and ignores case with HTML elements.
105 ...only foo, bar & boom should be received.
106 PASS mutations.length is 3
 104Testing that attributeFilter works as expected and observes case with HTML elements.
 105...only foo and bar should be received.
 106PASS mutations.length is 2
107107PASS mutations[0].type is "attributes"
108108PASS mutations[0].attributeName is "foo"
109109PASS mutations[0].attributeNamespace is null
110110PASS mutations[1].type is "attributes"
111111PASS mutations[1].attributeName is "bar"
112112PASS mutations[1].attributeNamespace is null
113 PASS mutations[2].type is "attributes"
114 PASS mutations[2].attributeName is "boom"
115 PASS mutations[2].attributeNamespace is null
116113
117114Testing the behavior of attributeFilter when the same observer observes at multiple nodes in a subtree with different filter options.
118115...only foo, bar & bat should be received.

LayoutTests/fast/mutation/observe-attributes.html

@@function testAttributeFilter() {
451451 var observer;
452452
453453 function start() {
454  debug('Testing that attributeFilter works as expected and ignores case with HTML elements.');
 454 debug('Testing that attributeFilter works as expected and observes case with HTML elements.');
455455
456456 mutations = null;
457457 observer = new WebKitMutationObserver(function(m) {

@@function testAttributeFilter() {
469469 }
470470
471471 function finish() {
472  debug('...only foo, bar & boom should be received.');
 472 debug('...only foo and bar should be received.');
473473
474  shouldBe('mutations.length', '3');
 474 shouldBe('mutations.length', '2');
475475 shouldBe('mutations[0].type', '"attributes"');
476476 shouldBe('mutations[0].attributeName', '"foo"');
477477 shouldBe('mutations[0].attributeNamespace', 'null');
478478 shouldBe('mutations[1].type', '"attributes"');
479479 shouldBe('mutations[1].attributeName', '"bar"');
480480 shouldBe('mutations[1].attributeNamespace', 'null');
481  shouldBe('mutations[2].type', '"attributes"');
482  shouldBe('mutations[2].attributeName', '"boom"');
483  shouldBe('mutations[2].attributeNamespace', 'null');
484481 observer.disconnect();
485482 debug('');
486483 runNextTest();