Bug 30469

Summary: We should not bubble up events if we drag something to an iframe that has an invalid source
Product: WebKit Reporter: Jian Li <jianli>
Component: WebCore JavaScriptAssignee: Jian Li <jianli>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Proposed Patch
eric: review-, jianli: commit-queue-
Proposed Patch
dimich: review-, jianli: commit-queue-
Proposed Patch dimich: review+, jianli: commit-queue-

Jian Li
Reported 2009-10-16 17:29:38 PDT
We should not bubble up events if we drag something to an iframe that has an invalid source. FF/IE does not do this and we should mimic the behavior.
Attachments
Proposed Patch (8.22 KB, patch)
2009-10-16 17:36 PDT, Jian Li
eric: review-
jianli: commit-queue-
Proposed Patch (10.79 KB, patch)
2009-10-20 15:54 PDT, Jian Li
dimich: review-
jianli: commit-queue-
Proposed Patch (11.07 KB, patch)
2009-11-04 11:11 PST, Jian Li
dimich: review+
jianli: commit-queue-
Jian Li
Comment 1 2009-10-16 17:36:40 PDT
Created attachment 41343 [details] Proposed Patch
Eric Seidel (no email)
Comment 2 2009-10-19 13:49:52 PDT
Comment on attachment 41343 [details] Proposed Patch Do we have a test which covers the case of a valid source bubbling correctly? This looks like copy-paste code which should be replaced by a static function, no?
Jian Li
Comment 3 2009-10-20 15:54:10 PDT
Created attachment 41531 [details] Proposed Patch Added the test script to cover the case of valid source bubbling. Also introduce a helper function to replace the similar code.
Dmitry Titov
Comment 4 2009-10-30 14:01:33 PDT
Comment on attachment 41531 [details] Proposed Patch Almost there. > diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog > + Tests that we don't bubble up the events if we drag something to an > + iframe that has an invalid source. Now that you have a test that verifies both bubbling with valid and invalid targets, this description could change to reflect this. > + * http/tests/misc/drag-over-iframe-invalid-source-does-not-bubble-expected.txt: Added. > + * http/tests/misc/drag-over-iframe-invalid-source-does-not-bubble.html: Added. I guess the test name could now also be different. Perhaps "bubble-drag-events-from-iframe.html"? > diff --git a/LayoutTests/http/tests/misc/drag-over-iframe-invalid-source-does-not-bubble.html b/LayoutTests/http/tests/misc/drag-over-iframe-invalid-source-does-not-bubble.html > +function log(msg) > +{ > + document.getElementById("log").appendChild(document.createTextNode(msg + "\n")); > +} Mix of styles - opening '{' of a functions follows different style through the file. Need to stick to one style. > + testDragEventBubbling("dragTargetParent", "dragTarget"); > + > + log("Tests that we bubble up the events if we drag something to a valid source"); > + testDragEventBubbling("dragTargetParent2", "dragTarget2"); Perhaps better names for valid/invalid targets could be validDragTarget/validDragTargetParent and invalidDragTarget/invalidDragTartgetParent? > + > +<div id="dragTargetParent"> > +<iframe id="dragTarget" src="file:"></iframe> > +</div> > +<div contentEditable id="dragTargetParent2"> > +<span id="dragTarget2">Drag here.</span> > +</div> In one case it is iframe and in another a span. Should it be both iframes, one with valid url and another with invalid one? This way, only one variable would change. > diff --git a/WebCore/page/EventHandler.cpp b/WebCore/page/EventHandler.cpp > +bool EventHandler::handleDragAndDropForTarget(DragAndDropHandleType type, Node* target, const AtomicString& eventType, const PlatformMouseEvent& event, Clipboard* clipboard) > + default: > + ASSERT(false); > + break; The 'default' can be removed. Now it can not be hit and if someone adds more values to the enum, gcc will issue a warning in compile time, but if there is 'default' it won't. r- because it seems the valid target in the test should also be iframe.
Jian Li
Comment 5 2009-11-04 11:11:20 PST
Created attachment 42498 [details] Proposed Patch All fixed.
Dmitry Titov
Comment 6 2009-11-04 16:11:36 PST
Comment on attachment 42498 [details] Proposed Patch r=me
Jian Li
Comment 7 2009-11-05 10:06:30 PST
Note You need to log in before you can comment on or make changes to this bug.