Diff
Modified: trunk/LayoutTests/ChangeLog (112953 => 112954)
--- trunk/LayoutTests/ChangeLog 2012-04-02 22:31:07 UTC (rev 112953)
+++ trunk/LayoutTests/ChangeLog 2012-04-02 22:33:42 UTC (rev 112954)
@@ -1,3 +1,16 @@
+2012-04-02 Daniel Cheng <[email protected]>
+
+ 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-02 Stephen Chenney <[email protected]>
[Chromium] Flaky SVG tests on MacOS 10.6
Modified: trunk/LayoutTests/fast/events/drag-dataTransferItemList.html (112953 => 112954)
--- trunk/LayoutTests/fast/events/drag-dataTransferItemList.html 2012-04-02 22:31:07 UTC (rev 112953)
+++ trunk/LayoutTests/fast/events/drag-dataTransferItemList.html 2012-04-02 22:33:42 UTC (rev 112954)
@@ -131,6 +131,7 @@
legacyDrop(event.dataTransfer);
else if (dropMethod.selectedIndex == 1)
itemListDrop(event.dataTransfer);
+ event.preventDefault();
}
function runTest(dragMethodIndex, dropMethodIndex)
Added: trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate-expected.txt (0 => 112954)
--- trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate-expected.txt 2012-04-02 22:33:42 UTC (rev 112954)
@@ -0,0 +1,7 @@
+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
+Cancelling dragenter
+Cancelling dragover
+Not preventing default event on drop.
+PASS
Property changes on: trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate.html (0 => 112954)
--- trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate.html (rev 0)
+++ trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate.html 2012-04-02 22:33:42 UTC (rev 112954)
@@ -0,0 +1,45 @@
+<!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)));
+}
+if (!window.layoutTestController)
+ return;
+window.addEventListener('beforeunload', function ()
+{
+ log('PASS');
+ layoutTestController.notifyDone();
+});
+document.body.addEventListener('dragenter', function (event)
+{
+ log('Cancelling dragenter');
+ event.preventDefault();
+});
+document.body.addEventListener('dragover', function (event)
+{
+ log('Cancelling dragover');
+ event.preventDefault();
+});
+document.body.addEventListener('drop', function (event)
+{
+ log('Not preventing default event on drop.');
+});
+layoutTestController.dumpAsText();
+layoutTestController.waitUntilDone();
+log('Starting test');
+eventSender.beginDragWithFiles(['DRTFakeFile']);
+eventSender.mouseMoveTo(document.body.offsetLeft + 10, document.body.offsetTop + 10);
+eventSender.mouseUp();
+log('FAIL');
+layoutTestController.notifyDone();
+</script>
+</body>
+</html>
Property changes on: trunk/LayoutTests/fast/events/drop-handler-should-not-stop-navigate.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/LayoutTests/http/tests/security/clipboard/clipboard-file-access.html (112953 => 112954)
--- trunk/LayoutTests/http/tests/security/clipboard/clipboard-file-access.html 2012-04-02 22:31:07 UTC (rev 112953)
+++ trunk/LayoutTests/http/tests/security/clipboard/clipboard-file-access.html 2012-04-02 22:33:42 UTC (rev 112954)
@@ -55,7 +55,7 @@
// 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();
});
Modified: trunk/Source/WebCore/ChangeLog (112953 => 112954)
--- trunk/Source/WebCore/ChangeLog 2012-04-02 22:31:07 UTC (rev 112953)
+++ trunk/Source/WebCore/ChangeLog 2012-04-02 22:33:42 UTC (rev 112954)
@@ -1,3 +1,17 @@
+2012-04-02 Daniel Cheng <[email protected]>
+
+ 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.
+
+ Test: fast/events/drop-handler-should-not-stop-navigate.html
+
+ * page/DragController.cpp:
+ (WebCore::DragController::performDrag):
+
2012-04-02 Alexis Menard <[email protected]>
We should use CSSPropertyID rather than integers when manipulating CSS property ids.
Modified: trunk/Source/WebCore/page/DragController.cpp (112953 => 112954)
--- trunk/Source/WebCore/page/DragController.cpp 2012-04-02 22:31:07 UTC (rev 112953)
+++ trunk/Source/WebCore/page/DragController.cpp 2012-04-02 22:33:42 UTC (rev 112954)
@@ -212,7 +212,7 @@
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;
}