<!DOCTYPE html>
<script src="../../../resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;

description('Test that mutations during delivery do not interrupt delivery order.');
function finish() {
    shouldBe('order.length', '3');
    shouldBe('order[0]', '1');
    shouldBe('order[1]', '3');
    shouldBe('order[2]', '2');
    finishJSTest();
}

var order = [];
var div = document.createElement('div');

var observer1 = new MutationObserver(function(mutations) {
    order.push(1);
    div.appendChild(document.createElement('span'));
});
var observer2 = new MutationObserver(function(mutations) {
    order.push(2);
});
var observer3 = new MutationObserver(function(mutations) {
    order.push(3);
});

observer1.observe(div, {attributes: true});
observer2.observe(div, {childList: true});
observer3.observe(div, {attributes: true});
div.setAttribute('foo', 'bar');
setTimeout(finish, 0);
</script>
<script src="../../../resources/js-test-post.js"></script>
