OLD | NEW |
| (Empty) |
1 <html> | |
2 <link rel="import" href="../resources/chai.html" /> | |
3 <link rel="import" href="../resources/mocha.html" /> | |
4 <script> | |
5 describe('MutationObserver cross document moves', function() { | |
6 it('should handle basic observation', function(done) { | |
7 var mutations; | |
8 var div = document.createElement('div'); | |
9 var observer = new MutationObserver(function(records) { | |
10 mutations = records; | |
11 }); | |
12 | |
13 observer.observe(div, {attributes: true}); | |
14 var newDoc = document.implementation.createDocument('', '', null); | |
15 newDoc.appendChild(div); | |
16 div.id = 'foo'; | |
17 setTimeout(function() { | |
18 assert.equal(mutations.length, 1); | |
19 assert.equal(mutations[0].type, 'attributes'); | |
20 assert.equal(mutations[0].target, div); | |
21 assert.equal(mutations[0].attributeName, 'id'); | |
22 observer.disconnect(); | |
23 done(); | |
24 }, 0); | |
25 }); | |
26 it('should handle subtree observation', function(done) { | |
27 var mutations; | |
28 var div = document.createElement('div'); | |
29 var subDiv = div.appendChild(document.createElement('div')); | |
30 var observer = new MutationObserver(function(records) { | |
31 mutations = records; | |
32 }); | |
33 | |
34 observer.observe(div, {attributes: true, subtree: true}); | |
35 var newDoc = document.implementation.createDocument(); | |
36 newDoc.appendChild(div); | |
37 subDiv.id = 'foo'; | |
38 setTimeout(function() { | |
39 assert.equal(mutations.length, 1); | |
40 assert.equal(mutations[0].type, 'attributes'); | |
41 assert.equal(mutations[0].target, subDiv); | |
42 assert.equal(mutations[0].attributeName, 'id'); | |
43 observer.disconnect(); | |
44 done(); | |
45 }, 0); | |
46 }); | |
47 }); | |
48 </script> | |
49 </html> | |
OLD | NEW |