Title: [253265] trunk
Revision
253265
Author
[email protected]
Date
2019-12-07 16:41:03 -0800 (Sat, 07 Dec 2019)

Log Message

Unique origin's window must get its own event loop
https://bugs.webkit.org/show_bug.cgi?id=204978

Reviewed by Antti Koivisto.

Source/WebCore:

This patch fixes the bug that unique origin documents and documents of the same registrable domains
with different schemes / protocols were sharing the same event loop. Note that we continue to share
the event loop across file URI documents.

We now use the agent cluster key to looking up the event loop to better match the HTML5 spec:
https://html.spec.whatwg.org/multipage/webappapis.html#obtain-agent-cluster-key

Tests: fast/eventloop/data-uri-document-has-its-own-event-loop.html
       fast/eventloop/queue-task-across-frames-in-file-uri.html
       http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html

* dom/Document.cpp:
(WebCore::Document::eventLoop):
* dom/EventLoop.h:
(WebCore::EventLoopTaskGroup::hasSameEventLoopAs): Added for testing purposes.
* dom/WindowEventLoop.cpp:
(WebCore::agentClusterKeyOrNullIfUnique): Added.
(WebCore::WindowEventLoop::eventLoopForSecurityOrigin): Replaced ensureForRegistrableDomain.
(WebCore::WindowEventLoop::create): Added.
(WebCore::WindowEventLoop::WindowEventLoop):
(WebCore::WindowEventLoop::~WindowEventLoop):
* dom/WindowEventLoop.h:
* testing/Internals.cpp:
(WebCore::Internals::hasSameEventLoopAs): Added for testing purposes.
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Added tests to make sure data URI documents continue to use the same event loop but documents of
unique origin and of different schemes will use distinct event loops using newly added internals
method (hasSameEventLoopAs). Also added assertions to the existing tests using this new method.

* fast/eventloop: Added.
* fast/eventloop/data-uri-document-has-its-own-event-loop-expected.txt: Added.
* fast/eventloop/data-uri-document-has-its-own-event-loop.html: Added.
* fast/eventloop/queue-task-across-frames-in-file-uri-expected.txt: Added.
* fast/eventloop/queue-task-across-frames-in-file-uri.html: Added.
* fast/eventloop/resources: Added.
* fast/eventloop/resources/eventloop-helper.html: Added.
* http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop-expected.txt: Added.
* http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html: Added.
* http/tests/eventloop/queue-task-across-cross-site-frames-expected.txt:
* http/tests/eventloop/queue-task-across-cross-site-frames.html:
* http/tests/eventloop/queue-task-across-frames-expected.txt:
* http/tests/eventloop/queue-task-across-frames.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (253264 => 253265)


--- trunk/LayoutTests/ChangeLog	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/LayoutTests/ChangeLog	2019-12-08 00:41:03 UTC (rev 253265)
@@ -1,3 +1,28 @@
+2019-12-07  Ryosuke Niwa  <[email protected]>
+
+        Unique origin's window must get its own event loop
+        https://bugs.webkit.org/show_bug.cgi?id=204978
+
+        Reviewed by Antti Koivisto.
+
+        Added tests to make sure data URI documents continue to use the same event loop but documents of
+        unique origin and of different schemes will use distinct event loops using newly added internals
+        method (hasSameEventLoopAs). Also added assertions to the existing tests using this new method.
+
+        * fast/eventloop: Added.
+        * fast/eventloop/data-uri-document-has-its-own-event-loop-expected.txt: Added.
+        * fast/eventloop/data-uri-document-has-its-own-event-loop.html: Added.
+        * fast/eventloop/queue-task-across-frames-in-file-uri-expected.txt: Added.
+        * fast/eventloop/queue-task-across-frames-in-file-uri.html: Added.
+        * fast/eventloop/resources: Added.
+        * fast/eventloop/resources/eventloop-helper.html: Added.
+        * http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop-expected.txt: Added.
+        * http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html: Added.
+        * http/tests/eventloop/queue-task-across-cross-site-frames-expected.txt:
+        * http/tests/eventloop/queue-task-across-cross-site-frames.html:
+        * http/tests/eventloop/queue-task-across-frames-expected.txt:
+        * http/tests/eventloop/queue-task-across-frames.html:
+
 2019-12-07  Andres Gonzalez  <[email protected]>
 
         Implementation of additional attribute caching in the IsolatedTree.

Added: trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop-expected.txt (0 => 253265)


--- trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop-expected.txt	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,11 @@
+This tests that each data URI document has its own unique event loop
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSameEventLoopAs(childFrame.contentWindow) is false
+PASS nestedFrameWithDataURLHasSameEventLoopAsParent is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop.html (0 => 253265)


--- trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop.html	                        (rev 0)
+++ trunk/LayoutTests/fast/eventloop/data-uri-document-has-its-own-event-loop.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests that each data URI document has its own unique event loop');
+
+if (!window.internals)
+    testFailed('This test relies on window.internals');
+else {
+    jsTestIsAsync = true;
+
+    childFrame = document.createElement('iframe');
+    document.body.appendChild(childFrame);
+
+    childFrame.src = "" html>
+    <body _onload_="parent.postMessage(internals.hasSameEventLoopAs(nestedFrame.contentWindow), '*')">
+    <iframe id="nestedFrame" src="" html>">`;
+
+    _onmessage_ = (event) => {
+        window.nestedFrameWithDataURLHasSameEventLoopAsParent = event.data;
+        shouldBeFalse('internals.hasSameEventLoopAs(childFrame.contentWindow)');
+        shouldBeFalse('nestedFrameWithDataURLHasSameEventLoopAsParent');
+        finishJSTest();
+    }
+}
+
+successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri-expected.txt (0 => 253265)


--- trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri-expected.txt	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,12 @@
+This tests the order by which tasks are scheduled across documents of file URI documents.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS logs.join(", ") is "1, 2, 3, 4, 5, 6"
+PASS internals.hasSameEventLoopAs(frame1.contentWindow) is true
+PASS internals.hasSameEventLoopAs(frame2.contentWindow) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri.html (0 => 253265)


--- trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri.html	                        (rev 0)
+++ trunk/LayoutTests/fast/eventloop/queue-task-across-frames-in-file-uri.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests the order by which tasks are scheduled across documents of file URI documents.');
+
+if (!window.internals)
+    testFailed('This test relies on window.internals');
+else {
+    jsTestIsAsync = true;
+    logs = [];
+
+    frame1 = document.createElement('iframe');
+    document.body.appendChild(frame1);
+
+    frame2 = document.createElement('iframe');
+    frame2.src = '';
+    frame2.addEventListener('load', runTest);
+    document.body.appendChild(frame2);
+}
+
+function runTest() {
+    internals.queueTask("DOMManipulation", () => logs.push('1'));
+    frame1.contentWindow.internals.queueTask("DOMManipulation", () => logs.push('2'));
+    internals.queueTask("DOMManipulation", () => logs.push('3'));
+    frame2.contentWindow.internals.queueTask("DOMManipulation", () => logs.push('4'));
+    frame1.contentWindow.internals.queueTask("DOMManipulation", () => logs.push('5'));
+    internals.queueTask("DOMManipulation", () => logs.push('6'));
+
+    setTimeout(() => {
+        shouldBeEqualToString('logs.join(", ")', '1, 2, 3, 4, 5, 6');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame1.contentWindow)');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame2.contentWindow)');
+        finishJSTest();
+    }, 100);
+}
+
+successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/fast/eventloop/resources/eventloop-helper.html (0 => 253265)


--- trunk/LayoutTests/fast/eventloop/resources/eventloop-helper.html	                        (rev 0)
+++ trunk/LayoutTests/fast/eventloop/resources/eventloop-helper.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<!-- This document is empty for now -->
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop-expected.txt (0 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop-expected.txt	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,11 @@
+This tests the order by which tasks are scheduled across documents that are not similar origins.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.hasSameEventLoopAs(frame1.contentWindow) is true
+PASS internals.hasSameEventLoopAs(frame2.contentWindow) is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html (0 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -0,0 +1,60 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+
+description('This tests the order by which tasks are scheduled across documents that are not similar origins.');
+
+if (!window.internals)
+    testFailed('This test relies on window.internals');
+else {
+    jsTestIsAsync = true;
+    window._onload_ = startTest;
+}
+
+logs = [];
+crossOriginLogs = [];
+
+async function startTest()
+{
+    window.frame1 = document.createElement('iframe');
+    frame1.src = '';
+    document.body.appendChild(frame1);
+
+    window.frame2 = document.createElement('iframe');
+    frame2.src = '';
+    document.body.appendChild(frame2);
+
+    await waitForLoad(frame1);
+    await waitForLoad(frame2);
+
+    shouldBeTrue('internals.hasSameEventLoopAs(frame1.contentWindow)');
+    shouldBeFalse('internals.hasSameEventLoopAs(frame2.contentWindow)');
+    finishJSTest();
+}
+
+const loadedFrames = new Map;
+_onmessage_ = (event) => {
+    if (event.data.type == 'load') {
+        const resolve = loadedFrames.get(event.source);
+        if (resolve)
+            resolve();
+        else
+            loadedFrames.set(event.source, null);
+    }
+}
+
+function waitForLoad(frame)
+{
+    if (loadedFrames.has(frame.contentWindow))
+        return Promise.resolve();
+    return new Promise((resolve) => loadedFrames.set(frame.contentWindow, resolve));
+}
+
+successfullyParsed = true;
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames-expected.txt (253264 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames-expected.txt	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames-expected.txt	2019-12-08 00:41:03 UTC (rev 253265)
@@ -5,6 +5,10 @@
 
 PASS logs.join(", ") is "1, 2, 3, 4, 5"
 PASS crossOriginLogs.join(", ") is "10, 11, 12"
+PASS internals.hasSameEventLoopAs(frame1.contentWindow) is true
+PASS internals.hasSameEventLoopAs(frame2.contentWindow) is false
+PASS internals.hasSameEventLoopAs(frame3.contentWindow) is true
+PASS internals.hasSameEventLoopAs(frame4.contentWindow) is false
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames.html (253264 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames.html	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/LayoutTests/http/tests/eventloop/queue-task-across-cross-site-frames.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -18,19 +18,19 @@
 
 async function startTest()
 {
-    const frame1 = document.createElement('iframe');
+    window.frame1 = document.createElement('iframe');
     document.body.appendChild(frame1);
 
-    const frame2 = document.createElement('iframe');
+    window.frame2 = document.createElement('iframe');
     frame2.name = 'frame2';
     frame2.src = '';
     document.body.appendChild(frame2);
 
-    const frame3 = document.createElement('iframe');
+    window.frame3 = document.createElement('iframe');
     frame3.src = '';
     document.body.appendChild(frame3);
 
-    const frame4 = document.createElement('iframe');
+    window.frame4 = document.createElement('iframe');
     frame4.name = 'frame4';
     frame4.src = '';
 
@@ -57,6 +57,10 @@
     setTimeout(() => {
         shouldBeEqualToString('logs.join(", ")', '1, 2, 3, 4, 5');
         shouldBeEqualToString('crossOriginLogs.join(", ")', '10, 11, 12');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame1.contentWindow)');
+        shouldBeFalse('internals.hasSameEventLoopAs(frame2.contentWindow)');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame3.contentWindow)');
+        shouldBeFalse('internals.hasSameEventLoopAs(frame4.contentWindow)');
         finishJSTest();
     }, 100);
 }

Modified: trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames-expected.txt (253264 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames-expected.txt	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames-expected.txt	2019-12-08 00:41:03 UTC (rev 253265)
@@ -4,6 +4,8 @@
 
 
 PASS logs.join(", ") is "1, 2, 3, 4, 5, 6"
+PASS internals.hasSameEventLoopAs(frame1.contentWindow) is true
+PASS internals.hasSameEventLoopAs(frame2.contentWindow) is true
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames.html (253264 => 253265)


--- trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames.html	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/LayoutTests/http/tests/eventloop/queue-task-across-frames.html	2019-12-08 00:41:03 UTC (rev 253265)
@@ -31,6 +31,8 @@
 
     setTimeout(() => {
         shouldBeEqualToString('logs.join(", ")', '1, 2, 3, 4, 5, 6');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame1.contentWindow)');
+        shouldBeTrue('internals.hasSameEventLoopAs(frame2.contentWindow)');
         finishJSTest();
     }, 100);
 }

Modified: trunk/Source/WebCore/ChangeLog (253264 => 253265)


--- trunk/Source/WebCore/ChangeLog	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/ChangeLog	2019-12-08 00:41:03 UTC (rev 253265)
@@ -1,3 +1,37 @@
+2019-12-07  Ryosuke Niwa  <[email protected]>
+
+        Unique origin's window must get its own event loop
+        https://bugs.webkit.org/show_bug.cgi?id=204978
+
+        Reviewed by Antti Koivisto.
+
+        This patch fixes the bug that unique origin documents and documents of the same registrable domains
+        with different schemes / protocols were sharing the same event loop. Note that we continue to share
+        the event loop across file URI documents.
+
+        We now use the agent cluster key to looking up the event loop to better match the HTML5 spec:
+        https://html.spec.whatwg.org/multipage/webappapis.html#obtain-agent-cluster-key
+
+        Tests: fast/eventloop/data-uri-document-has-its-own-event-loop.html
+               fast/eventloop/queue-task-across-frames-in-file-uri.html
+               http/tests/eventloop/documents-with-different-protocols-do-not-share-event-loop.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::eventLoop):
+        * dom/EventLoop.h:
+        (WebCore::EventLoopTaskGroup::hasSameEventLoopAs): Added for testing purposes.
+        * dom/WindowEventLoop.cpp:
+        (WebCore::agentClusterKeyOrNullIfUnique): Added.
+        (WebCore::WindowEventLoop::eventLoopForSecurityOrigin): Replaced ensureForRegistrableDomain.
+        (WebCore::WindowEventLoop::create): Added.
+        (WebCore::WindowEventLoop::WindowEventLoop):
+        (WebCore::WindowEventLoop::~WindowEventLoop):
+        * dom/WindowEventLoop.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::hasSameEventLoopAs): Added for testing purposes.
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-12-07  Zalan Bujtas  <[email protected]>
 
         [LFC][IFC] Display::LineBox should adopt to InlineLayoutUnit

Modified: trunk/Source/WebCore/dom/Document.cpp (253264 => 253265)


--- trunk/Source/WebCore/dom/Document.cpp	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-12-08 00:41:03 UTC (rev 253265)
@@ -6263,7 +6263,8 @@
 {
     ASSERT(isMainThread());
     if (UNLIKELY(!m_documentTaskGroup)) {
-        m_eventLoop = WindowEventLoop::ensureForRegistrableDomain(RegistrableDomain { securityOrigin().data() });
+        // https://html.spec.whatwg.org/multipage/webappapis.html#obtain-agent-cluster-key
+        m_eventLoop = WindowEventLoop::eventLoopForSecurityOrigin(securityOrigin());
         m_documentTaskGroup = makeUnique<EventLoopTaskGroup>(*m_eventLoop);
         if (activeDOMObjectsAreStopped())
             m_documentTaskGroup->stopAndDiscardAllTasks();

Modified: trunk/Source/WebCore/dom/EventLoop.h (253264 => 253265)


--- trunk/Source/WebCore/dom/EventLoop.h	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/dom/EventLoop.h	2019-12-08 00:41:03 UTC (rev 253265)
@@ -105,6 +105,12 @@
     {
     }
 
+    bool hasSameEventLoopAs(EventLoopTaskGroup& otherGroup)
+    {
+        ASSERT(m_eventLoop);
+        return m_eventLoop == otherGroup.m_eventLoop;
+    }
+
     bool matchesTask(EventLoopTask& task) const
     {
         auto* group = task.group();

Modified: trunk/Source/WebCore/dom/WindowEventLoop.cpp (253264 => 253265)


--- trunk/Source/WebCore/dom/WindowEventLoop.cpp	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/dom/WindowEventLoop.cpp	2019-12-08 00:41:03 UTC (rev 253265)
@@ -32,18 +32,39 @@
 
 namespace WebCore {
 
-static HashMap<RegistrableDomain, WindowEventLoop*>& windowEventLoopMap()
+static HashMap<String, WindowEventLoop*>& windowEventLoopMap()
 {
     RELEASE_ASSERT(isMainThread());
-    static NeverDestroyed<HashMap<RegistrableDomain, WindowEventLoop*>> map;
+    static NeverDestroyed<HashMap<String, WindowEventLoop*>> map;
     return map.get();
 }
 
-Ref<WindowEventLoop> WindowEventLoop::ensureForRegistrableDomain(const RegistrableDomain& domain)
+static String agentClusterKeyOrNullIfUnique(const SecurityOrigin& origin)
 {
-    auto addResult = windowEventLoopMap().add(domain, nullptr);
+    auto computeKey = [&] {
+        // https://html.spec.whatwg.org/multipage/webappapis.html#obtain-agent-cluster-key
+        if (origin.isUnique())
+            return origin.toString();
+        RegistrableDomain registrableDomain { origin.data() };
+        if (registrableDomain.isEmpty())
+            return origin.toString();
+        return makeString(origin.protocol(), "://", registrableDomain.string());
+    };
+    auto key = computeKey();
+    if (key.isEmpty() || key == "null"_s)
+        return { };
+    return key;
+}
+
+Ref<WindowEventLoop> WindowEventLoop::eventLoopForSecurityOrigin(const SecurityOrigin& origin)
+{
+    auto key = agentClusterKeyOrNullIfUnique(origin);
+    if (key.isNull())
+        return create({ });
+
+    auto addResult = windowEventLoopMap().add(key, nullptr);
     if (UNLIKELY(addResult.isNewEntry)) {
-        auto newEventLoop = adoptRef(*new WindowEventLoop(domain));
+        auto newEventLoop = create(key);
         addResult.iterator->value = newEventLoop.ptr();
         return newEventLoop;
     }
@@ -50,8 +71,13 @@
     return *addResult.iterator->value;
 }
 
-inline WindowEventLoop::WindowEventLoop(const RegistrableDomain& domain)
-    : m_domain(domain)
+inline Ref<WindowEventLoop> WindowEventLoop::create(const String& agentClusterKey)
+{
+    return adoptRef(*new WindowEventLoop(agentClusterKey));
+}
+
+inline WindowEventLoop::WindowEventLoop(const String& agentClusterKey)
+    : m_agentClusterKey(agentClusterKey)
     , m_timer(*this, &WindowEventLoop::run)
 {
 }
@@ -58,7 +84,9 @@
 
 WindowEventLoop::~WindowEventLoop()
 {
-    auto didRemove = windowEventLoopMap().remove(m_domain);
+    if (m_agentClusterKey.isNull())
+        return;
+    auto didRemove = windowEventLoopMap().remove(m_agentClusterKey);
     RELEASE_ASSERT(didRemove);
 }
 

Modified: trunk/Source/WebCore/dom/WindowEventLoop.h (253264 => 253265)


--- trunk/Source/WebCore/dom/WindowEventLoop.h	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/dom/WindowEventLoop.h	2019-12-08 00:41:03 UTC (rev 253265)
@@ -27,9 +27,9 @@
 
 #include "DocumentIdentifier.h"
 #include "EventLoop.h"
-#include "RegistrableDomain.h"
 #include "Timer.h"
 #include <wtf/HashSet.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -38,18 +38,19 @@
 // https://html.spec.whatwg.org/multipage/webappapis.html#window-event-loop
 class WindowEventLoop final : public EventLoop {
 public:
-    static Ref<WindowEventLoop> ensureForRegistrableDomain(const RegistrableDomain&);
+    static Ref<WindowEventLoop> eventLoopForSecurityOrigin(const SecurityOrigin&);
 
     virtual ~WindowEventLoop();
 
 private:
-    WindowEventLoop(const RegistrableDomain&);
+    static Ref<WindowEventLoop> create(const String&);
+    WindowEventLoop(const String&);
 
     void scheduleToRun() final;
     bool isContextThread() const final;
     MicrotaskQueue& microtaskQueue() final;
 
-    RegistrableDomain m_domain;
+    String m_agentClusterKey;
     Timer m_timer;
 };
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (253264 => 253265)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-12-08 00:41:03 UTC (rev 253265)
@@ -4690,6 +4690,22 @@
     return { };
 }
 
+ExceptionOr<bool> Internals::hasSameEventLoopAs(WindowProxy& proxy)
+{
+    RefPtr<ScriptExecutionContext> context = contextDocument();
+    if (!context || !proxy.frame())
+        return Exception { InvalidStateError };
+
+    auto& proxyFrame = *proxy.frame();
+    if (!is<Frame>(proxyFrame))
+        return false;
+    RefPtr<ScriptExecutionContext> proxyContext = downcast<Frame>(proxyFrame).document();
+    if (!proxyContext)
+        return Exception { InvalidStateError };
+
+    return context->eventLoop().hasSameEventLoopAs(proxyContext->eventLoop());
+}
+
 Vector<String> Internals::accessKeyModifiers() const
 {
     Vector<String> accessKeyModifierStrings;

Modified: trunk/Source/WebCore/testing/Internals.h (253264 => 253265)


--- trunk/Source/WebCore/testing/Internals.h	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/testing/Internals.h	2019-12-08 00:41:03 UTC (rev 253265)
@@ -780,6 +780,8 @@
     void postTask(RefPtr<VoidCallback>&&);
     ExceptionOr<void> queueTask(ScriptExecutionContext&, const String& source, RefPtr<VoidCallback>&&);
     ExceptionOr<void> queueTaskToQueueMicrotask(Document&, const String& source, RefPtr<VoidCallback>&&);
+    ExceptionOr<bool> hasSameEventLoopAs(WindowProxy&);
+
     void markContextAsInsecure();
 
     bool usingAppleInternalSDK() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (253264 => 253265)


--- trunk/Source/WebCore/testing/Internals.idl	2019-12-07 22:57:17 UTC (rev 253264)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-12-08 00:41:03 UTC (rev 253265)
@@ -767,6 +767,8 @@
     void postTask(VoidCallback callback);
     [CallWith=ScriptExecutionContext, MayThrowException] void queueTask(DOMString source, VoidCallback callback);
     [CallWith=Document] void queueTaskToQueueMicrotask(DOMString source, VoidCallback callback);
+    [MayThrowException] boolean hasSameEventLoopAs(WindowProxy windowProxy);
+
     void markContextAsInsecure();
 
     void setMaxCanvasPixelMemory(unsigned long size);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to