mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
30 lines
982 B
HTML
30 lines
982 B
HTML
<html>
|
|
<link rel="import" href="../resources/chai.html" />
|
|
<link rel="import" href="../resources/mocha.html" />
|
|
<script>
|
|
describe('MutationObserver wrappers', function() {
|
|
it('should survive GC for passing into the callback even if JS has lost references and the only remaining observations are transient.', function(done) {
|
|
function addObserver(node, fn) {
|
|
var observer = new MutationObserver(fn);
|
|
observer.testProperty = true;
|
|
observer.observe(node, {attributes:true, subtree: true});
|
|
}
|
|
|
|
var root = document.createElement('div');
|
|
var child = root.appendChild(document.createElement('span'));
|
|
addObserver(root, function(records, observer) {
|
|
window.observer = observer;
|
|
assert.ok(observer.testProperty);
|
|
done();
|
|
});
|
|
|
|
root.removeChild(child);
|
|
child.setAttribute('foo', 'bar');
|
|
root = null;
|
|
|
|
gc();
|
|
});
|
|
});
|
|
</script>
|
|
</html>
|