blob: 11be804e0dcf22bfda6a5553596adc826e6e06df [file] [log] [blame]
<html>
<link rel="import" href="../resources/chai.html" />
<link rel="import" href="../resources/mocha.html" />
<script>
describe('MutationObserver', function() {
it('should deliver in order of creation', function(done) {
var order = [];
var observers = [];
function setUpOrdering(num) {
observers.push(new MutationObserver(function(mutations) {
order.push(num);
}));
}
for (var i = 0; i < 10; ++i)
setUpOrdering(i);
var div = document.createElement('div');
observers[3].observe(div, {attributes: true});
observers[2].observe(div, {characterData: true, subtree: true});
observers[1].observe(div, {attributes: true});
observers[7].observe(div, {childList: true});
observers[4].observe(div, {attributes: true});
observers[9].observe(div, {attributes: true});
observers[0].observe(div, {childList: true});
observers[5].observe(div, {attributes: true});
observers[6].observe(div, {characterData: true, subtree: true});
observers[8].observe(div, {attributes: true});
div.setAttribute('foo', 'bar');
div.appendChild(document.createTextNode('hello'));
div.firstChild.textContent = 'goodbye';
setTimeout(function() {
assert.deepEqual(order, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
done();
}, 0);
});
});
</script>
</html>