1 Test WebKitMutationObserver.observe on attributes
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 Testing basic aspects of attribute observation.
7 ...can attribute changes be observed at all
8 PASS mutations.length is 2
9 PASS mutations[0].type is "attributes"
10 PASS mutations[0].attributeName is "foo"
11 PASS mutations[0].attributeNamespace is null
12 PASS mutations[1].type is "attributes"
13 PASS mutations[1].attributeName is "bar"
14 PASS mutations[1].attributeNamespace is null
15 ...observer.disconnect() should prevent further delivery of mutations.
16 PASS mutations is null
17 ...re-observing after disconnect works with the same observer.
18 PASS mutations.length is 2
19 PASS mutations[0].type is "attributes"
20 PASS mutations[0].attributeName is "foo"
21 PASS mutations[0].attributeNamespace is null
22 PASS mutations[1].type is "attributes"
23 PASS mutations[1].attributeName is "bar"
24 PASS mutations[1].attributeNamespace is null
26 Testing that observing without specifying "attributes" does not result in hearing about attribute changes.
27 PASS mutations is null
29 Testing that re-observing the same node with the same observer has the effect of resetting the options.
31 PASS mutations.length is 1
32 PASS mutations[0].type is "attributes"
33 PASS mutations[0].attributeName is "foo"
34 PASS mutations is null
36 Testing that multiple observers can be registered to a given node and both receive mutations.
37 PASS mutations.length is 1
38 PASS mutations[0].type is "attributes"
39 PASS mutations[0].attributeName is "foo"
40 PASS mutations2.length is 1
41 PASS mutations2[0].type is "attributes"
42 PASS mutations2[0].attributeName is "foo"
44 Testing that "attributeNamespace" value is delivered properly.
45 PASS mutations.length is 1
46 PASS mutations[0].type is "attributes"
47 PASS mutations[0].attributeName is "foo"
48 PASS mutations[0].attributeNamespace is "http://www.foo.com/bar"
50 Testing that modifications to node properties which delegate to attribute storage deliver mutations.
51 PASS mutations.length is 2
52 PASS mutations[0].type is "attributes"
53 PASS mutations[0].attributeName is "src"
54 PASS mutations[1].type is "attributes"
55 PASS mutations[1].attributeName is "href"
57 Testing mutation records are enqueued for attributes before DOMSubtreeModified is dispatched.
58 PASS mutations.length is 2
59 PASS mutations[0].type is "attributes"
60 PASS mutations[0].attributeName is "foo"
61 PASS mutations[1].type is "attributes"
62 PASS mutations[1].attributeName is "baz"
64 Testing basic oldValue delivery.
65 PASS mutations.length is 3
66 PASS mutations[0].type is "attributes"
67 PASS mutations[0].attributeName is "foo"
68 PASS mutations[0].oldValue is null
69 PASS mutations[1].type is "attributes"
70 PASS mutations[1].attributeName is "foo"
71 PASS mutations[1].oldValue is "bar"
72 PASS mutations[2].type is "attributes"
73 PASS mutations[2].attributeName is "bar"
74 PASS mutations[2].oldValue is "boo"
76 Testing that oldValue is delivered as requested (or not).
77 PASS mutationsWithOldValue.length is 1
78 PASS mutationsWithOldValue[0].type is "attributes"
79 PASS mutationsWithOldValue[0].attributeName is "foo"
80 PASS mutationsWithOldValue[0].oldValue is "bar"
81 PASS mutations.length is 1
82 PASS mutations[0].type is "attributes"
83 PASS mutations[0].attributeName is "foo"
84 PASS mutations[0].oldValue is null
86 An observer with multiple observations will get attributeOldValue if any entries request it.
87 PASS mutations.length is 1
88 PASS mutations[0].type is "attributes"
89 PASS mutations[0].attributeName is "foo"
90 PASS mutations[0].oldValue is "bar"
92 Testing setting an attribute via reflected IDL attribute.
93 PASS mutations.length is 3
94 PASS mutations[0].type is "attributes"
95 PASS mutations[0].attributeName is "id"
96 PASS mutations[0].oldValue is null
97 PASS mutations[1].type is "attributes"
98 PASS mutations[1].attributeName is "id"
99 PASS mutations[1].oldValue is "foo"
100 PASS mutations[2].type is "attributes"
101 PASS mutations[2].attributeName is "id"
102 PASS mutations[2].oldValue is "bar"
104 Testing that attributeFilter works as expected and observes case with HTML elements.
105 ...only foo and bar should be received.
106 PASS mutations.length is 2
107 PASS mutations[0].type is "attributes"
108 PASS mutations[0].attributeName is "foo"
109 PASS mutations[0].attributeNamespace is null
110 PASS mutations[1].type is "attributes"
111 PASS mutations[1].attributeName is "bar"
112 PASS mutations[1].attributeNamespace is null
114 Testing the behavior of attributeFilter when the same observer observes at multiple nodes in a subtree with different filter options.
115 ...only foo, bar & bat should be received.
116 PASS mutations.length is 3
117 PASS mutations[0].type is "attributes"
118 PASS mutations[0].attributeName is "foo"
119 PASS mutations[0].attributeNamespace is null
120 PASS mutations[1].type is "attributes"
121 PASS mutations[1].attributeName is "bar"
122 PASS mutations[1].attributeNamespace is null
123 PASS mutations[2].type is "attributes"
124 PASS mutations[2].attributeName is "bat"
125 PASS mutations[2].attributeNamespace is null
126 ...bar, bat & baz should all be received.
127 PASS mutations.length is 3
128 PASS mutations[0].type is "attributes"
129 PASS mutations[0].attributeName is "bar"
130 PASS mutations[0].attributeNamespace is null
131 PASS mutations[1].type is "attributes"
132 PASS mutations[1].attributeName is "bat"
133 PASS mutations[1].attributeNamespace is null
134 PASS mutations[2].type is "attributes"
135 PASS mutations[2].attributeName is "baz"
136 PASS mutations[2].attributeNamespace is null
138 Testing that setting an attributeFilter filters out namespaced attributes.
139 ...pathLength should not be received.
140 PASS mutations is null
142 Testing that attributeFilter respects case with non-HTML elements.
143 ...only ID, id, booM should be received.
144 PASS mutations.length is 3
145 PASS mutations[0].type is "attributes"
146 PASS mutations[0].attributeName is "ID"
147 PASS mutations[0].attributeNamespace is null
148 PASS mutations[1].type is "attributes"
149 PASS mutations[1].attributeName is "id"
150 PASS mutations[1].attributeNamespace is null
151 PASS mutations[2].type is "attributes"
152 PASS mutations[2].attributeName is "booM"
153 PASS mutations[2].attributeNamespace is null
155 Testing that modifying an elements style property dispatches Mutation Records.
156 PASS mutations.length is 3
157 PASS mutations[0].type is "attributes"
158 PASS mutations[0].attributeName is "style"
159 PASS mutations[0].oldValue is null
160 PASS mutations[1].type is "attributes"
161 PASS mutations[1].attributeName is "style"
162 PASS mutations[1].oldValue is null
163 PASS mutations[2].type is "attributes"
164 PASS mutations[2].attributeName is "style"
165 PASS mutations[2].oldValue is null
166 ...mutation record created.
167 PASS mutations is null
169 Testing that modifying an elements style property dispatches Mutation Records with correct oldValues.
170 PASS mutations.length is 3
171 PASS mutations[0].type is "attributes"
172 PASS mutations[0].attributeName is "style"
173 PASS mutations[0].oldValue is "color: yellow; width: 100px;"
174 PASS mutations[1].type is "attributes"
175 PASS mutations[1].attributeName is "style"
176 PASS mutations[1].oldValue is "color: red; width: 100px;"
177 PASS mutations[2].type is "attributes"
178 PASS mutations[2].attributeName is "style"
179 PASS mutations[2].oldValue is "color: red; width: 200px;"
180 ...mutation record created.
181 PASS mutations is null
183 Testing that a no-op style property mutation does not create Mutation Records.
184 PASS mutations is null
186 Test that mutating an attribute through an attr node delivers mutation records
187 PASS mutations.length is 1
188 PASS mutations[0].target is div
189 PASS mutations[0].type is "attributes"
190 PASS mutations[0].attributeName is "data-test"
191 PASS mutations[0].oldValue is "foo"
193 Test that mutating via setAttributeNode delivers mutation records
194 PASS mutations.length is 3
195 PASS mutations[0].target is div
196 PASS mutations[0].type is "attributes"
197 PASS mutations[0].attributeName is "data-test"
198 PASS mutations[0].oldValue is "foo"
199 PASS mutations[1].target is div
200 PASS mutations[1].type is "attributes"
201 PASS mutations[1].attributeName is "data-other"
202 PASS mutations[1].oldValue is null
203 PASS mutations[2].target is div
204 PASS mutations[2].type is "attributes"
205 PASS mutations[2].attributeName is "id"
206 PASS mutations[2].oldValue is "myId"
208 Test that setAttribute on an attribute with an existing Attr delivers mutation records
209 PASS mutations.length is 1
210 PASS mutations[0].target is div
211 PASS mutations[0].type is "attributes"
212 PASS mutations[0].attributeName is "data-test"
213 PASS mutations[0].oldValue is "foo"
215 Test that setNamedItem and removeNamedItem deliver mutation records
216 PASS mutations.length is 2
217 PASS mutations[0].target is div
218 PASS mutations[0].type is "attributes"
219 PASS mutations[0].attributeName is "data-test"
220 PASS mutations[0].oldValue is "foo"
221 PASS mutations[1].target is div
222 PASS mutations[1].type is "attributes"
223 PASS mutations[1].attributeName is "data-test"
224 PASS mutations[1].oldValue is "bar"
226 PASS successfullyParsed is true