Files
webcomponentsjs/tests/MutationObservers/runner.html
2014-11-24 17:04:36 -08:00

90 lines
3.1 KiB
HTML

<!doctype html>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<meta charset="utf-8">
<!-- Mocha/Chai -->
<link rel="stylesheet" href="../tools/mocha/mocha.css">
<script src="../tools/mocha/mocha.js"></script>
<script src="../tools/chai/chai.js"></script>
<script src="../tools/mocha-htmltest.js"></script>
<!-- MutationObserver -->
<script src="../../src/MutationObserver/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>