el1t / uBlock-Safari

uBlock Origin - An efficient blocker for Chromium, Firefox, and Safari. Fast and lean.
GNU General Public License v3.0
2.74k stars 97 forks source link

XHR blocking broken in some webpages #55

Closed jinschoi closed 7 years ago

jinschoi commented 7 years ago

Describe the issue

The XHR blocking fails on event dispatch with: "TypeError: Argument 1 ('event') to EventTarget.dispatchEvent must be an instance of Event".

Apparently, calling document.dispatchEvent with a CustomEvent created using "new CustomEvent(...)" throws that error, which can easily be tested using the console:

e = new CustomEvent("foo"); document.dispatchEvent(e);

Doing it using the old deprecated way: e = document.createEvent("CustomEvent"); e.initCustomEvent(...);

works just fine. In vapi-client.js, those two ways of creating CustomEvents are switched on legacyMode. If I just switch out "legacyMode" with "true" in line 600, it works properly for me.

One or more specific URLs where the issue occurs

I encountered this error on Flipster, a site to read magazines through a library subscription, but it can be seen here as well: http://www.javamagazine.mozaicreader.com/JanFeb2016#&pageSet=4&page=0&contentItem=0

Steps for anyone to reproduce the issue

  1. Visit the example URL.
  2. Note that it works with uBlock uninstalled (not just whitelisting the site).
  3. Note that it fails with uBlock installed, even when the site is whitelisted.

Your settings

All default settings.

Your filter lists

Default, none, it doesn't matter.

el1t commented 7 years ago

The issue is that CustomEvent is being polyfilled by the website (e.g. the javamagazine one). I've got a workaround, though.