Opened 2 years ago

Closed 10 months ago

Last modified 8 months ago

#5938 closed defect (fixed)

[webextension] "Block element" does not appear in menu for some websites

Reported by: mapx Assignee: kzar
Priority: P2 Milestone: Adblock-Plus-3.5-for-Chrome-Opera-Firefox
Module: Platform Keywords: externaldependencies
Cc: mjethani, kzar, sebastian, hfiguiere, Ross, cjsmall, greiner Blocked By:
Blocking: Platform: Firefox
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29589668/
https://gitlab.com/eyeo/adblockplus/adblockpluschrome/merge_requests/22

Description (last modified by kzar)

Environment

Firefox 57
ABP 2.99.0.1896
easylist / easyprivacy

ALSO

Firefox 60.0.1 / 64.0
Adblock Plus devenv built from 96eda29ae585.
Default filter lists

How to reproduce

1.) Browse to https://www.bestbuy.com/?intl=nosplash OR https://facebook.com OR https://tweakers.net/ OR https://www.dpreview.com/ OR https://vk.com/
2.) Click the ABP icon

Observed behaviour

"Block element" button is missing.

Expected behaviour

"Block element" button is shown and functions correctly.

Notes

  • An error shows up in the background console when the popup is opened, but only when the problem is happening:
Unchecked lastError value: Error: ext is not defined  ExtensionCommon.jsm:304
	withLastError resource://gre/modules/ExtensionCommon.jsm:304:9
	wrapPromise/< resource://gre/modules/ExtensionCommon.jsm:357:11
  • This does not seem to be a recent regression, I tested quite far back and could consistently reproduce the problem.
  • I can still reproduce the problem with EasyList disabled.
  • This seems to be a symptom of Mozilla bug #1408996.
  • See this workaround in uBlock: var vAPI = window.vAPI;.

Hints for testers

  • Check that the "Block element" tool works for these troublesome pages on Firefox now.
  • Check that subscription links still work on Firefox.
  • Check that the "Block element" tool works as before on Chrome.

Attachments (1)

time.mk-2018-02-07-05-51.zip (45.1 KB) - added by Janevski 21 months ago.

Download all attachments as: .zip

Change History (45)

comment:1 Changed 2 years ago by mapx

  • Component changed from Unknown to Platform

comment:2 Changed 2 years ago by mapx

  • Description modified (diff)

comment:3 Changed 2 years ago by kzar

  • Cc hfiguiere Ross added
  • Platform changed from Unknown / Cross platform to Firefox

comment:4 Changed 2 years ago by kzar

  • Priority changed from Unknown to P2
  • Ready set

I can reproduce this as described, investigating.

comment:5 Changed 2 years ago by kzar

  • Description modified (diff)

comment:6 follow-up: Changed 2 years ago by mapx

Could be related to this ticket ?
https://issues.adblockplus.org/ticket/5817

Does FB use some restrictive CSP directives ?

comment:7 Changed 2 years ago by kzar

  • Description modified (diff)

comment:8 in reply to: ↑ 6 Changed 2 years ago by kzar

Replying to mapx:

Could be related to this ticket ?
https://issues.adblockplus.org/ticket/5817

Does FB use some restrictive CSP directives ?

Well since the error is showing up in the background page I figure it's not likely to be the problem, but for reference the CSP I'm seeing is default-src * data: blob:;script-src *.facebook.com *.fbcdn.net *.facebook.net *.google-analytics.com *.virtualearth.net *.google.com 127.0.0.1:* *.spotilocal.com:* 'unsafe-inline' 'unsafe-eval' fbstatic-a.akamaihd.net fbcdn-static-b-a.akamaihd.net *.atlassolutions.com blob: data: 'self';style-src data: blob: 'unsafe-inline' *;connect-src *.facebook.com *.fbcdn.net *.facebook.net *.spotilocal.com:* *.akamaihd.net wss://*.facebook.com:* https://fb.scanandcleanlocal.com:* *.atlassolutions.com attachment.fbsbx.com ws://localhost:* blob: *.cdninstagram.com 'self';

comment:9 Changed 2 years ago by kzar

I'm not sure what's going on here, popup.js is sending "composer.content.getState" but getting undefined as the response. I've ran out of time for today.

comment:10 Changed 2 years ago by mjethani

Well, I've narrowed it down. The problem here is that ext in ext/content.js is undefined. But there's only the symptom of the real problem, which is a bug in Firefox.

You can try out the simple extension below.

Here's the manifest.json:

{
  "applications": {
    "gecko": {
      "id": "example-extension@example.com",
      "strict_min_version": "50.0"
    }
  },
  "content_scripts": [
    {
      "js": ["content.js"],
      "matches": [ "http://*/*", "https://*/*" ],
      "run_at": "document_start"
    }
  ],
  "description": "An example extension",
  "manifest_version": 2,
  "name": "Example",
  "short_name": "Example",
  "version": "0.1.0"
}

And here's the content.js:

{
  const instanceId = Math.floor(Math.random() * 10000);

  console.log("Initializing content.js");
    
  let printFoo = () => console.log(`[${instanceId}] window.foo:`, window.foo);
      
  window.foo = {};
  printFoo();
  
  setInterval(printFoo, 1000);
      
  console.log("Finished initializing content.js");
}

Now when you load https://www.facebook.com/thebestposts you'll see that even though window.foo is assigned and prints the correct value immediately, on the first tick (after a second) it prints undefined and keeps printing undefined forever. It's like the window object is getting replaced at some point.

Interestingly this does not happen on https://manishjethani.com/

I'll investigate further tomorrow but this looks like a bug.

Version 1, edited 2 years ago by mjethani (previous) (next) (diff)

comment:11 Changed 2 years ago by mjethani

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

comment:12 Changed 2 years ago by mjethani

  • Owner set to mjethani

comment:13 Changed 2 years ago by mjethani

I have reported the bug to Mozilla: #1412115.

comment:14 Changed 2 years ago by kzar

  • Keywords externaldependencies added
  • Status changed from reviewing to reopened

comment:16 Changed 2 years ago by kzar

  • Summary changed from webextension: "block element" does not appear in menu for FB to [webextension] "block element" does not appear in menu for FB

comment:17 Changed 2 years ago by trev

  • Description modified (diff)
  • Summary changed from [webextension] "block element" does not appear in menu for FB to [webextension] "block element" does not appear in menu on some websites

comment:18 Changed 22 months ago by fhd

  • Cc trev removed

Changed 21 months ago by Janevski

comment:19 Changed 21 months ago by Janevski

Scenario:
This happens on Chromium too.
Just by visiting some websites the right click block element option doesn't appear to exist at all.

Example, but not limited to:
Visit http://time.mk
I've put an attachment of index.html.

Info:
Chromium Version 63.0.3239.84 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit)
Adblock Plus 1.13.5

Last edited 21 months ago by Janevski (previous) (diff)

comment:20 Changed 20 months ago by kzar

Janevski that is a different issue, see #6048.

Edit: In fact that issue isn't quite the same either, I've opened #6387 for it. To set expectations however fixing this might well not be possible with the APIs that the browsers provide.

Last edited 20 months ago by kzar (previous) (diff)

comment:21 Changed 17 months ago by mapx

  • Cc cjsmall added

comment:23 Changed 17 months ago by mapx

  • Cc greiner added

comment:24 Changed 17 months ago by greiner

In case it helps: We've been experiencing the same issue in the Flattr extension on Firefox Mobile where the browser "forgets" the extension's listener which it sets on flattr.com for the purpose of authenticating the user. Unlike here, however, we didn't encounter the problem on Firefox Desktop or on Chrome.

Unfortunately, all I found about it at that time was bug 1408996 which has already been mentioned in a previous comment.

comment:25 Changed 17 months ago by mapx

another example

https://tweakers.net/

comment:26 follow-up: Changed 17 months ago by mapx

No such issue in uBo, it works on every site

comment:27 Changed 17 months ago by mjethani

  • Owner mjethani deleted

comment:29 Changed 10 months ago by kzar

  • Description modified (diff)

comment:30 Changed 10 months ago by kzar

  • Description modified (diff)
  • Summary changed from [webextension] "block element" does not appear in menu on some websites to [webextension] "Block element" does not appear in menu for some websites

comment:31 Changed 10 months ago by kzar

  • Description modified (diff)

comment:32 Changed 10 months ago by kzar

  • Description modified (diff)

comment:33 Changed 10 months ago by kzar

  • Description modified (diff)

comment:34 Changed 10 months ago by kzar

  • Description modified (diff)

comment:35 Changed 10 months ago by kzar

  • Description modified (diff)

comment:36 in reply to: ↑ 26 Changed 10 months ago by kzar

Replying to mapx:

No such issue in uBo, it works on every site

Seems you're right, which led me to this workaround in his code.

comment:37 Changed 10 months ago by greiner

See also #7159

comment:38 Changed 10 months ago by kzar

  • Owner set to kzar
  • Review URL(s) modified (diff)

comment:39 Changed 10 months ago by kzar

  • Status changed from reopened to reviewing

comment:41 Changed 10 months ago by kzar

  • Description modified (diff)

comment:42 Changed 10 months ago by abpbot

A commit referencing this issue has landed:
Issue 5938 - Work around Firefox content script bug

comment:43 Changed 10 months ago by kzar

  • Description modified (diff)
  • Milestone set to Adblock-Plus-for-Chrome-Opera-Firefox-next
  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:44 Changed 8 months ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Fixed. Block element now works as expected on the sites listed. There is still some odd behaviour on the Bestbuy website which I opened as #7298.

ABP 3.4.3.2253
Firefox 65.0.1 / 51 / Windows 10
Firefox Mobile 65.0.1 / Android 7.1.1
Chrome 72.0.3626.109 / 49.0.2623.75 / Windows 10
Opera 58.0.3135.65 / 36.0.2130.80 / Windows 10
Edge 44.17763.1.0 / Windows 10

Note: See TracTickets for help on using tickets.