haikuwebkit/LayoutTests/fast/eventloop/queue-task-across-frames-in...

46 lines
1.4 KiB
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 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 = 'resources/eventloop-helper.html';
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="../../resources/js-test-post.js"></script>
</body>
</html>