| 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.disconnect', function() { | |
| 6 it('should cancel pending delivery', function(done) { | |
| 7 var mutations; | |
| 8 var observer; | |
| 9 var div; | |
| 10 | |
| 11 function start() { | |
| 12 mutations = null; | |
| 13 div = document.createElement('div'); | |
| 14 | |
| 15 observer = new MutationObserver(function(m) { | |
| 16 mutations = m; | |
| 17 }); | |
| 18 | |
| 19 observer.observe(div, { attributes: true }); | |
| 20 div.setAttribute('foo', 'bar'); | |
| 21 observer.disconnect(); | |
| 22 setTimeout(next, 0); | |
| 23 } | |
| 24 | |
| 25 function next() { | |
| 26 // Disconnecting should cancel any pending delivery... | |
| 27 assert.equal(mutations, null); | |
| 28 observer.observe(div, { attributes: true }); | |
| 29 div.setAttribute('bar', 'baz'); | |
| 30 setTimeout(finish, 0); | |
| 31 } | |
| 32 | |
| 33 function finish() { | |
| 34 // ...and re-observing should not see any of the previously-generate
d records. | |
| 35 assert.equal(mutations.length, 1); | |
| 36 assert.equal(mutations[0].attributeName, "bar"); | |
| 37 done(); | |
| 38 } | |
| 39 | |
| 40 start(); | |
| 41 }); | |
| 42 }); | |
| 43 </script> | |
| 44 </html> | |
| OLD | NEW |