haikuwebkit/LayoutTests/fast/eventloop/data-uri-document-has-its-o...

35 lines
1015 B
HTML
Raw Permalink Normal View History

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: Canonical link: https://commits.webkit.org/218212@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@253265 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2019-12-08 00:41:03 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<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 = `data:text/html,<!DOCTYPE html>
<body onload="parent.postMessage(internals.hasSameEventLoopAs(nestedFrame.contentWindow), '*')">
<iframe id="nestedFrame" src="data:text/html,<!DOCTYPE html>">`;
onmessage = (event) => {
window.nestedFrameWithDataURLHasSameEventLoopAsParent = event.data;
shouldBeFalse('internals.hasSameEventLoopAs(childFrame.contentWindow)');
shouldBeFalse('nestedFrameWithDataURLHasSameEventLoopAsParent');
finishJSTest();
}
}
successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>