chromium / suspicious-site-reporter

Extension for reporting suspicious sites to Safe Browsing.
Apache License 2.0
96 stars 22 forks source link

Toggling "Allow Incognito" on settings page turns the flag orange #31

Open ericlaw1979 opened 5 years ago

ericlaw1979 commented 5 years ago

Toggling "Allow Incognito" on the settings page turns the flag orange and enables it such that you end up with this funny UI whereby it offers to submit a report about a chrome: URL: image

ericlaw1979 commented 5 years ago

This also happens when toggling the "Allow access to file urls"

The problem goes away if you use Chrome's DevTools to inspect the background page. So the problem may be correlated with the Background page being marked "Inactive"?

ericlaw1979 commented 5 years ago

It may not be relevant for this issue, but it seems like this:

chrome.tabs.query({}, (tabs) => {
      tabs.forEach((tab) => {
        setBrowserActionAndIcon(tab);
      });
    });

could be safely changed to

chrome.tabs.query({"active":true}, (tabs) => {
      tabs.forEach((tab) => {
        setBrowserActionAndIcon(tab);
      });
    });

This would speed up the initial load cost?

ericlaw1979 commented 5 years ago

One other oddity; if I inspect the background page while toggling these checkboxes, the |Sources| tab seems to show the background page's script loading multiple times. I don't see this with one of my own extensions that uses a background page/js.

image

ericlaw1979 commented 5 years ago

Documentation for chrome.tabs.onActivated notes that it can fire before tab.url is available, so the setBrowserActionAndIcon call should probably check whether tab.url is assigned before attempting to call startsWith on it.

ericlaw1979 commented 5 years ago

This also reproduces on Mac OSX in Chrome Canary with the official extension.

Interestingly, when I build the extension locally and load it "unpacked", the problem does not reproduce.