10

I learned about Chrome disabling an extension when new permissions are added the hard way.

When I add new features to my extension I need to add new sites in the permissions list. Now I know I should have used optional_permissions.

My questions are:

  1. If I move the site's list from permissions to optional_permissions does the user need to approve those sites again? or just the ones that I add over time.
  2. Could any of these changes cause the extension to be disabled?:

    a. I add sites in the matches section of an entry in content_scripts

    b. I add sites in the matches section of an entry in externally_connectable

  3. Is there a way to define externally_connectable in optional_permissions?

Related links: chrome.permissions | Permission Warnings


Update: When Chrome disabled my extension I had added in the manifest one site on content_scripts > matches and externally_connectable with a matches site. The latter shows a new line in the permissions warnings saying "Communicate with cooperating websites". I'm not sure which change caused the disabling, that's why I ask about externally_connectable too.

IvanRF
  • 7,115
  • 5
  • 47
  • 71
  • Did you try to [test permission warnings](https://developer.chrome.com/extensions/permission_warnings#test) ? – Denis L May 26 '17 at 06:20
  • @Deliaz No, but I definitely will before updating hosts again – IvanRF May 26 '17 at 17:31
  • I don't think testing it this way is possible anymore. One may need to add a test extension to the store. – Xan May 26 '17 at 22:42
  • @Xan is it possible to define test accounts for an already published extension or do I need to duplicate the extension for this tests? – IvanRF May 26 '17 at 23:34
  • To be on the safe side, I would use a fresh, unlisted extension. – Xan May 27 '17 at 08:09

2 Answers2

19

In order to test when extensions are disabled by Chrome I created a private extension in the Chrome Web Store.

I started with a simple definition for manifest.json and then I added fields and settings one by one. For each test, I:

  1. uploaded a new version to the store
  2. waited for Google to publish the extension (this took a lot of time!)
  3. forced the extension update on a testers' account
  4. writed down the results

After 13 tests, this is what I've found:


Changes in manifest that DISABLE the extension

  • Adding an entry at "content_scripts" > "matches" [Warning: "Read and change your data on example.com"]
  • Adding "externally_connectable" > {"ids", "matches"} [Warning: "Communicate with cooperating websites"]

Changes in manifest that did NOT disabled the extension (no warnings)

  • Adding "declarativeContent" permission
  • Adding "optional_permissions" > all hosts
  • Adding an entry at "externally_connectable" > "ids" (after externally_connectable was accepted)
  • Adding an entry at "externally_connectable" > "matches" (after externally_connectable was accepted)
  • Adding an entry of a host without permissions at "externally_connectable" > "matches" (after externally_connectable was accepted)
  • Adding "incognito": "split"
  • Adding "content_security_policy" > script-src URL
  • Adding "web_accessible_resources"

Plus, permissions listed at permission_warnings#nowarning docs.

I probably did some silly tests like "web_accessible_resources", but I prefer that than having Chrome disabling my extension again.


Special test

Since I'm moving to optional_permissions, all hosts listed in permissions are removed. So, I wanted to know what would happen with the disabled extension when a new update does not have the problematic permission anymore:

Update 1: a new host is added at "content_scripts" > "matches" => Extension disabled

Update 2: the problematic host is removed from "content_scripts" => Extension ENABLED again

To conclude, if you made a mistake you can release a new version rolling back the changes that caused the extension to be disabled.

If I move the site's list from permissions to optional_permissions does the user need to approve those sites again? or just the ones that I add over time.

The answer is straightforward, no. Chrome stores all permissions given to the extension over time. So, only the new hosts on optional_permissions need to be approved.

IvanRF
  • 7,115
  • 5
  • 47
  • 71
  • This is a great insight, Thank you very much for taking time and sharing the behaviors. – Nishchit Aug 25 '19 at 07:45
  • Did anyone tested "storage" permission and can tell if that would cause the extension to be disabled? (Hope to avoid waiting for test extension review in CWS) – saroyanm Jun 06 '20 at 15:51
1
  1. If I move the site's list from permissions to optional_permissions does the user need to approve those sites again? or just the ones that I add over time.

New users: yes, they will need to approve it.

Existing installs that get updated: most likely no.

Consider: even if you completely remove a permission, and then put it back again, it is still considered granted.

The general documentation quote is: "Chrome prompts the user if adding the permissions results in different warning messages than the user has already seen and accepted."

  1. Could any of these changes cause the extension to be disabled?:

    a. I add sites in the matches section of an entry in content_scripts

    b. I add sites in the matches section of an entry in externally_connectable

a. Adding matches to content_scripts is equivalent to giving full host permissions and will cause your extension to be disabled if it's a new host. If you already had host permissions for that host, it will not be disabled.

b. I don't know. In theory, this does not grant your extension any new permissions, so it shouldn't.

  1. Is there a way to define externally_connectable in optional_permissions?

As per docs, no. It's not a permission to begin with.

Xan
  • 74,770
  • 16
  • 179
  • 206
  • regarding 2.a., is there any way to add a new host on `content_scripts` > `matches` without causing the extension to be disabled? If I use "http://*/" on `optional_permission` and ask for that new host permission at runtime, will the extension still be disabled? – IvanRF May 26 '17 at 16:46
  • 2
    The point of asking at runtime is to avoid being disabled; but if you add a content script match it's a non-optional host permission. If you want to use content scripts with optional permissions, you'll have to programmatically inject. – Xan May 26 '17 at 16:47
  • so, instead of adding a `content_scripts`, I add a permission for a site and inject the same files as before. I guess I will have to simulate the `document_end` too, not sure how to solve the `"all_frames"` – IvanRF May 26 '17 at 16:52
  • 2
    Read the docs of `chrome.tabs.executeScript` - it takes a lot of optional parameters that duplicate manifest keys. – Xan May 26 '17 at 22:42
  • Thanks for the tip, I can see the corresponding parameters – IvanRF May 26 '17 at 23:37
  • I'm in the middle of the move to optional permissions and I've found a dead end. If you want a challenge, check [this new question](https://stackoverflow.com/q/44425102/1718678) – IvanRF Jun 08 '17 at 01:13