<?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>187386</bug_id>
          
          <creation_ts>2018-07-06 08:08:10 -0700</creation_ts>
          <short_desc>Sometimes &quot;x instanceof Worker&quot; inappropriately returns false</short_desc>
          <delta_ts>2018-07-09 20:35:50 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>JavaScriptCore</component>
          <version>Safari 11</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>jdscheff</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>cdumez</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1439779</commentid>
    <comment_count>0</comment_count>
    <who name="">jdscheff</who>
    <bug_when>2018-07-06 08:08:10 -0700</bug_when>
    <thetext>This code should clearly print &quot;true&quot;:

    blob = new Blob([&quot;self.onmessage = function() {};&quot;], { type: &quot;text/javascript&quot; });
    worker = new Worker(window.URL.createObjectURL(blob));
    console.log(worker instanceof Worker);

I tested that in Safari 11.1 and it does indeed print &quot;true&quot; when I run it. However for some small subset of Safari 11.x users, it will print &quot;false&quot;.

From my client-side error tracker, this bug has occurred in Safari versions 11.0.2, 11.0.3, 11.1.0, 11.1.1. But only to a small fraction of Safari users. Out of a total of ~5000 Safari 11 users in the past month, only 14 of them experienced this error. I even got one of these users to run the above code in the JS console and he confirmed that even that simple code does indeed print &quot;false&quot; for him.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1440399</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-07-09 08:58:09 -0700</bug_when>
    <thetext>One common way this happens is when the page&apos;s JavaScript messes with the Worker&apos;s prototype chain in some way (so Worker or EventTarget). Some script does this to extend the API of a particular type.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1440401</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-07-09 09:02:13 -0700</bug_when>
    <thetext>(In reply to Chris Dumez from comment #1)
&gt; One common way this happens is when the page&apos;s JavaScript messes with the
&gt; Worker&apos;s prototype chain in some way (so Worker or EventTarget). Some script
&gt; does this to extend the API of a particular type.

To be clear, unless we have specific evidence (reproduction case), my instinct would be to say that this is an issue with the page&apos;s script, not WebKit. We&apos;ve investigated many instances of this in the past and every time, it was the page&apos;s script modifying the prototype chain in some way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1440709</commentid>
    <comment_count>3</comment_count>
    <who name="">jdscheff</who>
    <bug_when>2018-07-09 20:35:50 -0700</bug_when>
    <thetext>Can you be more specific about how messing with the prototype chain might cause this problem? Mostly just for my curiosity, since in my app I already switched from relying on &quot;instanceof Worker&quot; to be correct.

Also it&apos;s curious because this error only appears in my error tracker for Safari, not any other browser. And while I do have a little third party JS running, it&apos;s not much. It&apos;d be weird if something like Google Analytics was destructively messing with built in prototypes.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>