haikuwebkit/LayoutTests/fast/events/drag-and-drop-link-fast-mul...

90 lines
2.1 KiB
HTML
Raw Permalink Normal View History

[GTK] WebProcess crashes when quickly attempting many DnD operations https://bugs.webkit.org/show_bug.cgi?id=138468 Reviewed by Michael Catanzaro. Source/WebKit2: Do not allow different DnD operations over the same element at the same time, so that any new attempt to DnD an element happening before a previous attempt has ended will take precedence, cancelling the older operation before going ahead with the new one. This is consistent with how WebCore::EventHandler handles DnD operations, preventing the web process from crashing in scenarios where the user might try to perform many DnD operations over the same element very quickly. * UIProcess/gtk/DragAndDropHandler.cpp: (WebKit::DragAndDropHandler::DragAndDropHandler): Initialized new member. (WebKit::DragAndDropHandler::startDrag): Ensure a previous DnD operation is cancelled before handling the new one that has just started. (WebKit::DragAndDropHandler::fillDragData): Protect against calling this function from webkitWebViewBaseDragDataGet for already cancelled operations. (WebKit::DragAndDropHandler::finishDrag): Protect against calling this function from webkitWebViewBaseDragEnd for already cancelled operations. * UIProcess/gtk/DragAndDropHandler.h: LayoutTests: New test added to check that the web process does not crash when multiple DnD operations are quickly attempted over the same draggable element. * fast/events/drag-and-drop-link-fast-multiple-times-does-not-crash-expected.txt: Added. * fast/events/drag-and-drop-link-fast-multiple-times-does-not-crash.html: Added. Added the new test to the failure expectations for mac-wk2, as there's no suitable implementation of eventSender in place yet (see bug 42194). * platform/mac-wk2/TestExpectations: Added failure expectation for the new test. Canonical link: https://commits.webkit.org/171540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-26 09:45:51 +00:00
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;
var htmlHyperlink;
var dragBeginPositionX;
var dragBeginPositionY;
var dragEndPositionX;
var dragEndPositionY;
var dragHasStarted = false;
var dragHasEnded = false;
var maxNumberOfRuns = 20;
var currentRun = 0;
function finishTest()
{
debug("<br>");
shouldBeTrue("dragHasStarted");
shouldBeTrue("dragHasEnded");
finishJSTest();
}
function dragStart(e) {
dragHasStarted = true;
}
function dragEnd(e) {
dragHasEnded = true;
if (currentRun < maxNumberOfRuns)
return;
window.setTimeout(finishTest, 0);
}
function dragAndDrop(beginX, beginY, endX, endY)
{
if (!window.eventSender)
return;
eventSender.mouseMoveTo(beginX, beginY);
eventSender.mouseDown();
eventSender.leapForward(100);
eventSender.mouseMoveTo(endX, endY);
eventSender.mouseUp();
}
function runNextStep()
{
if (currentRun++ >= maxNumberOfRuns)
return;
debug("Dragging HTML hyperlink around. Attempt #" + currentRun);
dragAndDrop(dragBeginPositionX, dragBeginPositionY, dragEndPositionX, dragEndPositionY);
window.setTimeout(runNextStep, 0);
}
function runTest()
{
if (!window.testRunner)
return;
htmlHyperlink = document.getElementById("htmlHyperlink");
htmlHyperlink.ondragstart = dragStart;
htmlHyperlink.ondragend = dragEnd;
dragBeginPositionX = htmlHyperlink.offsetLeft + htmlHyperlink.offsetWidth / 2;
dragBeginPositionY = htmlHyperlink.offsetTop + htmlHyperlink.offsetHeight / 2;
dragEndPositionX = dragBeginPositionX + htmlHyperlink.offsetWidth + 50;
dragEndPositionY = dragBeginPositionY + htmlHyperlink.offsetHeight + 50;
runNextStep();
}
</script>
</head>
<body onload="runTest()">
<p>
<a id="htmlHyperlink" href="http://www.whatwg.org/html">HTML hyperlink</a>
<p>
<div id="console"></div>
<script>
description("This test checks that quickly attempting a drag'n'drop operation multiple times over the same element does not crash the web process.");
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>