Opened 10 months ago

Closed 3 months ago

#24263 closed defect (fixed)

Tor Browser 7.0.9 doesn't run background scripts from Web Extensions

Reported by: sajolida Owned by: tbb-team
Priority: Medium Milestone:
Component: Applications/Tor Browser Version:
Severity: Normal Keywords:
Cc: brade, mcs, u@…, sajolida, learningcrumb Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

While doing some last minute tests before the release of the port of the Tails ISO image verification extension to Web Extensions we realized that it was not working on Debian while it is working on Tails and Windows.

Investigating this further we think that the background scripts of Web Extensions are not run correctly in Tor Browser 7.0.9 on Debian. For example, running the dummy extension described in https://trac.torproject.org/projects/tor/ticket/21270 leads to a ping in the console on both Tor Browser 7.0.8 in Windows and Tor Browser 7.0.6 in Tails but not on Tor Browser 7.0.9 in Debian. I'm sorry I'm comparing different version of Tor Browser on different OSes so I can't tell if it's OS-specific or version-specific... Note that they were all in "low" security in the slider.

Here is the code of the dummy extension I used to do the tests, inspired from #21270:

$ cat ping/manifest.json 
{
  "manifest_version": 2,
  "name": "Ping Test",
  "version": "1.0",
  "description": "Tiny extension which pings the console from a background script.",
  "background": {
    "scripts": [ "ping.js" ]
  }
}

$ cat ping/ping.js 
console.log('ping');

The procedure to test it is:

  1. Start a fresh Tor Browser.
  2. Press Ctrl+Shift+J to open the JavaScript console.
  3. Visit about:debugging and load manifest.json as a temporary add-on.

The output of the console in each case is:

Debian: 7.0.9 (based on Mozilla Firefox 52.4.1) (64-bit)

1510597075800   addons.webextension.{73a6fe31-595d-460b-a920-fcc0f8843232}      WARN    Loading extension '{73a6fe31-595d-460b-a920-fcc0f8843232}': Reading manifest: Error processing permissions.1: Unknown permission "privacy"
1510597075800   addons.webextension.{73a6fe31-595d-460b-a920-fcc0f8843232}      WARN    Loading extension '{73a6fe31-595d-460b-a920-fcc0f8843232}': Reading manifest: Error processing permissions.4: Unknown permission "unlimitedStorage"
1510597075800   addons.webextension.https-everywhere-eff@eff.org        WARN    Loading extension 'https-everywhere-eff@eff.org': Reading manifest: Error processing devtools_page: An unexpected property was found in the WebExtension manifest.
Tor NOTICE: Bootstrapped 85%: Finishing handshake with first hop
1510597076000   addons.webextension.https-everywhere-eff@eff.org        WARN    Please specify whether you want browser_style or not in your browser_action options.
Tor NOTICE: Bootstrapped 90%: Establishing a Tor circuit
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.  ExtensionCommon.jsm:265
Tor NOTICE: new bridge descriptor 'potagerbis' (fresh): $8D31A74671EACA6B3865DDBD6A5DD70D7F6A24F6~potagerbis at 91.194.60.100
Tor NOTICE: Tor has successfully opened a circuit. Looks like client functionality is working.
Tor NOTICE: Bootstrapped 100%: Done
[11-13 18:18:05] Torbutton NOTE: Initializing security-prefs.js
[11-13 18:18:05] Torbutton NOTE: security-prefs.js initialization complete
Tor NOTICE: New control connection opened from 127.0.0.1.
[11-13 18:18:06] Torbutton WARN: no SOCKS credentials found for current document.
Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“toggleReaderMode”  browser.xul
Key event not available on GTK2: key=“u” modifiers=“accel shift” id=“torbutton-new-identity-key”  browser.xul
Key event not available on some keyboard layouts: key=“i” modifiers=“accel,alt,shift” id=“key_browserToolbox”  browser.xul
[11-13 18:18:26] Torbutton WARN: no SOCKS credentials found for current document.
[11-13 18:18:43] Torbutton WARN: no SOCKS credentials found for current document.
JSON.parse: unexpected end of data at line 1 column 1 of the JSON data  DirectoryLinksProvider.jsm:391
[11-13 18:18:49] Torbutton WARN: no SOCKS credentials found for current document.
[11-13 18:19:17] Torbutton WARN: no SOCKS credentials found for current document.

Windows: 7.0.8 (based on Mozilla Firefox 52.4.1) (32-bit)

[11-13 18:21:01] TorLauncher NOTE: failed to open authenticated connection:  [scrubbed]
1510597261900   addons.webextension.{73a6fe31-595d-460b-a920-fcc0f8843232}      WARN    Loading extension '{73a6fe31-595d-460b-a920-fcc0f8843232}': Reading manifest: Error processing permissions.1: Unknown permission "privacy"
1510597262000   addons.webextension.{73a6fe31-595d-460b-a920-fcc0f8843232}      WARN    Loading extension '{73a6fe31-595d-460b-a920-fcc0f8843232}': Reading manifest: Error processing permissions.4: Unknown permission "unlimitedStorage"
1510597272200   addons.webextension.https-everywhere-eff@eff.org        WARN    Loading extension 'https-everywhere-eff@eff.org': Reading manifest: Error processing devtools_page: An unexpected property was found in the WebExtension manifest.
1510597272600   addons.webextension.https-everywhere-eff@eff.org        WARN    Please specify whether you want browser_style or not in your browser_action options.
Tor NOTICE: Bootstrapped 85%: Finishing handshake with first hop
Tor NOTICE: Bootstrapped 90%: Establishing a Tor circuit
Tor NOTICE: Tor has successfully opened a circuit. Looks like client functionality is working.
Tor NOTICE: Bootstrapped 100%: Done
Unchecked lastError value: Error: Could not establish connection. Receiving end does not exist.  ExtensionCommon.jsm:265
[11-13 18:21:18] Torbutton NOTE: Initializing security-prefs.js
[11-13 18:21:18] Torbutton NOTE: security-prefs.js initialization complete
Tor NOTICE: New control connection opened from 127.0.0.1.
[11-13 18:21:19] Torbutton WARN: no SOCKS credentials found for current document.
[11-13 18:21:20] Torbutton WARN: no SOCKS credentials found for current document.
Key event not available on some keyboard layouts: key=<93>r<94> modifiers=<93>accel,alt<94> id=<93>toggleReaderMode<94>  browser.xul
Key event not available on GTK2: key=<93>u<94> modifiers=<93>accel shift<94> id=<93>torbutton-new-identity-key<94>  browser.xul
Key event not available on some keyboard layouts: key=<93>i<94> modifiers=<93>accel,alt,shift<94> id=<93>key_browserToolbox<94>  browser.xul
[11-13 18:21:33] Torbutton WARN: no SOCKS credentials found for current document.
ping  ping.js:1:1

Tails: 7.0.6 (based on Mozilla Firefox 52.4.0) (64-bit)

DEPRECATION WARNING: Search service falling back to synchronous initialization. This is generally the consequence of an add-on using a deprecated search service API.
You may find more details about this deprecation at: https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIBrowserSearchService#async_warning
jar:file:///usr/local/lib/tor-browser/omni.ja!/components/nsSearchService.js 2702 SRCH_SVC__ensureInitialized
jar:file:///usr/local/lib/tor-browser/omni.ja!/components/nsSearchService.js 4003 SRCH_SVC_getEngineByName
mozilla.cfg 4 null
  Deprecated.jsm:79
1510598479300   addons.xpi-utils        ERROR   Unable to read anything useful from the database  Log.jsm:753
1510598480100   addons.webextension.<unknown>   WARN    Loading extension 'null': Reading manifest: Error processing permissions.1: Unknown permission "privacy"
1510598482300   addons.webextension.<unknown>   WARN    Loading extension 'null': Reading manifest: Error processing devtools_page: An unexpected property was found in the WebExtension manifest.
Warning: attempting to write 4232 bytes to preference extensions.bootstrappedAddons. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file. This preference will not be sent to any content processes.
1510598483000   addons.xpi      WARN    Add-on https-everywhere-eff@eff.org is missing bootstrap method install
Warning: attempting to write 4484 bytes to preference extensions.bootstrappedAddons. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file. This preference will not be sent to any content processes.
Bootstrapped manifest not allowed to use 'component' directive.  chrome.manifest:60
Bootstrapped manifest not allowed to use 'contract' directive.  chrome.manifest:61
Bootstrapped manifest not allowed to use 'category' directive.  chrome.manifest:63
Bootstrapped manifest not allowed to use 'overlay' directive.  chrome.manifest:68
Bootstrapped manifest not allowed to use 'overlay' directive.  chrome.manifest:69
Bootstrapped manifest not allowed to use 'style' directive.  chrome.manifest:71
Bootstrapped manifest not allowed to use 'component' directive.  chrome.manifest:74
Bootstrapped manifest not allowed to use 'contract' directive.  chrome.manifest:75
Bootstrapped manifest not allowed to use 'category' directive.  chrome.manifest:76
1510598486500   addons.webextension.{73a6fe31-595d-460b-a920-fcc0f8843232}      WARN    Loading extension '{73a6fe31-595d-460b-a920-fcc0f8843232}': Reading manifest: Error processing permissions.1: Unknown permission "privacy"
1510598486600   addons.webextension.https-everywhere-eff@eff.org        WARN    Loading extension 'https-everywhere-eff@eff.org': Reading manifest: Error processing devtools_page: An unexpected property was found in the WebExtension manifest.
1510598486800   addons.webextension.https-everywhere-eff@eff.org        WARN    Please specify whether you want browser_style or not in your browser_action options.
SyntaxError: The URI is malformed.  (unknown)
[11-13 18:41:32] Torbutton NOTE: Initializing security-prefs.js
[11-13 18:41:32] Torbutton NOTE: security-prefs.js initialization complete
SyntaxError: The URI is malformed.  (unknown)
Key event not available on some keyboard layouts: key=“r” modifiers=“accel,alt” id=“toggleReaderMode”  browser.xul
Key event not available on GTK2: key=“u” modifiers=“accel shift” id=“torbutton-new-identity-key”  browser.xul
Key event not available on some keyboard layouts: key=“i” modifiers=“accel,alt,shift” id=“key_browserToolbox”  browser.xul
[11-13 18:41:47] Torbutton WARN: no SOCKS credentials found for current document.
Unix error 2 during operation open on file /home/amnesia/.tor-browser/profile.default/directoryLinks.json (No such file or directory)  DirectoryLinksProvider.jsm:402
[11-13 18:42:06] Torbutton WARN: no SOCKS credentials found for current document.
Warning: attempting to write 4730 bytes to preference extensions.bootstrappedAddons. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file. This preference will not be sent to any content processes.
ping  ping.js:1:1

Child Tickets

Change History (7)

comment:1 Changed 10 months ago by mcs

Cc: brade mcs added

I tested a little on macOS and I was able to reproduce this problem with 7.0.9 but not 7.0.8. That points to the #24052 fix, although I don't have time to dig deeper today.

comment:2 Changed 10 months ago by sajolida

Cc: u@… sajolida added

I tried this on Tails 3.3 which has Tor Browser 7.0.10 and I got no ping. This seems to confirm what you're saying and that this bug was introduced in 7.0.9 and might not be otherwise related to the operating system.

comment:3 Changed 10 months ago by sajolida

Summary: Tor Browser 7.0.9 on Debian doesn't run background scripts from Web ExtensionsTor Browser 7.0.9 doesn't run background scripts from Web Extensions

comment:4 Changed 10 months ago by sajolida

I tried with the version of our extension published on addons.mozilla.org and it works in Tor Browser 7.0.10, so as mcs implied, this is related to *local files* only, and Web Extensions seem to work fine when loaded from web stores.

So for us, this is only a problem while developing the extension but not for our users → Good news!

comment:5 Changed 10 months ago by gk

Cc: learningcrumb added

#24504 is a duplicate.

comment:6 Changed 10 months ago by learningcrumb

The problem described in 24504 goes away if I bundle the extension as an xpi.

So it's clear it only happens when the extension is a directory of loose files rather than an xpi file.

Therefore, I agree that 24504 is a duplicate of this ticket.

I guess I could have saved myself some time building that test case if I'd looked more carefully at existing tickets... but mostly I'm just glad to have a workaround I can use immediately.

Thanks for spotting the link gk!

Incidentally, while testing just now I did see some strange behaviour with pings from an embedded WebExt only appearing in the Browser Console if the console was open when the button was hit, disappearing again when the console was closed and reopened, while messages from the outer extension itself behaved normally. It may not be important. If I have time I will look into it and open a separate ticket if necessary. Just mentioning it in case I don't get around to it and someone else feels like investigating. This was while using the test extension from 24504 bundled as an xpi.

comment:7 Changed 3 months ago by gk

Resolution: fixed
Status: newclosed

This should be fixed in Tor Browser 8.0a9.

Note: See TracTickets for help on using tickets.