Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#4332 closed defect (fixed)

Objects produced by the wrapped WebSocket aren't considered WebSocket instances

Reported by: trev Assignee: kzar
Priority: P1 Milestone: Adblock-Plus-1.12.2-for-Chrome-Opera-Safari
Module: Platform Keywords:
Cc: sebastian, kzar, Ross, scheer Blocked By:
Blocking: #1727 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Scheer Verified working: yes
Review URL(s):



Adblock Plus on Chrome 52.

How to reproduce

  1. Go to
  2. Press Ctrl-Shift-J/Cmd-Option-J to open JavaScript console.
  3. Type new WebSocket("wss://") instanceof WebSocket and press Enter.

Observed behaviour

You see false printed to console.

Expected behaviour

It should be true, as you get for the new tab page where WebSocket isn't wrapped.


It seems that we need to set .prototype property on the original WebSocket function as well, not merely the bound function. As explains, bound functions will redirect to their target function for subclass tests, so this one has to be associated with the right prototype.

Change History (5)

comment:1 Changed 4 years ago by kzar

  • Owner set to kzar
  • Priority changed from Unknown to P1
  • Review URL(s) modified (diff)

comment:2 Changed 4 years ago by kzar

  • Status changed from new to reviewing

comment:3 Changed 4 years ago by kzar

  • Cc Ross scheer added
  • Milestone set to Adblock-Plus-1.12.2-for-Chrome-Opera-Safari
  • Resolution set to fixed
  • Status changed from reviewing to closed

A commit referencing this issue has landed:
Fixes 4331, 4332 - WebSocket.length and instanceof WebSocket

comment:4 Changed 4 years ago by scheer

  • Tester changed from Unknown to Scheer
  • Verified working set
  • When entering the above I now receive:
-new WebSocket("wss://") instanceof WebSocket
-WebSocket connection to 'wss://' failed: Error during WebSocket handshake: Unexpected response code: 400

Chrome 52

comment:5 Changed 4 years ago by rraceanu

Same results on Safari 9 and Opera 39.0.2256.48- ABP

-WebSocket connection to 'wss://' failed: Error during WebSocket handshake: Unexpected response code: 400

Note: See TracTickets for help on using tickets.