Bug 218361
Summary: | JS Promises in detached iframes do not settle | ||
---|---|---|---|
Product: | WebKit | Reporter: | Chris Dumez <cdumez> |
Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
Status: | RESOLVED DUPLICATE | ||
Severity: | Normal | CC: | ggaren, keith_miller, mark.lam, rniwa, saam, ysuzuki |
Priority: | P2 | ||
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
See Also: | https://bugs.webkit.org/show_bug.cgi?id=218363 |
Chris Dumez
JS Promises in detached iframes do not settle:
===
<!doctype html>
<title>Test that the promise from detached iframes do get resolved.</title>
<body></body>
<script>
frame = document.createElement('iframe');
document.body.appendChild(frame);
frame.contentWindow.Promise.resolve("test").then(() => {
alert("Resolved! URL is: " + document.URL);
});
frame.remove();
</script>
===
I see an alert in Chrome and Firefox (with the URL being the top document URL). No alert in Safari.
This is causing issues with our DOM API returning promises as well.
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Keith Miller
Do we check that the frame is still detached in the WebCore micro task queue? Seems likely that is the source of the problem here.
Keith Miller
(In reply to Keith Miller from comment #1)
> Do we check that the frame is still detached in the WebCore micro task
> queue? Seems likely that is the source of the problem here.
/detached/attached/s
Chris Dumez
Looks like this is the source of the issue:
diff --git a/Source/WebCore/dom/Microtasks.cpp b/Source/WebCore/dom/Microtasks.cpp
index 2e4aa4b56c10..73cb09642adf 100644
--- a/Source/WebCore/dom/Microtasks.cpp
+++ b/Source/WebCore/dom/Microtasks.cpp
@@ -56,7 +56,7 @@ void MicrotaskQueue::performMicrotaskCheckpoint()
Vector<std::unique_ptr<EventLoopTask>> queue = WTFMove(m_microtaskQueue);
for (auto& task : queue) {
auto* group = task->group();
- if (!group || group->isStoppedPermanently())
+ if (!group/* || group->isStoppedPermanently()*/)
continue;
if (group->isSuspended())
toKeep.append(WTFMove(task));
Chris Dumez
As Geoff pointed out on Slack:
"""
A browsing context group holds a browsing context set (a set of top-level browsing contexts).
A top-level browsing context is added to the group when the group is created. All subsequent top-level browsing contexts added to the group will be auxiliary browsing contexts.
"""
Seems wrong that we use different groups for documents in the same top-level browsing context.
Yusuke Suzuki
Is it related to https://bugs.webkit.org/show_bug.cgi?id=216149 ?
Chris Dumez
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index c9e3be11872a..6f4ffa18644b 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -2711,8 +2711,8 @@ void Document::resumeActiveDOMObjects(ReasonForSuspension why)
void Document::stopActiveDOMObjects()
{
- if (m_documentTaskGroup)
- m_documentTaskGroup->stopAndDiscardAllTasks();
+ /*if (m_documentTaskGroup)
+ m_documentTaskGroup->stopAndDiscardAllTasks();*/
ScriptExecutionContext::stopActiveDOMObjects();
platformSuspendOrStopActiveDOMObjects();
}
diff --git a/Source/WebCore/dom/Microtasks.cpp b/Source/WebCore/dom/Microtasks.cpp
index 2e4aa4b56c10..73cb09642adf 100644
--- a/Source/WebCore/dom/Microtasks.cpp
+++ b/Source/WebCore/dom/Microtasks.cpp
@@ -56,7 +56,7 @@ void MicrotaskQueue::performMicrotaskCheckpoint()
Vector<std::unique_ptr<EventLoopTask>> queue = WTFMove(m_microtaskQueue);
for (auto& task : queue) {
auto* group = task->group();
- if (!group || group->isStoppedPermanently())
+ if (!group/* || group->isStoppedPermanently()*/)
continue;
if (group->isSuspended())
toKeep.append(WTFMove(task));
Had to do both these changes to make WebAudio tests pass (Bug 218363).
Chris Dumez
*** This bug has been marked as a duplicate of bug 218363 ***