Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
[MutationObservers] Clear pending mutation records on disconnect()
https://bugs.webkit.org/show_bug.cgi?id=78639 Reviewed by Ojan Vafai. Source/WebCore: Test: fast/mutation/disconnect-cancel-pending.html * dom/WebKitMutationObserver.cpp: (WebCore::WebKitMutationObserver::disconnect): Clear pending records. (WebCore::WebKitMutationObserver::deliver): Avoid calling the callback if no records are pending delivery. LayoutTests: * fast/mutation/disconnect-cancel-pending-expected.txt: Added. * fast/mutation/disconnect-cancel-pending.html: Added. Canonical link: https://commits.webkit.org/96820@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@109058 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,14 @@ | ||
Test that WebKitMutationObserver.disconnect cancels pending delivery | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
Disconnecting should cancel any pending delivery... | ||
PASS mutations is null | ||
...and re-observing should not see any of the previously-generated records. | ||
PASS mutations.length is 1 | ||
PASS mutations[0].attributeName is "bar" | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,45 @@ | ||
<!DOCTYPE html> | ||
<script src="../js/resources/js-test-pre.js"></script> | ||
<script> | ||
description('Test that WebKitMutationObserver.disconnect cancels pending delivery'); | ||
|
||
window.jsTestIsAsync = true; | ||
var mutations; | ||
var observer; | ||
|
||
function start() { | ||
mutations = null; | ||
div = document.createElement('div'); | ||
|
||
observer = new WebKitMutationObserver(function(m) { | ||
mutations = m; | ||
}); | ||
|
||
observer.observe(div, { attributes: true }); | ||
div.setAttribute('foo', 'bar'); | ||
observer.disconnect(); | ||
setTimeout(next, 0); | ||
} | ||
|
||
function next() { | ||
debug('Disconnecting should cancel any pending delivery...'); | ||
shouldBeNull('mutations'); | ||
observer.observe(div, { attributes: true }); | ||
div.setAttribute('bar', 'baz'); | ||
setTimeout(finish, 0); | ||
} | ||
|
||
function finish() { | ||
debug('...and re-observing should not see any of the previously-generated records.'); | ||
shouldBe('mutations.length', '1'); | ||
shouldBe('mutations[0].attributeName', '"bar"'); | ||
finishJSTest(); | ||
} | ||
|
||
if (!window.WebKitMutationObserver) | ||
testFailed('This test requires ENABLE(MUTATION_OBSERVERS)'); | ||
else | ||
start(); | ||
|
||
</script> | ||
<script src="../js/resources/js-test-post.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters