flutter_flutter/tests/mutation-observer/mutation-record-nullity.html
2014-10-23 11:17:19 -07:00

43 lines
1.5 KiB
HTML

<html>
<link rel="import" href="../resources/chai.html" />
<link rel="import" href="../resources/mocha.html" />
<script>
describe('Non-relevant properties on mutation records should be null, except for NodeLists, which should be empty', function() {
var observer = new MutationObserver(function() {});
it('on characterData records', function() {
var text = document.createTextNode('something');
observer.observe(text, {characterData: true});
text.data = 'something else';
var record = observer.takeRecords()[0];
assert.isNull(record.attributeName);
assert.isNull(record.oldValue);
assert.isNull(record.previousSibling);
assert.isNull(record.nextSibling);
assert.equal(record.addedNodes.length, 0);
assert.equal(record.removedNodes.length, 0);
});
it('on childList records', function() {
var div = document.createElement('div');
observer.observe(div, {childList: true});
div.appendChild(document.createElement('span'));
record = observer.takeRecords()[0];
assert.isNull(record.attributeName);
assert.isNull(record.oldValue);
});
it('on attribute records', function() {
var div = document.createElement('div');
observer.observe(div, {attributes: true});
div.setAttribute('data-foo', 'bar');
record = observer.takeRecords()[0];
assert.isNull(record.oldValue);
assert.isNull(record.previousSibling);
assert.isNull(record.nextSibling);
assert.equal(record.addedNodes.length, 0);
assert.equal(record.removedNodes.length, 0);
});
});
</script>
</html>