OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../js/resources/js-test-pre.js"></script> | 2 <script src="../../js/resources/js-test-pre.js"></script> |
3 <script> | 3 <script> |
4 | 4 |
5 window.jsTestIsAsync = true; | 5 window.jsTestIsAsync = true; |
6 var mutations, mutations2, mutationsWithOldValue; | 6 var mutations, mutations2, mutationsWithOldValue; |
7 var calls; | 7 var calls; |
8 var div; | 8 var div; |
9 | 9 |
10 function testBasic() { | 10 function testBasic() { |
11 var div; | 11 var div; |
12 var observer; | 12 var observer; |
13 | 13 |
14 function start() { | 14 function start() { |
15 debug('Testing basic aspects of attribute observation.'); | 15 debug('Testing basic aspects of attribute observation.'); |
16 | 16 |
17 mutations = null; | 17 mutations = null; |
18 div = document.createElement('div'); | 18 div = document.createElement('div'); |
19 div.setAttribute('bar', 'foo'); | 19 div.setAttribute('bar', 'foo'); |
20 | 20 |
21 observer = new WebKitMutationObserver(function(m) { | 21 observer = new MutationObserver(function(m) { |
22 mutations = m; | 22 mutations = m; |
23 }); | 23 }); |
24 | 24 |
25 observer.observe(div, { attributes: true, characterData: true }); | 25 observer.observe(div, { attributes: true, characterData: true }); |
26 div.setAttribute('foo', 'bar'); | 26 div.setAttribute('foo', 'bar'); |
27 div.removeAttribute('bar'); | 27 div.removeAttribute('bar'); |
28 setTimeout(checkDisconnectAndMutate, 0); | 28 setTimeout(checkDisconnectAndMutate, 0); |
29 } | 29 } |
30 | 30 |
31 function checkDisconnectAndMutate() { | 31 function checkDisconnectAndMutate() { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 function testWrongType() { | 76 function testWrongType() { |
77 var div; | 77 var div; |
78 var observer; | 78 var observer; |
79 | 79 |
80 function start() { | 80 function start() { |
81 debug('Testing that observing without specifying "attributes" does not r
esult in hearing about attribute changes.'); | 81 debug('Testing that observing without specifying "attributes" does not r
esult in hearing about attribute changes.'); |
82 | 82 |
83 mutations = null; | 83 mutations = null; |
84 div = document.createElement('div'); | 84 div = document.createElement('div'); |
85 observer = new WebKitMutationObserver(function(m) { | 85 observer = new MutationObserver(function(m) { |
86 mutations = m; | 86 mutations = m; |
87 }); | 87 }); |
88 | 88 |
89 observer.observe(div, { childList: true, characterData: true }); | 89 observer.observe(div, { childList: true, characterData: true }); |
90 div.setAttribute('foo', 'bar'); | 90 div.setAttribute('foo', 'bar'); |
91 setTimeout(finish, 0); | 91 setTimeout(finish, 0); |
92 } | 92 } |
93 | 93 |
94 function finish() { | 94 function finish() { |
95 shouldBe('mutations', 'null'); | 95 shouldBe('mutations', 'null'); |
96 observer.disconnect(); | 96 observer.disconnect(); |
97 debug(''); | 97 debug(''); |
98 runNextTest(); | 98 runNextTest(); |
99 } | 99 } |
100 | 100 |
101 start(); | 101 start(); |
102 } | 102 } |
103 | 103 |
104 function testMultipleRegistration() { | 104 function testMultipleRegistration() { |
105 var div; | 105 var div; |
106 var observer; | 106 var observer; |
107 | 107 |
108 function start() { | 108 function start() { |
109 debug('Testing that re-observing the same node with the same observer ha
s the effect of resetting the options.'); | 109 debug('Testing that re-observing the same node with the same observer ha
s the effect of resetting the options.'); |
110 | 110 |
111 calls = 0; | 111 calls = 0; |
112 mutations = null; | 112 mutations = null; |
113 div = document.createElement('div'); | 113 div = document.createElement('div'); |
114 observer = new WebKitMutationObserver(function(m) { | 114 observer = new MutationObserver(function(m) { |
115 mutations = m; | 115 mutations = m; |
116 calls++; | 116 calls++; |
117 }); | 117 }); |
118 | 118 |
119 observer.observe(div, { attributes: true, characterData: true }); | 119 observer.observe(div, { attributes: true, characterData: true }); |
120 observer.observe(div, { attributes: true }); | 120 observer.observe(div, { attributes: true }); |
121 div.setAttribute('foo', 'bar'); | 121 div.setAttribute('foo', 'bar'); |
122 setTimeout(checkDisconnectAndMutate, 0); | 122 setTimeout(checkDisconnectAndMutate, 0); |
123 } | 123 } |
124 | 124 |
(...skipping 21 matching lines...) Expand all Loading... |
146 | 146 |
147 function testMultipleObservers() { | 147 function testMultipleObservers() { |
148 var div; | 148 var div; |
149 var observer; | 149 var observer; |
150 var observer2; | 150 var observer2; |
151 | 151 |
152 function start() { | 152 function start() { |
153 debug('Testing that multiple observers can be registered to a given node
and both receive mutations.'); | 153 debug('Testing that multiple observers can be registered to a given node
and both receive mutations.'); |
154 mutations = null; | 154 mutations = null; |
155 div = document.createElement('div'); | 155 div = document.createElement('div'); |
156 observer = new WebKitMutationObserver(function(m) { | 156 observer = new MutationObserver(function(m) { |
157 mutations = m; | 157 mutations = m; |
158 }); | 158 }); |
159 observer2 = new WebKitMutationObserver(function(m) { | 159 observer2 = new MutationObserver(function(m) { |
160 mutations2 = m; | 160 mutations2 = m; |
161 }); | 161 }); |
162 observer.observe(div, { attributes: true }); | 162 observer.observe(div, { attributes: true }); |
163 observer2.observe(div, { attributes: true }); | 163 observer2.observe(div, { attributes: true }); |
164 div.setAttribute('foo', 'bar'); | 164 div.setAttribute('foo', 'bar'); |
165 setTimeout(finish, 0); | 165 setTimeout(finish, 0); |
166 } | 166 } |
167 | 167 |
168 function finish() { | 168 function finish() { |
169 shouldBe('mutations.length', '1'); | 169 shouldBe('mutations.length', '1'); |
(...skipping 12 matching lines...) Expand all Loading... |
182 } | 182 } |
183 | 183 |
184 function testNamespaceURI() { | 184 function testNamespaceURI() { |
185 var div; | 185 var div; |
186 var observer; | 186 var observer; |
187 | 187 |
188 function start() { | 188 function start() { |
189 debug('Testing that "attributeNamespace" value is delivered properly.'); | 189 debug('Testing that "attributeNamespace" value is delivered properly.'); |
190 mutations = null; | 190 mutations = null; |
191 div = document.createElement('div'); | 191 div = document.createElement('div'); |
192 observer = new WebKitMutationObserver(function(m) { | 192 observer = new MutationObserver(function(m) { |
193 mutations = m; | 193 mutations = m; |
194 }); | 194 }); |
195 | 195 |
196 observer.observe(div, { attributes: true, childList: true }); | 196 observer.observe(div, { attributes: true, childList: true }); |
197 div.setAttributeNS('http://www.foo.com/bar', 'foo', 'bar'); | 197 div.setAttributeNS('http://www.foo.com/bar', 'foo', 'bar'); |
198 setTimeout(finish, 0); | 198 setTimeout(finish, 0); |
199 } | 199 } |
200 | 200 |
201 function finish() { | 201 function finish() { |
202 shouldBe('mutations.length', '1'); | 202 shouldBe('mutations.length', '1'); |
(...skipping 11 matching lines...) Expand all Loading... |
214 function testPropertyAccess() { | 214 function testPropertyAccess() { |
215 var img, a; | 215 var img, a; |
216 var observer; | 216 var observer; |
217 | 217 |
218 function start() { | 218 function start() { |
219 debug('Testing that modifications to node properties which delegate to a
ttribute storage deliver mutations.'); | 219 debug('Testing that modifications to node properties which delegate to a
ttribute storage deliver mutations.'); |
220 mutations = null; | 220 mutations = null; |
221 img = document.createElement('img'); | 221 img = document.createElement('img'); |
222 a = document.createElement('a'); | 222 a = document.createElement('a'); |
223 | 223 |
224 observer = new WebKitMutationObserver(function(m) { | 224 observer = new MutationObserver(function(m) { |
225 mutations = m; | 225 mutations = m; |
226 }); | 226 }); |
227 | 227 |
228 observer.observe(img, { attributes: true }); | 228 observer.observe(img, { attributes: true }); |
229 observer.observe(a, { attributes: true }); | 229 observer.observe(a, { attributes: true }); |
230 | 230 |
231 img.src = 'baz.png'; | 231 img.src = 'baz.png'; |
232 a.href = 'foo.html'; | 232 a.href = 'foo.html'; |
233 | 233 |
234 setTimeout(finish, 0); | 234 setTimeout(finish, 0); |
(...skipping 20 matching lines...) Expand all Loading... |
255 | 255 |
256 function start() { | 256 function start() { |
257 debug('Testing mutation records are enqueued for attributes before DOMSu
btreeModified is dispatched.'); | 257 debug('Testing mutation records are enqueued for attributes before DOMSu
btreeModified is dispatched.'); |
258 | 258 |
259 mutations = null; | 259 mutations = null; |
260 div = document.body.appendChild(document.createElement('div')); | 260 div = document.body.appendChild(document.createElement('div')); |
261 div2 = document.body.appendChild(document.createElement('div')); | 261 div2 = document.body.appendChild(document.createElement('div')); |
262 | 262 |
263 subDiv = div.appendChild(document.createElement('div')); | 263 subDiv = div.appendChild(document.createElement('div')); |
264 | 264 |
265 observer = new WebKitMutationObserver(function(m) { | 265 observer = new MutationObserver(function(m) { |
266 mutations = m; | 266 mutations = m; |
267 }); | 267 }); |
268 | 268 |
269 listener = function(e) { | 269 listener = function(e) { |
270 div2.setAttribute('baz', 'bat'); | 270 div2.setAttribute('baz', 'bat'); |
271 } | 271 } |
272 | 272 |
273 div.addEventListener('DOMSubtreeModified', listener); | 273 div.addEventListener('DOMSubtreeModified', listener); |
274 observer.observe(subDiv, { attributes: true }); | 274 observer.observe(subDiv, { attributes: true }); |
275 observer.observe(div2, { attributes: true }); | 275 observer.observe(div2, { attributes: true }); |
(...skipping 22 matching lines...) Expand all Loading... |
298 function testOldValue() { | 298 function testOldValue() { |
299 var div; | 299 var div; |
300 var observer; | 300 var observer; |
301 | 301 |
302 function start() { | 302 function start() { |
303 debug('Testing basic oldValue delivery.'); | 303 debug('Testing basic oldValue delivery.'); |
304 mutations = null; | 304 mutations = null; |
305 div = document.createElement('div'); | 305 div = document.createElement('div'); |
306 div.setAttribute('bar', 'boo'); | 306 div.setAttribute('bar', 'boo'); |
307 | 307 |
308 observer = new WebKitMutationObserver(function(mutations) { | 308 observer = new MutationObserver(function(mutations) { |
309 window.mutations = mutations; | 309 window.mutations = mutations; |
310 }); | 310 }); |
311 observer.observe(div, { attributes: true, attributeOldValue: true }); | 311 observer.observe(div, { attributes: true, attributeOldValue: true }); |
312 div.setAttribute('foo', 'bar'); | 312 div.setAttribute('foo', 'bar'); |
313 div.setAttribute('foo', 'baz'); | 313 div.setAttribute('foo', 'baz'); |
314 div.removeAttribute('bar'); | 314 div.removeAttribute('bar'); |
315 div.removeAttribute('non-existant'); | 315 div.removeAttribute('non-existant'); |
316 setTimeout(finish, 0); | 316 setTimeout(finish, 0); |
317 } | 317 } |
318 | 318 |
(...skipping 20 matching lines...) Expand all Loading... |
339 var div; | 339 var div; |
340 var observerWithOldValue; | 340 var observerWithOldValue; |
341 var observer; | 341 var observer; |
342 | 342 |
343 function start() { | 343 function start() { |
344 debug('Testing that oldValue is delivered as requested (or not).'); | 344 debug('Testing that oldValue is delivered as requested (or not).'); |
345 mutationsWithOldValue = null; | 345 mutationsWithOldValue = null; |
346 mutations = null; | 346 mutations = null; |
347 div = document.createElement('div'); | 347 div = document.createElement('div'); |
348 div.setAttribute('foo', 'bar'); | 348 div.setAttribute('foo', 'bar'); |
349 observerWithOldValue = new WebKitMutationObserver(function(mutations) { | 349 observerWithOldValue = new MutationObserver(function(mutations) { |
350 window.mutationsWithOldValue = mutations; | 350 window.mutationsWithOldValue = mutations; |
351 }); | 351 }); |
352 observer = new WebKitMutationObserver(function(mutations) { | 352 observer = new MutationObserver(function(mutations) { |
353 window.mutations = mutations; | 353 window.mutations = mutations; |
354 }); | 354 }); |
355 observerWithOldValue.observe(div, { attributes: true, attributeOldValue:
true }); | 355 observerWithOldValue.observe(div, { attributes: true, attributeOldValue:
true }); |
356 observer.observe(div, { attributes: true }); | 356 observer.observe(div, { attributes: true }); |
357 div.setAttribute('foo', 'baz'); | 357 div.setAttribute('foo', 'baz'); |
358 setTimeout(finish, 0); | 358 setTimeout(finish, 0); |
359 } | 359 } |
360 | 360 |
361 function finish() { | 361 function finish() { |
362 shouldBe('mutationsWithOldValue.length', '1'); | 362 shouldBe('mutationsWithOldValue.length', '1'); |
(...skipping 17 matching lines...) Expand all Loading... |
380 var div; | 380 var div; |
381 var span; | 381 var span; |
382 var observer; | 382 var observer; |
383 | 383 |
384 function start() { | 384 function start() { |
385 debug('An observer with multiple observations will get attributeOldValue
if any entries request it.'); | 385 debug('An observer with multiple observations will get attributeOldValue
if any entries request it.'); |
386 mutations = null; | 386 mutations = null; |
387 div = document.createElement('div'); | 387 div = document.createElement('div'); |
388 span = div.appendChild(document.createElement('span')); | 388 span = div.appendChild(document.createElement('span')); |
389 span.setAttribute('foo', 'bar'); | 389 span.setAttribute('foo', 'bar'); |
390 observer = new WebKitMutationObserver(function(mutations) { | 390 observer = new MutationObserver(function(mutations) { |
391 window.mutations = mutations; | 391 window.mutations = mutations; |
392 }); | 392 }); |
393 observer.observe(div, { attributes: true, attributeOldValue: true, subtr
ee: true }); | 393 observer.observe(div, { attributes: true, attributeOldValue: true, subtr
ee: true }); |
394 observer.observe(span, { attributes: true }); | 394 observer.observe(span, { attributes: true }); |
395 span.setAttribute('foo', 'baz'); | 395 span.setAttribute('foo', 'baz'); |
396 setTimeout(finish, 0); | 396 setTimeout(finish, 0); |
397 } | 397 } |
398 | 398 |
399 function finish() { | 399 function finish() { |
400 shouldBe('mutations.length', '1'); | 400 shouldBe('mutations.length', '1'); |
401 shouldBe('mutations[0].type', '"attributes"'); | 401 shouldBe('mutations[0].type', '"attributes"'); |
402 shouldBe('mutations[0].attributeName', '"foo"'); | 402 shouldBe('mutations[0].attributeName', '"foo"'); |
403 shouldBe('mutations[0].oldValue', '"bar"'); | 403 shouldBe('mutations[0].oldValue', '"bar"'); |
404 observer.disconnect(); | 404 observer.disconnect(); |
405 debug(''); | 405 debug(''); |
406 runNextTest(); | 406 runNextTest(); |
407 } | 407 } |
408 | 408 |
409 start(); | 409 start(); |
410 } | 410 } |
411 | 411 |
412 function testIDLAttribute() { | 412 function testIDLAttribute() { |
413 var div; | 413 var div; |
414 var observer; | 414 var observer; |
415 | 415 |
416 function start() { | 416 function start() { |
417 debug('Testing setting an attribute via reflected IDL attribute.'); | 417 debug('Testing setting an attribute via reflected IDL attribute.'); |
418 mutations = null; | 418 mutations = null; |
419 div = document.createElement('div'); | 419 div = document.createElement('div'); |
420 observer = new WebKitMutationObserver(function(mutations) { | 420 observer = new MutationObserver(function(mutations) { |
421 window.mutations = mutations; | 421 window.mutations = mutations; |
422 }); | 422 }); |
423 observer.observe(div, { attributes: true, attributeOldValue: true }); | 423 observer.observe(div, { attributes: true, attributeOldValue: true }); |
424 div.id = 'foo'; | 424 div.id = 'foo'; |
425 div.id = 'bar'; | 425 div.id = 'bar'; |
426 div.id = null; | 426 div.id = null; |
427 setTimeout(finish, 0); | 427 setTimeout(finish, 0); |
428 } | 428 } |
429 | 429 |
430 function finish() { | 430 function finish() { |
(...skipping 16 matching lines...) Expand all Loading... |
447 } | 447 } |
448 | 448 |
449 function testAttributeFilter() { | 449 function testAttributeFilter() { |
450 var div, path; | 450 var div, path; |
451 var observer; | 451 var observer; |
452 | 452 |
453 function start() { | 453 function start() { |
454 debug('Testing that attributeFilter works as expected and observes case
with HTML elements.'); | 454 debug('Testing that attributeFilter works as expected and observes case
with HTML elements.'); |
455 | 455 |
456 mutations = null; | 456 mutations = null; |
457 observer = new WebKitMutationObserver(function(m) { | 457 observer = new MutationObserver(function(m) { |
458 mutations = m; | 458 mutations = m; |
459 }); | 459 }); |
460 | 460 |
461 div = document.createElement('div'); | 461 div = document.createElement('div'); |
462 observer.observe(div, { attributes: true, attributeFilter: ['foo', 'bar'
, 'booM'] }); | 462 observer.observe(div, { attributes: true, attributeFilter: ['foo', 'bar'
, 'booM'] }); |
463 div.setAttribute('foo', 'foo'); | 463 div.setAttribute('foo', 'foo'); |
464 div.setAttribute('bar', 'bar'); | 464 div.setAttribute('bar', 'bar'); |
465 div.setAttribute('baz', 'baz'); | 465 div.setAttribute('baz', 'baz'); |
466 div.setAttribute('BOOm', 'boom'); | 466 div.setAttribute('BOOm', 'boom'); |
467 | 467 |
(...skipping 19 matching lines...) Expand all Loading... |
487 } | 487 } |
488 | 488 |
489 function testAttributeFilterSubtree() { | 489 function testAttributeFilterSubtree() { |
490 var div, div2, div3; | 490 var div, div2, div3; |
491 var observer; | 491 var observer; |
492 | 492 |
493 function start() { | 493 function start() { |
494 debug('Testing the behavior of attributeFilter when the same observer ob
serves at multiple nodes in a subtree with different filter options.'); | 494 debug('Testing the behavior of attributeFilter when the same observer ob
serves at multiple nodes in a subtree with different filter options.'); |
495 | 495 |
496 mutations = null; | 496 mutations = null; |
497 observer = new WebKitMutationObserver(function(m) { | 497 observer = new MutationObserver(function(m) { |
498 mutations = m; | 498 mutations = m; |
499 }); | 499 }); |
500 | 500 |
501 div = document.createElement('div'); | 501 div = document.createElement('div'); |
502 div2 = div.appendChild(document.createElement('div')); | 502 div2 = div.appendChild(document.createElement('div')); |
503 div3 = div2.appendChild(document.createElement('div')); | 503 div3 = div2.appendChild(document.createElement('div')); |
504 | 504 |
505 observer.observe(div, { attributes: true, subtree: true, attributeFilter
: ['foo', 'bar'] }); | 505 observer.observe(div, { attributes: true, subtree: true, attributeFilter
: ['foo', 'bar'] }); |
506 observer.observe(div2, { attributes: true, subtree: true, attributeFilte
r: ['bar', 'bat'] }); | 506 observer.observe(div2, { attributes: true, subtree: true, attributeFilte
r: ['bar', 'bat'] }); |
507 | 507 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 558 } |
559 | 559 |
560 function testAttributeFilterNonHTMLElement() { | 560 function testAttributeFilterNonHTMLElement() { |
561 var path; | 561 var path; |
562 var observer; | 562 var observer; |
563 | 563 |
564 function start() { | 564 function start() { |
565 debug('Testing that setting an attributeFilter filters out namespaced at
tributes.'); | 565 debug('Testing that setting an attributeFilter filters out namespaced at
tributes.'); |
566 | 566 |
567 mutations = null; | 567 mutations = null; |
568 observer = new WebKitMutationObserver(function(m) { | 568 observer = new MutationObserver(function(m) { |
569 mutations = m; | 569 mutations = m; |
570 }); | 570 }); |
571 | 571 |
572 path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); | 572 path = document.createElementNS('http://www.w3.org/2000/svg', 'path'); |
573 observer.observe(path, { attributes: true, attributeFilter: ['pathLength
'] }); | 573 observer.observe(path, { attributes: true, attributeFilter: ['pathLength
'] }); |
574 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathLength', '200'); | 574 path.setAttributeNS('http://www.w3.org/2000/svg', 'pathLength', '200'); |
575 | 575 |
576 setTimeout(finish, 0); | 576 setTimeout(finish, 0); |
577 } | 577 } |
578 | 578 |
(...skipping 11 matching lines...) Expand all Loading... |
590 | 590 |
591 function testAttributeFilterNonHTMLDocument() { | 591 function testAttributeFilterNonHTMLDocument() { |
592 var svgDoc, div, path; | 592 var svgDoc, div, path; |
593 var observer; | 593 var observer; |
594 | 594 |
595 function start() { | 595 function start() { |
596 debug('Testing that attributeFilter respects case with non-HTML elements
.'); | 596 debug('Testing that attributeFilter respects case with non-HTML elements
.'); |
597 | 597 |
598 svgDoc = document.implementation.createDocument('http://www.w3.org/2000/
svg', 'svg', 'svg'); | 598 svgDoc = document.implementation.createDocument('http://www.w3.org/2000/
svg', 'svg', 'svg'); |
599 mutations = null; | 599 mutations = null; |
600 observer = new WebKitMutationObserver(function(m) { | 600 observer = new MutationObserver(function(m) { |
601 mutations = m; | 601 mutations = m; |
602 }); | 602 }); |
603 | 603 |
604 div = svgDoc.createElement('div'); | 604 div = svgDoc.createElement('div'); |
605 observer.observe(div, { attributes: true, attributeFilter: ['ID', 'id',
'booM'] }); | 605 observer.observe(div, { attributes: true, attributeFilter: ['ID', 'id',
'booM'] }); |
606 div.setAttribute('ID', 'ID'); | 606 div.setAttribute('ID', 'ID'); |
607 div.setAttribute('id', 'id'); | 607 div.setAttribute('id', 'id'); |
608 div.setAttribute('baz', 'baz'); | 608 div.setAttribute('baz', 'baz'); |
609 div.setAttribute('booM', 'boom'); | 609 div.setAttribute('booM', 'boom'); |
610 div.setAttribute('BOOm', 'boom'); | 610 div.setAttribute('BOOm', 'boom'); |
(...skipping 24 matching lines...) Expand all Loading... |
635 } | 635 } |
636 | 636 |
637 function testStyleAttributePropertyAccess() { | 637 function testStyleAttributePropertyAccess() { |
638 var div, path; | 638 var div, path; |
639 var observer; | 639 var observer; |
640 | 640 |
641 function start() { | 641 function start() { |
642 debug('Testing that modifying an elements style property dispatches Muta
tion Records.'); | 642 debug('Testing that modifying an elements style property dispatches Muta
tion Records.'); |
643 | 643 |
644 mutations = null; | 644 mutations = null; |
645 observer = new WebKitMutationObserver(function(m) { | 645 observer = new MutationObserver(function(m) { |
646 mutations = m; | 646 mutations = m; |
647 }); | 647 }); |
648 | 648 |
649 div = document.createElement('div'); | 649 div = document.createElement('div'); |
650 div.setAttribute('style', 'color: yellow; width: 100px;'); | 650 div.setAttribute('style', 'color: yellow; width: 100px;'); |
651 observer.observe(div, { attributes: true }); | 651 observer.observe(div, { attributes: true }); |
652 div.style.color = 'red'; | 652 div.style.color = 'red'; |
653 div.style.width = '200px'; | 653 div.style.width = '200px'; |
654 div.style.color = 'blue'; | 654 div.style.color = 'blue'; |
655 | 655 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } | 687 } |
688 | 688 |
689 function testStyleAttributePropertyAccessOldValue() { | 689 function testStyleAttributePropertyAccessOldValue() { |
690 var div, path; | 690 var div, path; |
691 var observer; | 691 var observer; |
692 | 692 |
693 function start() { | 693 function start() { |
694 debug('Testing that modifying an elements style property dispatches Muta
tion Records with correct oldValues.'); | 694 debug('Testing that modifying an elements style property dispatches Muta
tion Records with correct oldValues.'); |
695 | 695 |
696 mutations = null; | 696 mutations = null; |
697 observer = new WebKitMutationObserver(function(m) { | 697 observer = new MutationObserver(function(m) { |
698 mutations = m; | 698 mutations = m; |
699 }); | 699 }); |
700 | 700 |
701 div = document.createElement('div'); | 701 div = document.createElement('div'); |
702 div.setAttribute('style', 'color: yellow; width: 100px;'); | 702 div.setAttribute('style', 'color: yellow; width: 100px;'); |
703 observer.observe(div, { attributes: true, attributeOldValue: true }); | 703 observer.observe(div, { attributes: true, attributeOldValue: true }); |
704 div.style.color = 'red'; | 704 div.style.color = 'red'; |
705 div.style.width = '200px'; | 705 div.style.width = '200px'; |
706 div.style.color = 'blue'; | 706 div.style.color = 'blue'; |
707 | 707 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 } | 739 } |
740 | 740 |
741 function testStyleAttributePropertyAccessIgnoreNoop() { | 741 function testStyleAttributePropertyAccessIgnoreNoop() { |
742 var div, path; | 742 var div, path; |
743 var observer; | 743 var observer; |
744 | 744 |
745 function start() { | 745 function start() { |
746 debug('Testing that a no-op style property mutation does not create Muta
tion Records.'); | 746 debug('Testing that a no-op style property mutation does not create Muta
tion Records.'); |
747 | 747 |
748 mutations = null; | 748 mutations = null; |
749 observer = new WebKitMutationObserver(function(m) { | 749 observer = new MutationObserver(function(m) { |
750 mutations = m; | 750 mutations = m; |
751 }); | 751 }); |
752 | 752 |
753 div = document.createElement('div'); | 753 div = document.createElement('div'); |
754 div.setAttribute('style', 'color: yellow; width: 100px;'); | 754 div.setAttribute('style', 'color: yellow; width: 100px;'); |
755 observer.observe(div, { attributes: true }); | 755 observer.observe(div, { attributes: true }); |
756 div.style.removeProperty('height'); | 756 div.style.removeProperty('height'); |
757 | 757 |
758 setTimeout(finish, 0); | 758 setTimeout(finish, 0); |
759 } | 759 } |
760 | 760 |
761 function finish() { | 761 function finish() { |
762 shouldBe('mutations', 'null'); | 762 shouldBe('mutations', 'null'); |
763 | 763 |
764 observer.disconnect(); | 764 observer.disconnect(); |
765 debug(''); | 765 debug(''); |
766 runNextTest(); | 766 runNextTest(); |
767 } | 767 } |
768 | 768 |
769 start(); | 769 start(); |
770 } | 770 } |
771 | 771 |
772 function testMutateThroughAttrNodeValue() { | 772 function testMutateThroughAttrNodeValue() { |
773 var observer; | 773 var observer; |
774 | 774 |
775 function start() { | 775 function start() { |
776 debug('Test that mutating an attribute through an attr node delivers mut
ation records'); | 776 debug('Test that mutating an attribute through an attr node delivers mut
ation records'); |
777 | 777 |
778 mutations = null; | 778 mutations = null; |
779 observer = new WebKitMutationObserver(function(mutations) { | 779 observer = new MutationObserver(function(mutations) { |
780 window.mutations = mutations; | 780 window.mutations = mutations; |
781 }); | 781 }); |
782 | 782 |
783 div = document.createElement('div'); | 783 div = document.createElement('div'); |
784 div.setAttribute('data-test', 'foo'); | 784 div.setAttribute('data-test', 'foo'); |
785 observer.observe(div, { attributes: true, attributeOldValue: true }); | 785 observer.observe(div, { attributes: true, attributeOldValue: true }); |
786 div.attributes['data-test'].value = 'bar'; | 786 div.attributes['data-test'].value = 'bar'; |
787 | 787 |
788 setTimeout(finish, 0); | 788 setTimeout(finish, 0); |
789 } | 789 } |
(...skipping 13 matching lines...) Expand all Loading... |
803 start(); | 803 start(); |
804 } | 804 } |
805 | 805 |
806 function testMutateThroughAttrNodeChild() { | 806 function testMutateThroughAttrNodeChild() { |
807 var observer; | 807 var observer; |
808 | 808 |
809 function start() { | 809 function start() { |
810 debug('Test that mutating an attribute by attaching a child to an attr n
ode delivers mutation records'); | 810 debug('Test that mutating an attribute by attaching a child to an attr n
ode delivers mutation records'); |
811 | 811 |
812 mutations = null; | 812 mutations = null; |
813 observer = new WebKitMutationObserver(function(mutations) { | 813 observer = new MutationObserver(function(mutations) { |
814 window.mutations = mutations; | 814 window.mutations = mutations; |
815 }); | 815 }); |
816 | 816 |
817 div = document.createElement('div'); | 817 div = document.createElement('div'); |
818 div.setAttribute('data-test', 'foo'); | 818 div.setAttribute('data-test', 'foo'); |
819 observer.observe(div, { attributes: true, attributeOldValue: true }); | 819 observer.observe(div, { attributes: true, attributeOldValue: true }); |
820 div.attributes['data-test'].appendChild(document.createTextNode('bar')); | 820 div.attributes['data-test'].appendChild(document.createTextNode('bar')); |
821 | 821 |
822 setTimeout(finish, 0); | 822 setTimeout(finish, 0); |
823 } | 823 } |
(...skipping 13 matching lines...) Expand all Loading... |
837 start(); | 837 start(); |
838 } | 838 } |
839 | 839 |
840 function testSetAndRemoveAttributeNode() { | 840 function testSetAndRemoveAttributeNode() { |
841 var observer; | 841 var observer; |
842 | 842 |
843 function start() { | 843 function start() { |
844 debug('Test that mutating via setAttributeNode delivers mutation records
'); | 844 debug('Test that mutating via setAttributeNode delivers mutation records
'); |
845 | 845 |
846 mutations = null; | 846 mutations = null; |
847 observer = new WebKitMutationObserver(function(mutations) { | 847 observer = new MutationObserver(function(mutations) { |
848 window.mutations = mutations; | 848 window.mutations = mutations; |
849 }); | 849 }); |
850 | 850 |
851 div = document.createElement('div'); | 851 div = document.createElement('div'); |
852 div.id = 'myId'; | 852 div.id = 'myId'; |
853 div.setAttribute('data-test', 'foo'); | 853 div.setAttribute('data-test', 'foo'); |
854 observer.observe(div, { attributes: true, attributeOldValue: true }); | 854 observer.observe(div, { attributes: true, attributeOldValue: true }); |
855 var attr = document.createAttribute('data-test'); | 855 var attr = document.createAttribute('data-test'); |
856 attr.value = 'bar'; | 856 attr.value = 'bar'; |
857 div.setAttributeNode(attr); | 857 div.setAttributeNode(attr); |
(...skipping 28 matching lines...) Expand all Loading... |
886 start(); | 886 start(); |
887 } | 887 } |
888 | 888 |
889 function testMixedNodeAndElementOperations() { | 889 function testMixedNodeAndElementOperations() { |
890 var observer; | 890 var observer; |
891 | 891 |
892 function start() { | 892 function start() { |
893 debug('Test that setAttribute on an attribute with an existing Attr deli
vers mutation records'); | 893 debug('Test that setAttribute on an attribute with an existing Attr deli
vers mutation records'); |
894 | 894 |
895 mutations = null; | 895 mutations = null; |
896 observer = new WebKitMutationObserver(function(mutations) { | 896 observer = new MutationObserver(function(mutations) { |
897 window.mutations = mutations; | 897 window.mutations = mutations; |
898 }); | 898 }); |
899 | 899 |
900 div = document.createElement('div'); | 900 div = document.createElement('div'); |
901 var attr = document.createAttribute('data-test'); | 901 var attr = document.createAttribute('data-test'); |
902 attr.value = 'foo'; | 902 attr.value = 'foo'; |
903 div.setAttributeNode(attr); | 903 div.setAttributeNode(attr); |
904 observer.observe(div, { attributes: true, attributeOldValue: true }); | 904 observer.observe(div, { attributes: true, attributeOldValue: true }); |
905 div.setAttribute('data-test', 'bar'); | 905 div.setAttribute('data-test', 'bar'); |
906 | 906 |
(...skipping 15 matching lines...) Expand all Loading... |
922 start(); | 922 start(); |
923 } | 923 } |
924 | 924 |
925 function testNamedNodeMapOperations() { | 925 function testNamedNodeMapOperations() { |
926 var observer; | 926 var observer; |
927 | 927 |
928 function start() { | 928 function start() { |
929 debug('Test that setNamedItem and removeNamedItem deliver mutation recor
ds'); | 929 debug('Test that setNamedItem and removeNamedItem deliver mutation recor
ds'); |
930 | 930 |
931 mutations = null; | 931 mutations = null; |
932 observer = new WebKitMutationObserver(function(mutations) { | 932 observer = new MutationObserver(function(mutations) { |
933 window.mutations = mutations; | 933 window.mutations = mutations; |
934 }); | 934 }); |
935 | 935 |
936 div = document.createElement('div'); | 936 div = document.createElement('div'); |
937 div.setAttribute('data-test', 'foo'); | 937 div.setAttribute('data-test', 'foo'); |
938 observer.observe(div, { attributes: true, attributeOldValue: true }); | 938 observer.observe(div, { attributes: true, attributeOldValue: true }); |
939 var attr = document.createAttribute('data-test'); | 939 var attr = document.createAttribute('data-test'); |
940 attr.value = 'bar'; | 940 attr.value = 'bar'; |
941 div.attributes.setNamedItem(attr); | 941 div.attributes.setNamedItem(attr); |
942 div.attributes.removeNamedItem('data-test'); | 942 div.attributes.removeNamedItem('data-test'); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
995 tests[testIndex++](); | 995 tests[testIndex++](); |
996 else | 996 else |
997 finishJSTest(); | 997 finishJSTest(); |
998 } | 998 } |
999 | 999 |
1000 description('Test WebKitMutationObserver.observe on attributes'); | 1000 description('Test WebKitMutationObserver.observe on attributes'); |
1001 | 1001 |
1002 runNextTest(); | 1002 runNextTest(); |
1003 </script> | 1003 </script> |
1004 <script src="../../js/resources/js-test-post.js"></script> | 1004 <script src="../../js/resources/js-test-post.js"></script> |
OLD | NEW |