blob: 693522fa32ee042a8c6333235aec6dce1b003315 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<script>
description('Non-relevant properties on mutation records should be null, except for NodeLists, which should be empty');
var observer = new MutationObserver(function() {});
var text = document.createTextNode('something');
observer.observe(text, {characterData: true});
text.data = 'something else';
var record = observer.takeRecords()[0];
debug('characterData record:');
shouldBeNull('record.attributeName');
shouldBeNull('record.attributeNamespace');
shouldBeNull('record.oldValue');
shouldBeNull('record.previousSibling');
shouldBeNull('record.nextSibling');
shouldBe('record.addedNodes.length', '0');
shouldBe('record.removedNodes.length', '0');
var div = document.createElement('div');
observer.observe(div, {childList: true});
div.appendChild(document.createElement('span'));
record = observer.takeRecords()[0];
debug('\nchildList record:');
shouldBeNull('record.attributeName');
shouldBeNull('record.attributeNamespace');
shouldBeNull('record.oldValue');
observer.observe(div, {attributes: true});
div.setAttribute('data-foo', 'bar');
record = observer.takeRecords()[0];
debug('\nattributes record:');
shouldBeNull('record.attributeNamespace');
shouldBeNull('record.oldValue');
shouldBeNull('record.previousSibling');
shouldBeNull('record.nextSibling');
shouldBe('record.addedNodes.length', '0');
shouldBe('record.removedNodes.length', '0');
</script>