Opened 3 months ago

Closed 5 weeks ago

Last modified 4 weeks ago

#6969 closed change (fixed)

Implement abort-on-property-read snippet

Reported by: hfiguiere Assignee: hfiguiere
Priority: Unknown Milestone:
Module: Core Keywords: circumvention
Cc: mjethani, sebastian, kzar, amrmak, arthur, Ross Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29886700/

Description (last modified by mjethani)

Background

Some circumvention scripts depend on global properties on the window object. The execution of such scripts can be aborted by throwing an error when the property is read.

There is a technique in uBlock Origin called abort-on-property-read that does this.

What to change

Implement a snippet called abort-on-property-read that wraps a given property of the window object and throws an error if the property is read.

Hints for testers

Try this:

<!-- test.html -->
<div>
  Lorem ipsum dolor sit amet, consectetur
  adipiscing elit, sed do eiusmod tempor
  incididunt ut labore et dolore magna aliqua.
</div>
<script src="script.js"></script>
/* script.js */
adsShown = false;

setTimeout(() =>
{  
  if (!adsShown)
  {
    let ad = document.createElement("div");
    ad.id = Math.random().toString(36).substring(2);
    ad.innerHTML = "<div><span>Check this!</span><span class='label'>Ad</span></div>";
    document.body.appendChild(ad);

    adsShown = true;
  }
},
500);

When you load this page, it should show the "Check this!" ad. If you then add the filter localhost#$#abort-on-property-read adsShown and reload the page, the ad should no longer be shown. Also there should be no error in the tab's console.

Change History (23)

comment:1 Changed 3 months ago by hfiguiere

  • Description modified (diff)
  • Owner set to hfiguiere

comment:2 Changed 3 months ago by hfiguiere

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:3 Changed 3 months ago by arthur

  • Cc arthur added

comment:4 Changed 3 months ago by hfiguiere

  • Cc Ross added
  • Description modified (diff)

comment:5 Changed 3 months ago by hfiguiere

  • Description modified (diff)

comment:6 Changed 3 months ago by hfiguiere

  • Description modified (diff)

comment:7 Changed 6 weeks ago by hfiguiere

  • Description modified (diff)

comment:8 Changed 6 weeks ago by mjethani

chefkoch.de,pcwelt.de,vox.de,cinema.de#$#abort-on-property-read trckd
chefkoch.de,pcwelt.de,vox.de,cinema.de#$#abort-on-property-read uabpd3

This can also be just one filter, like so:

chefkoch.de,pcwelt.de,vox.de,cinema.de#$#abort-on-property-read trckd; abort-on-property-read uabpd3

comment:9 Changed 6 weeks ago by abpbot

A commit referencing this issue has landed:
Issue 6969 - Implement abort-on-property-read snippet

comment:10 Changed 6 weeks ago by hfiguiere

  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:11 Changed 5 weeks ago by abpbot

A commit referencing this issue has landed:
Issue 6969 - Implement abort-on-property-read snippet

comment:12 Changed 5 weeks ago by mjethani

Hubert, I think the hints for testers should have a standalone test case just like all the other snippets (see #6919 for example).

comment:13 Changed 5 weeks ago by mjethani

  • Resolution fixed deleted
  • Status changed from closed to reopened

I am reopening this until there's a standalone test case.

comment:14 Changed 5 weeks ago by mjethani

  • Description modified (diff)
  • Resolution set to fixed
  • Status changed from reopened to closed

comment:15 Changed 5 weeks ago by mjethani

  • Ready set

comment:16 Changed 5 weeks ago by mjethani

  • Description modified (diff)

comment:17 Changed 5 weeks ago by mjethani

  • Description modified (diff)

comment:18 Changed 5 weeks ago by mjethani

  • Description modified (diff)

comment:19 Changed 5 weeks ago by mjethani

  • Description modified (diff)

comment:20 Changed 5 weeks ago by hfiguiere

We should make a new test page with this.

comment:21 Changed 5 weeks ago by Ross

Thanks for the test HTML. I agree all of these examples should be added to the proper test pages. I've added this one to the list of test data to create to the Test Data section of the ABP WebEx Testing notes document.

comment:22 Changed 5 weeks ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Done. This works with the example provided with no errors and as far as I can tell, seems to be working fine removing the ads on the domains listed above in comment 8.

ABP 3.4.0.2189
Firefox 63 / 51 / Windows 8
Chrome 70 / 49 / Windows 8
Opera 36 / 56 / Windows 8

comment:23 Changed 4 weeks ago by hfiguiere

  • Sensitive unset
Note: See TracTickets for help on using tickets.