shim necessary for browsers supporting old mutation events but not new mutation observers bzr revid: xmo@openerp.com-20130828084945-yfqrs0v9v8iecwjm
82 lines
2.6 KiB
HTML
82 lines
2.6 KiB
HTML
<!DOCTYPE html>
|
|
<!--
|
|
Copyright 2012 The Polymer Authors. All rights reserved.
|
|
Use of this source code is governed by a BSD-style
|
|
license that can be found in the LICENSE file.
|
|
-->
|
|
<meta charset="utf-8">
|
|
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
|
|
<script src="../node_modules/chai/chai.js"></script>
|
|
<script src="../node_modules/mocha/mocha.js"></script>
|
|
<script src="sidetable.js"></script>
|
|
<script src="../MutationObserver.js"></script>
|
|
<script>
|
|
|
|
mocha.setup({
|
|
ui: 'tdd',
|
|
ignoreLeaks: true
|
|
});
|
|
|
|
var assert = chai.assert;
|
|
|
|
function assertArrayEqual(a, b, msg) {
|
|
assert.equal(a.length, b.length, msg);
|
|
for (var i = 0; i < a.length; i++) {
|
|
assert.equal(a[i], b[i], msg);
|
|
}
|
|
}
|
|
|
|
var expectRecord = (function() {
|
|
var useNative = /native/.test(location.search);
|
|
var isWebKit = /WebKit/.test(navigator.userAgent);
|
|
var slice = Array.prototype.slice.call.bind(Array.prototype.slice);
|
|
|
|
if (useNative) {
|
|
JsMutationObserver =
|
|
window.MutationObserver || window.WebKitMutationObserver;
|
|
}
|
|
|
|
// addedNodes/removedNodes are broken in WebKit.
|
|
// https://bugs.webkit.org/show_bug.cgi?id=98921
|
|
function fixWebKitNodes(nodes) {
|
|
if (nodes === null && useNative && isWebKit)
|
|
return [];
|
|
return nodes;
|
|
}
|
|
|
|
return function expectRecord(record, expected) {
|
|
assert.strictEqual(record.type,
|
|
expected.type === undefined ? null : expected.type);
|
|
assert.strictEqual(record.target,
|
|
expected.target === undefined ? null : expected.target);
|
|
assertArrayEqual(fixWebKitNodes(record.addedNodes),
|
|
expected.addedNodes === undefined ? [] : expected.addedNodes);
|
|
assertArrayEqual(fixWebKitNodes(record.removedNodes),
|
|
expected.removedNodes === undefined ? [] : expected.removedNodes);
|
|
assert.strictEqual(record.previousSibling,
|
|
expected.previousSibling === undefined ?
|
|
null : expected.previousSibling);
|
|
assert.strictEqual(record.nextSibling,
|
|
expected.nextSibling === undefined ? null : expected.nextSibling);
|
|
assert.strictEqual(record.attributeName,
|
|
expected.attributeName === undefined ? null : expected.attributeName);
|
|
assert.strictEqual(record.attributeNamespace,
|
|
expected.attributeNamespace === undefined ?
|
|
null : expected.attributeNamespace);
|
|
assert.strictEqual(record.oldValue,
|
|
expected.oldValue === undefined ? null : expected.oldValue);
|
|
};
|
|
})();
|
|
|
|
</script>
|
|
<script src="attributes.js"></script>
|
|
<script src="characterData.js"></script>
|
|
<script src="childList.js"></script>
|
|
<script src="mixed.js"></script>
|
|
<script src="callback.js"></script>
|
|
<script src="transient.js"></script>
|
|
<div id="mocha"></div>
|
|
<script>
|
|
mocha.run();
|
|
</script>
|