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 window.jsTestIsAsync = true; | 4 window.jsTestIsAsync = true; |
5 | 5 |
6 description('Test that MutationObservers created during delivery must wait for t
he next loop.'); | 6 description('Test that MutationObservers created during delivery must wait for t
he next loop.'); |
7 function finish() { | 7 function finish() { |
8 shouldBe('order.length', '4'); | 8 shouldBe('order.length', '4'); |
9 shouldBe('order[0]', '1'); | 9 shouldBe('order[0]', '1'); |
10 shouldBe('order[1]', '2'); | 10 shouldBe('order[1]', '2'); |
11 shouldBe('order[2]', '1'); | 11 shouldBe('order[2]', '1'); |
12 shouldBe('order[3]', '3'); | 12 shouldBe('order[3]', '3'); |
13 finishJSTest(); | 13 finishJSTest(); |
14 } | 14 } |
15 | 15 |
16 var order = []; | 16 var order = []; |
17 var div = document.createElement('div'); | 17 var div = document.createElement('div'); |
18 | 18 |
19 var observer3; | 19 var observer3; |
20 var observer1 = new WebKitMutationObserver(function(mutations) { | 20 var observer1 = new MutationObserver(function(mutations) { |
21 order.push(1); | 21 order.push(1); |
22 if (!observer3) { | 22 if (!observer3) { |
23 observer3 = new WebKitMutationObserver(function(mutations) { | 23 observer3 = new MutationObserver(function(mutations) { |
24 order.push(3); | 24 order.push(3); |
25 }); | 25 }); |
26 observer3.observe(div, {attributes: true}); | 26 observer3.observe(div, {attributes: true}); |
27 div.setAttribute('foo', 'baz'); | 27 div.setAttribute('foo', 'baz'); |
28 } | 28 } |
29 }); | 29 }); |
30 var observer2 = new WebKitMutationObserver(function(mutations) { | 30 var observer2 = new MutationObserver(function(mutations) { |
31 order.push(2); | 31 order.push(2); |
32 }); | 32 }); |
33 | 33 |
34 observer1.observe(div, {attributes: true}); | 34 observer1.observe(div, {attributes: true}); |
35 observer2.observe(div, {attributes: true}); | 35 observer2.observe(div, {attributes: true}); |
36 div.setAttribute('foo', 'bar'); | 36 div.setAttribute('foo', 'bar'); |
37 setTimeout(finish, 0); | 37 setTimeout(finish, 0); |
38 </script> | 38 </script> |
39 <script src="../../js/resources/js-test-post.js"></script> | 39 <script src="../../js/resources/js-test-post.js"></script> |
OLD | NEW |