[Webkit-unassigned] [Bug 163845] New: Promise - MutationObserver interaction spins the event loop
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Sat Oct 22 04:01:22 PDT 2016
https://bugs.webkit.org/show_bug.cgi?id=163845
Bug ID: 163845
Summary: Promise - MutationObserver interaction spins the event
loop
Classification: Unclassified
Product: WebKit
Version: Safari Technology Preview
Hardware: Macintosh
OS: OS X 10.11
Status: NEW
Severity: Normal
Priority: P2
Component: JavaScriptCore
Assignee: webkit-unassigned at lists.webkit.org
Reporter: miklos.bertalan at risingstack.com
Queueing a Promise from a MutationObserver handler or triggering an observed change from a Promise callback spins the event loop. According to the spec, it should register a new microtask and not a new task.
Code to reproduce (it is also attached):
<div class="tester"></div>
<script>
const tester = document.querySelector('.tester')
let counter = 0
setTimeout(() => console.log('timeout'))
new MutationObserver(() => {
console.log('mutation')
if (counter < 100) {
Promise.resolve().then(() => {
console.log('promise')
tester.setAttribute('data-random', Math.random())
})
}
counter++
}).observe(tester, {attributes: true})
tester.setAttribute('data-random', Math.random())
</script>
Issue:
It the above code should print: mutation, promise, mutation, promise, ... timeout
Instead it prints: mutation, timeout, promise, mutation, promise, mutation, ...
Notes:
It seems to get it wrong consistently (not just some of the time). I think it is not caused by any kind of throttling.
It seems to queue a new task for both directions (Promise -> Mutation, Mutation -> Promise).
(Promise -> Promise) and (Mutation -> Mutation) are both handled correctly as new microtasks.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-unassigned/attachments/20161022/38e5d3c8/attachment.html>
More information about the webkit-unassigned
mailing list