Opened on 01/10/2019 at 10:03:54 PM

Closed on 01/15/2019 at 05:35:40 PM

Last modified on 01/29/2019 at 04:34:16 PM

#7207 closed change (fixed)

Implement abort-on-property-write snippet

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

https://codereview.adblockplus.org/29979555/

Description (last modified by hfiguiere)

Background

Similarly to issue #6969

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 written (set).

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

What to change

Implement a snippet called abort-on-property-write that wraps a given property of the window object and throws an error if the property is written (set).

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 */
setTimeout(() =>
{  
  if (!window.adsShowing)
  {
    window.adsShowing = true;
    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);
  }
},
500);

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

Attachments (0)

Change History (13)

comment:1 Changed on 01/10/2019 at 10:04:58 PM by hfiguiere

  • Cc mjethani arthur added

comment:2 Changed on 01/11/2019 at 02:38:49 PM by hfiguiere

  • Description modified (diff)

comment:3 Changed on 01/15/2019 at 11:56:31 AM by sdixit

Let's get code review done so that we have a chance to release this before code freeze. Manish: Could you please help on this?

comment:4 Changed on 01/15/2019 at 05:25:44 PM by mjethani

  • Owner set to hfiguiere
  • Priority changed from Unknown to P2
  • Ready set

comment:5 Changed on 01/15/2019 at 05:34:36 PM by abpbot

A commit referencing this issue has landed:
Issue 7207 - Implement abort-on-property-write snippet

comment:6 Changed on 01/15/2019 at 05:35:40 PM by hfiguiere

  • Resolution set to fixed
  • Review URL(s) modified (diff)
  • Status changed from new to closed

comment:7 Changed on 01/17/2019 at 08:55:37 AM by abpbot

A commit referencing this issue has landed:
Issue 7207 - Implement abort-on-property-write snippet

comment:8 Changed on 01/22/2019 at 06:03:28 AM by Ross

Working in the browser versions below. Will verify once able to test on minimum versions.

ABP 3.4.2.2231
Chrome 71.0.3578.98 / Windows 10
Firefox 64.0.2 / Windows 10

comment:9 Changed on 01/22/2019 at 01:55:16 PM by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Implemented and working.

ABP 3.4.2.2231
Chrome 71.0.3578.98 / Windows 10 (Latest)
Chrome 49.0.2623.75 / Windows 10 (Min supported)
Firefox 64.0.2 / Windows 10 (Latest)
Firefox 51.0 / Windows 10 (Min supported)
Opera 57.0.3098.76 / Windows 10 (Latest)
Opera 36.0.2130.65 / Windows 10 (Min supported)

comment:10 Changed on 01/23/2019 at 02:55:25 AM by mjethani

  • Sensitive unset

comment:11 Changed on 01/25/2019 at 02:20:43 PM by Ross

Does not work in Edge. Should it? I will open a new ticket if so.

ABP 0.9.12.2237
Edge 44.17763.1.0 / EdgeHTML 18.17763 / Windows 10

comment:12 Changed on 01/29/2019 at 09:07:04 AM by mjethani

Let's open a new ticket for Edge, in my opinion.

comment:13 Changed on 01/29/2019 at 04:34:16 PM by hfiguiere

It should work in Edge, but the example might not as there are other timing consideration in place.

What you can try is, on the same page as in the test procedure, open the devtools and in the JS console try to do the following:

window.adsShowing = true

You should get an error.

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from hfiguiere.
 
Note: See TracTickets for help on using tickets.