Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
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 Respuestas
Responde la pregunta

0

It's a bug in Chromium.

Suggests an invalid filepath. But it works.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda