Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

176
Views
chrome.action.setIcon failureCallback is not a function

I'm trying to change the extension icon depending on what is found in the URL, the below works but i get an error:

Uncaught (in promise) TypeError: failureCallback is not a function Context extensions::setIcon Stack Trace

I feel sure this is a woods for the trees thing. Can anyone help?

//get url of the page we are on in the tab
async function getTab() {
  let queryOptions = { active: true, currentWindow: true };
  let tabs = await chrome.tabs.query(queryOptions);
  return tabs[0];
};
                
var tab;
                
//listen for the following two events - when they happen run the colourIcon function
chrome.tabs.onActivated.addListener(colourIcon);
chrome.tabs.onUpdated.addListener(colourIcon);
                
async function colourIcon(){
  let urlCol = await getTab()
  let url = urlCol.url
  tab = urlCol.id
  if (url.indexOf("d") > -1) {
    changeIconColour("purple");
  } else if (url.indexOf("b") > -1) {
    changeIconColour("purple");
  } else if (url.indexOf("a") > -1) {
    changeIconColour("purple");
  } else { // if there is no match, you can't get the data
    changeIconColour("grey");
  };
}
            
function changeIconColour(colour) {
  let pathToIcons;
  //change the path to the icon folder depending on what colour is sent to the function
  if (colour == "purple") {
    pathToIcons = "/";
  } else {
    pathToIcons = "grey/";
  }
            
  // and set the icon
  chrome.action.setIcon({
    path: {
      "16": "/assets/icons" + pathToIcons + "extension_toolbar_icon16.png",
      "32": "/assets/icons" + pathToIcons + "extension_toolbar_icon32.png",
      "48": "/assets/icons" + pathToIcons + "extension_toolbar_icon48.png",
      "128": "/assets/icons" + pathToIcons + "extension_toolbar_icon128.png"
    },
    tabId: tab
    })
  };

The error is at extensions::setIcon:35, which is the line starting "failure", here:

$Promise.catch(imageDataPromise, function(error) {
    failureCallback(exceptionHandler.safeErrorToString(error, true));
  });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It's a bug in Chromium.

Suggests an invalid filepath. But it works.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!