function test() {
let insertedEventCount = 0;
let insertedListener = function() {
insertedEventCount++;
};
let removedEventCount = 0;
let removedListener = function() {
removedEventCount++;
};
// Tests for no title element.
document.addEventListener('DOMNodeRemoved', removedListener);
document.addEventListener('DOMNodeInserted', insertedListener);
document.title = "Test for Bug 1127588";
document.removeEventListener('DOMNodeInserted', insertedListener);
document.removeEventListener('DOMNodeRemoved', removedListener);
// Check result.
is(insertedEventCount, 2, "Should get 'DOMNodeInserted' mutation event");
is(removedEventCount, 0, "Should not get 'DOMNodeRemoved' mutation event");
// Test for updating title element.
insertedEventCount = 0;
removedEventCount = 0;
document.addEventListener('DOMNodeRemoved', removedListener);
document.addEventListener('DOMNodeInserted', insertedListener);
// eslint-disable-next-line no-self-assign
document.title = document.title;
document.removeEventListener('DOMNodeInserted', insertedListener);
document.removeEventListener('DOMNodeRemoved', removedListener);
// Check result.
is(insertedEventCount, 1, "Should get 'DOMNodeInserted' mutation event");
is(removedEventCount, 1, "Should get 'DOMNodeRemoved' mutation event");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.