<?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>132306</bug_id>
          
          <creation_ts>2014-04-28 15:24:31 -0700</creation_ts>
          <short_desc>dataTransfer.types changes to null during execution of HTML drop event</short_desc>
          <delta_ts>2019-02-06 09:18:28 -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>DOM</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>OS X 10.9</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Owen Shaw">qx236</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ggaren</cc>
    
    <cc>matthew_hanson</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1004752</commentid>
    <comment_count>0</comment_count>
      <attachid>230327</attachid>
    <who name="Owen Shaw">qx236</who>
    <bug_when>2014-04-28 15:24:31 -0700</bug_when>
    <thetext>Created attachment 230327
simplified test code

In an HTML drop event handler function, event.dataTransfer.types is initially non-null, but then changes to null, seemingly between lines of JavaScript.

The issue is sporadic, even in the simplified test code attached.  Furthermore, I have only reproduced this when dragging and dropping data from Chrome to Safari.

The attached test code sets up bare-minimum drop handling on document.body, and on drop loops 10 times, making a note each iteration of whether event.dataTransfer.types is null or non-null, and finally prints the results on the page.

1) Load attached HTML test page in Safari
2) Open Chrome and browse to any site
3) Drag text or image from Chrome to test page in Safari
4) Repeat as necessary to observe
    a) value can start as non-null and change to null
    b) the change can occur at different places on different runs

Repeated testing is key because the results vary from run to run.  Some runs will show the value as always null, others will show the value as never null, and some runs will show a changing value.

The test code is a bit contrived, but it helps catch the issue.  The code that started my investigation was essentially the following:

if (e.dataTransfer.types === null){
    return;
}
for (var i = 0, l = e.dataTransfer.types.length; i &lt; l; ++i){
&gt;&gt; TypeError: &apos;null&apos; is not an object (evaluating &apos;e.dataTransfer.types.length&apos;)

Which is one line saying .types is not null and then the next line throwing an error because .types is null.

Mac 10.9.2
Safari Version: 7.0.3 (9537.75.14)  (also tested in WebKit Nightly r167883)
Chrome Version: 34.0.1847.131</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1271991</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-01-31 17:17:06 -0800</bug_when>
    <thetext>&lt;rdar://problem/30299496&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1293676</commentid>
    <comment_count>2</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2017-04-03 10:44:09 -0700</bug_when>
    <thetext>I couldn&apos;t reproduce this bug using Safari Technology Preview Release 26. I tried a few times on a few different websites. Maybe it would help to specify the source website.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1293917</commentid>
    <comment_count>3</comment_count>
    <who name="Owen Shaw">qx236</who>
    <bug_when>2017-04-03 17:19:20 -0700</bug_when>
    <thetext>Looks like it may be fixed.  I just tried in Tech Preview 26 and can&apos;t reproduce the bug either.

Although it is still reproducible for me in Safari 10.1 (12603.1.30.0.34), so the fix must have been recent.  

The source site has never seemed important.  I just tried from google.com and nytimes.com today; both showed the bug in 10.1, and neither showed it in Preview 26.

Thanks for looking into it!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1503173</commentid>
    <comment_count>4</comment_count>
    <who name="Lucas Forschler">lforschler</who>
    <bug_when>2019-02-06 09:18:28 -0800</bug_when>
    <thetext>Mass move bugs into the DOM component.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>230327</attachid>
            <date>2014-04-28 15:24:31 -0700</date>
            <delta_ts>2014-04-28 15:24:31 -0700</delta_ts>
            <desc>simplified test code</desc>
            <filename>simple-dragtest.html</filename>
            <type>text/html</type>
            <size>784</size>
            <attacher name="Owen Shaw">qx236</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWw+CjxodG1sPgo8aGVhZD4KICA8bWV0YSBjaGFyc2V0PSJ1dGYtOCI+CiAg
PHRpdGxlPlRlc3Q8L3RpdGxlPgogIDxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4KICBk
b2N1bWVudC5hZGRFdmVudExpc3RlbmVyKCdET01Db250ZW50TG9hZGVkJywgZnVuY3Rpb24oKXsK
ICAgIGRvY3VtZW50LmJvZHkuYWRkRXZlbnRMaXN0ZW5lcignZHJhZ2VudGVyJywgZnVuY3Rpb24o
ZSl7CiAgICAgIGUucHJldmVudERlZmF1bHQoKTsKICAgIH0pOwogICAgZG9jdW1lbnQuYm9keS5h
ZGRFdmVudExpc3RlbmVyKCdkcmFnb3ZlcicsIGZ1bmN0aW9uKGUpewogICAgICBlLnByZXZlbnRE
ZWZhdWx0KCk7CiAgICB9KTsKICAgIGRvY3VtZW50LmJvZHkuYWRkRXZlbnRMaXN0ZW5lcignZHJv
cCcsIGZ1bmN0aW9uKGUpewogICAgICBlLnByZXZlbnREZWZhdWx0KCk7CiAgICAgIHZhciByZXN1
bHRzID0gW10KICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCAxMDsgKytpKXsKICAgICAgICByZXN1
bHRzW2ldID0gZS5kYXRhVHJhbnNmZXIudHlwZXMgPT09IG51bGwgPyAnbnVsbCcgOiAnbm90IG51
bGwnOwogICAgICB9CiAgICAgIGRvY3VtZW50LmJvZHkuaW5uZXJIVE1MID0gcmVzdWx0cy5qb2lu
KCc8YnI+Jyk7CiAgICB9KTsKICB9KTsKICA8L3NjcmlwdD4KICA8c3R5bGUgdHlwZT0idGV4dC9j
c3MiPgogIGh0bWwsIGJvZHkgewogICAgcGFkZGluZzogMDsKICAgIGhlaWdodDogMTAwJTsKICB9
CiAgPC9zdHlsZT4KPC9oZWFkPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>