NEW 187386
Sometimes "x instanceof Worker" inappropriately returns false
https://bugs.webkit.org/show_bug.cgi?id=187386
Summary Sometimes "x instanceof Worker" inappropriately returns false
jdscheff
Reported 2018-07-06 08:08:10 PDT
This code should clearly print "true": blob = new Blob(["self.onmessage = function() {};"], { type: "text/javascript" }); worker = new Worker(window.URL.createObjectURL(blob)); console.log(worker instanceof Worker); I tested that in Safari 11.1 and it does indeed print "true" when I run it. However for some small subset of Safari 11.x users, it will print "false". 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 "false" for him.
Attachments
Chris Dumez
Comment 1 2018-07-09 08:58:09 PDT
One common way this happens is when the page's JavaScript messes with the Worker's prototype chain in some way (so Worker or EventTarget). Some script does this to extend the API of a particular type.
Chris Dumez
Comment 2 2018-07-09 09:02:13 PDT
(In reply to Chris Dumez from comment #1) > One common way this happens is when the page's JavaScript messes with the > Worker's prototype chain in some way (so Worker or EventTarget). Some script > 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's script, not WebKit. We've investigated many instances of this in the past and every time, it was the page's script modifying the prototype chain in some way.
jdscheff
Comment 3 2018-07-09 20:35:50 PDT
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 "instanceof Worker" to be correct. Also it'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's not much. It'd be weird if something like Google Analytics was destructively messing with built in prototypes.
Note You need to log in before you can comment on or make changes to this bug.