mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-05-09 00:41:24 +00:00
79 lines
2.8 KiB
HTML
79 lines
2.8 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">
|
|
|
|
<!-- MutationObserver -->
|
|
<script src="../../src/WeakMap/WeakMap.js"></script>
|
|
<script src="../../src/MutationObserver/MutationObserver.js"></script>
|
|
<script src="../../../web-component-tester/browser.js"></script>
|
|
<script>
|
|
|
|
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 = Boolean(window.MutationObserver ||
|
|
window.WebKitMutationObserver);
|
|
var isWebKit = /WebKit/.test(navigator.userAgent);
|
|
var slice = Array.prototype.slice.call.bind(Array.prototype.slice);
|
|
|
|
if (useNative) {
|
|
window.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);
|
|
};
|
|
})();
|
|
|
|
WCT.loadSuites([
|
|
'attributes.js',
|
|
'characterData.js',
|
|
'childList.js',
|
|
'mixed.js',
|
|
'callback.js',
|
|
'transient.js'
|
|
]);
|
|
|
|
</script>
|