<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>58206</bug_id>
          
          <creation_ts>2011-04-10 10:46:52 -0700</creation_ts>
          <short_desc>[Qt] HTML5 drag and drop not working when getData is used</short_desc>
          <delta_ts>2014-02-03 03:17:30 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit Misc.</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt, QtTriaged</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>56486</dependson>
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Aparna Nandyal">aparna.nand</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cricri.bug</cc>
    
    <cc>dtrebbien</cc>
    
    <cc>eric</cc>
    
    <cc>ossy</cc>
    
    <cc>rhemalinder</cc>
    
    <cc>robertc</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>382908</commentid>
    <comment_count>0</comment_count>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-04-10 10:46:52 -0700</bug_when>
    <thetext>Steps to reproduce the problem:

1. Open QtTestBrowser or any other simple app that with QWebView 
2. Load http://ljouanneau.com/lab/html5/demodragdrop.html. This page has HTML5 drag and drop.
3. Perform the operations in the page as illustrated - that is drag boxes. 

Expected result: 
Dragging and dropping of boxes is possible as illustrated in the page

Actual result:
Unable to drag the content

Other information:
https://bugs.webkit.org/show_bug.cgi?id=56486 has been raised for a similar issue but the problem with other websites mentioned in 56486 is different from this bug, hence raising another bug for this as discussed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>382910</commentid>
    <comment_count>1</comment_count>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-04-10 10:59:50 -0700</bug_when>
    <thetext>Analysis:
It is found that the value returned by getData in the following script in wrong:


function dragOver(ev) {
    var idelt = ev.dataTransfer.getData(&quot;Text&quot;);
    var id = ev.target.getAttribute(&apos;id&apos;);
    if( (id ==&apos;boxB&apos; || id ==&apos;boxA&apos;) &amp;&amp; (idelt == &apos;drag&apos; || idelt==&apos;drag2&apos;))
        return false;
    else if( id ==&apos;boxC&apos; &amp;&amp; idelt == &apos;drag3&apos;)
        return false;
    else
        return true;
}

idelt is always undefined. On the other hand if the same web page (http://ljouanneau.com/lab/html5/demodragdrop.html) is downloaded and saved as html and opened through the QtTestBrowser, it works fine. 

Problem in the code:
String ClipboardQt::getData(const String&amp; type, bool&amp; success) const
{

    if (policy() != ClipboardReadable) {
        success = false;
        return String();
    }

    ....
}

The policy value is set as ClipboardTypesReadable in this case hence empty string is returned. The policy value is set in DragController::tryDHTMLDrag. If the URL is local, then clipboardReadable is set (which is why it works when the same html page is saved locally and then loaded in QtTestBrowser) else clipboardTypesReadable is set. 


Additional information: To get this fix working, patch in https://bugs.webkit.org/show_bug.cgi?id=56486 is a required (which is to get generic HTML5 drag and drop to work)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>382912</commentid>
    <comment_count>2</comment_count>
      <attachid>88954</attachid>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-04-10 11:11:34 -0700</bug_when>
    <thetext>Created attachment 88954
Patch for review

getData JavaScript API is an important integral part of HTML5 D&amp;D usage which is always returning an undefined value in this case. Fix rectifies this problem.

Existing test cases cover D&amp;D. DRT does not support D&amp;D yet. Also this case is reproducible for pages online only.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>382944</commentid>
    <comment_count>3</comment_count>
      <attachid>88954</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2011-04-10 15:40:34 -0700</bug_when>
    <thetext>Comment on attachment 88954
Patch for review

How do we test this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>383103</commentid>
    <comment_count>4</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2011-04-11 04:57:45 -0700</bug_when>
    <thetext>(In reply to comment #3)
&gt; (From update of attachment 88954 [details])
&gt; How do we test this?

That is quite a problem. I looked at testing drag-and-drop last week and we have big issue because of the way Qt handle drag and drop.

Currently, we do not run the layout tests. :(</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>383134</commentid>
    <comment_count>5</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2011-04-11 06:17:34 -0700</bug_when>
    <thetext>In general things which aren&apos;t tested are broken.  So I think it is probably more worth your time to fix the drag and drop testing on Qt... then at least you&apos;ll know what&apos;s broken there in comparison to other ports. :)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>393165</commentid>
    <comment_count>6</comment_count>
      <attachid>88954</attachid>
    <who name="Andreas Kling">kling</who>
    <bug_when>2011-04-26 17:17:45 -0700</bug_when>
    <thetext>Comment on attachment 88954
Patch for review

Just tested this on Safari and Chromium, and the test doesn&apos;t work on either of them. We should not be adding different behavior for QtWebKit.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>396253</commentid>
    <comment_count>7</comment_count>
    <who name="Aparna Nandyal">aparna.nand</who>
    <bug_when>2011-05-01 23:19:52 -0700</bug_when>
    <thetext>This is broken on all the ports because, we dont allow getData to be called when drag start or drag over is happening. This is for security reason, that getData can be accessed only during drop event and not before that. This so, because when you are dragging data across documents on your desktop, you do not want getData to be called by intermittent document which is not suppose to have access to data. The real solution to this problem would be to check if the dragging is happening within the same document (if within same domain), then getData can be accessed in drag enter and drag over event too. This is the implementation in other browsers like firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>488973</commentid>
    <comment_count>8</comment_count>
    <who name="Rhema">rhemalinder</who>
    <bug_when>2011-10-22 17:15:14 -0700</bug_when>
    <thetext>This is a huge problem for me (see http://stackoverflow.com/questions/7830249/how-do-you-get-the-selected-items-from-a-dragstart-event-in-chrome-is-datatrans) this solution makes perfect sense.  For example, a dragstart should have the data being dragged available if the event is registered on that document.
E.G.  Add this to the Chrome Javascript dev console...
window.addEventListener(&quot;dragstart&quot;, function(event) {
        alert(event.dataTransfer.getData(&quot;Text&quot;));
    });

Returns alerts &apos;undefined&apos; when selected text is dragged. :(

  (In reply to comment #7)
&gt; This is broken on all the ports because, we dont allow getData to be called when drag start or drag over is happening. This is for security reason, that getData can be accessed only during drop event and not before that. This so, because when you are dragging data across documents on your desktop, you do not want getData to be called by intermittent document which is not suppose to have access to data. The real solution to this problem would be to check if the dragging is happening within the same document (if within same domain), then getData can be accessed in drag enter and drag over event too. This is the implementation in other browsers like firefox.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>975196</commentid>
    <comment_count>9</comment_count>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2014-02-03 03:17:30 -0800</bug_when>
    <thetext>=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>88954</attachid>
            <date>2011-04-10 11:11:34 -0700</date>
            <delta_ts>2011-04-26 17:17:45 -0700</delta_ts>
            <desc>Patch for review</desc>
            <filename>patch_58206</filename>
            <type>text/plain</type>
            <size>1416</size>
            <attacher name="Aparna Nandyal">aparna.nand</attacher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Sk6CisKIDIwMTEtMDQtMDkg
IEtlaXRoIEt5eml2YXQgIDxrZWl0aC5reXppdmF0QG5va2lhLmNvbT4KIAogICAgICAgICBSZXZp
ZXdlZCBieSBMYXN6bG8gR29tYm9zLgpkaWZmIC0tZ2l0IGEvU291cmNlL1dlYkNvcmUvcGxhdGZv
cm0vcXQvQ2xpcGJvYXJkUXQuY3BwIGIvU291cmNlL1dlYkNvcmUvcGxhdGZvcm0vcXQvQ2xpcGJv
YXJkUXQuY3BwCmluZGV4IDcyM2NkZDQuLmY4ZWJmMDkgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJD
b3JlL3BsYXRmb3JtL3F0L0NsaXBib2FyZFF0LmNwcAorKysgYi9Tb3VyY2UvV2ViQ29yZS9wbGF0
Zm9ybS9xdC9DbGlwYm9hcmRRdC5jcHAKQEAgLTE0Myw3ICsxNDMsNyBAQCB2b2lkIENsaXBib2Fy
ZFF0OjpjbGVhckFsbERhdGEoKQogU3RyaW5nIENsaXBib2FyZFF0OjpnZXREYXRhKGNvbnN0IFN0
cmluZyYgdHlwZSwgYm9vbCYgc3VjY2VzcykgY29uc3QKIHsKIAotICAgIGlmIChwb2xpY3koKSAh
PSBDbGlwYm9hcmRSZWFkYWJsZSkgeworICAgIGlmIChwb2xpY3koKSAhPSBDbGlwYm9hcmRSZWFk
YWJsZSAmJiBwb2xpY3koKSAhPSBDbGlwYm9hcmRUeXBlc1JlYWRhYmxlKSB7CiAgICAgICAgIHN1
Y2Nlc3MgPSBmYWxzZTsKICAgICAgICAgcmV0dXJuIFN0cmluZygpOwogICAgIH0K
</data>
<flag name="review"
          id="81567"
          type_id="1"
          status="-"
          setter="kling"
    />
          </attachment>
      

    </bug>

</bugzilla>