https://bugs.webkit.org/show_bug.cgi?id=79172
Reviewed by Ryosuke Niwa.
Source/WebCore:
Only early return if the drop handler prevents the default action.
http://trac.webkit.org/changeset/105396 introduced this issue when fixing some other aspects
of DnD handling.
Test: fast/events/drop-handler-should-not-stop-navigate.html
* page/DragController.cpp:
(WebCore::DragController::performDrag):
(WebCore::DragController::concludeEditDrag): Remove the assert. By definition, we want to
allow default actions to run now if they weren't explicitly canceled.
LayoutTests:
* fast/events/drag-dataTransferItemList.html: Fix drop handler to prevent default.
* fast/events/drop-handler-should-not-stop-navigate-expected.txt: Added.
* fast/events/drop-handler-should-not-stop-navigate.html: Added.
* http/tests/security/clipboard/clipboard-file-access.html: Change dragover to drop handler
to prevent bubbled events from causing navigation.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113088
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-03 Daniel Cheng <dcheng@chromium.org>
+
+ Having a drop handler prevents navigation on drop even if event is not cancelled
+ https://bugs.webkit.org/show_bug.cgi?id=79172
+
+ Reviewed by Ryosuke Niwa.
+
+ * fast/events/drag-dataTransferItemList.html: Fix drop handler to prevent default.
+ * fast/events/drop-handler-should-not-stop-navigate-expected.txt: Added.
+ * fast/events/drop-handler-should-not-stop-navigate.html: Added.
+ * http/tests/security/clipboard/clipboard-file-access.html: Change dragover to drop handler
+ to prevent bubbled events from causing navigation.
+
2012-04-03 Erik Arvidsson <arv@chromium.org>
[v8] Fix memory leak in V8LazyEventListener
legacyDrop(event.dataTransfer);
else if (dropMethod.selectedIndex == 1)
itemListDrop(event.dataTransfer);
+ event.preventDefault();
}
function runTest(dragMethodIndex, dropMethodIndex)
--- /dev/null
+This tests that a drop handler's default action must be prevented in order to stop navigation. Otherwise, if event.preventDefault() is not called, navigation should occur. To test manually, simply drag and drop another link or HTML file on this page. If navigation occurs, then the test passed.
+
+Starting test
+Not preventing default event on drop.
+PASS
--- /dev/null
+<!DOCTYPE html>
+<html>
+<body>
+<div>This tests that a drop handler's default action must be prevented in order to stop navigation.
+Otherwise, if event.preventDefault() is not called, navigation should occur. To test manually,
+simply drag and drop another link or HTML file on this page. If navigation occurs, then the test
+passed.</div>
+<script>
+function log(text)
+{
+ document.body.appendChild(document.createElement('br'));
+ document.body.appendChild(document.createElement('div').appendChild(document.createTextNode(text)));
+}
+window.addEventListener('beforeunload', function ()
+{
+ log('PASS');
+ layoutTestController.notifyDone();
+});
+document.body.addEventListener('dragenter', function (event)
+{
+ event.preventDefault();
+});
+document.body.addEventListener('dragover', function (event)
+{
+ event.preventDefault();
+});
+document.body.addEventListener('drop', function (event)
+{
+ log('Not preventing default event on drop.');
+});
+(function ()
+{
+ if (!window.layoutTestController)
+ return;
+ layoutTestController.dumpAsText();
+ layoutTestController.waitUntilDone();
+ log('Starting test');
+ eventSender.beginDragWithFiles(['DRTFakeFile']);
+ eventSender.mouseMoveTo(document.body.offsetLeft + 10, document.body.offsetTop + 10);
+ eventSender.mouseUp();
+ window.setTimeout(function ()
+ {
+ // Deadman's switch so we don't need to wait for the test to timeout to fail.
+ log('FAIL');
+ layoutTestController.notifyDone();
+ }, 0);
+})();
+</script>
+</body>
+</html>
// Some tests don't end up dropping the draggee over the drag target. Catch any
// leftover drop events bubbling up through the tree so they don't cause page
// navigation.
-document.body.addEventListener("dragover", function() {
+document.body.addEventListener("drop", function() {
event.preventDefault();
});
+2012-04-03 Daniel Cheng <dcheng@chromium.org>
+
+ Having a drop handler prevents navigation on drop even if event is not cancelled
+ https://bugs.webkit.org/show_bug.cgi?id=79172
+
+ Reviewed by Ryosuke Niwa.
+
+ Only early return if the drop handler prevents the default action.
+ http://trac.webkit.org/changeset/105396 introduced this issue when fixing some other aspects
+ of DnD handling.
+
+ Test: fast/events/drop-handler-should-not-stop-navigate.html
+
+ * page/DragController.cpp:
+ (WebCore::DragController::performDrag):
+ (WebCore::DragController::concludeEditDrag): Remove the assert. By definition, we want to
+ allow default actions to run now if they weren't explicitly canceled.
+
2012-04-03 Erik Arvidsson <arv@chromium.org>
[v8] Fix memory leak in V8LazyEventListener
preventedDefault = mainFrame->eventHandler()->performDragAndDrop(createMouseEvent(dragData), clipboard.get());
clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard here for security
}
- if (m_isHandlingDrag || preventedDefault) {
+ if (preventedDefault) {
m_documentUnderMouse = 0;
return true;
}
bool DragController::concludeEditDrag(DragData* dragData)
{
ASSERT(dragData);
- ASSERT(!m_isHandlingDrag);
RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse;
if (m_fileInputElementUnderMouse) {