James-E-A / cerdicator

Enhanced TLS indicator with an emphasis on information about the Root Certificate Authority from which the connection's authenticity is derived
https://addons.mozilla.org/en-US/firefox/addon/cerdicator/
1 stars 3 forks source link

Icon status isn't separate between tabs #1

Closed James-E-A closed 4 years ago

James-E-A commented 4 years ago

If you load 2 tabs: Google, and Sectigo, the icon will stay stuck at the logo of the second one you loaded, rather than being set appropriately on a per-tab basis.

Every time a new tab loads, it changes the icon across all tabs

If you look at the code, it's a simple enough "fix" to set tabId when setting the icon… but, when I do this, it instantly (like, 1 frame later) goes back to the default icon. ARGH.

James-E-A commented 4 years ago

contributed solution from some people online (they requested not to be credited per se)

have not tested/evaluated yet

I may refactor further

//foreground.js
function loadDidComplete() {
    browser.runtime.sendMessage("PAGE_LOAD_COMPLETED");
}

if (document.readyState === "complete") {
    loadDidComplete();
} else {
    window.addEventListener('DOMContentLoaded', loadDidComplete);
}
//background.js
var pageLoadCallbacks = {};

browser.runtime.onMessage.addListener((message, sender, callback)  => {
    if (message  ===  "PAGE_LOAD_COMPLETED") {
        if (sender.url in pageLoadCallbacks) {
            var pageLoadCallback = pageLoadCallbacks[sender.url];
            pageLoadCallback();
            delete pageLoadCallbacks[sender.url];
        }
    }
});

browser.webRequest.onHeadersReceived.addListener(
    async (details) => {
...
        pageLoadCallbacks[details.url] = () => {
            browser.browserAction.setIcon({
                tabId: tabId,
                path: path
            });
            browser.browserAction.setTitle({
                tabId: tabId,
                title: rootHost||`?? ${fp} ??`
            });
        }
...
James-E-A commented 4 years ago

Closed by 6dfb4beee58588c73995b6c4e45a0afec7869c10

James-E-A commented 4 years ago

7 is the successor of this issue

fix one bug, induce 2 more