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

154
Vistas
Firefox: captureVisibleTab appears to hang

I am trying to make a Firefox extension that will add a button to take a screenshot of the active tab. When I call 'captureVisibleTab', the call seems to hang - the function never executes the next line. Minimal code to show the problem:

let shotBtn = document.createElement("button");
shotBtn.innerHTML = "Shot";
shotBtn.onclick = function () {
    takeShot();
};
document.body.appendChild(leftBtn);

async function takeShot() {
    leftBtn.innerHTML = "Start"; // This line executes.
    const shot = await browser.tabs.captureVisibleTab();
    leftBtn.innerHTML = "Done";  // This line does not.
}

I see the button text change to "Start", but I do not see it change to "Done".

I've tried some variants: Remove the 'await' and add "shot.then" handling instead, and putting the captureVisibleTab call directly in the onclick method instead of a separate async method. I've added the permission "<all_urls>" in my manifest, but am not certain I have been granted the permission - is there a way to check this?

I'm new to JavaScript and web extensions generally so there may well be some fundamental flaw in my understanding of how this asynchronous function should work. Is it possible some garbage collector is grabbing up the function object before it finishes executing? If so, how can I avoid this in an 'onclick' method?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I should have read a little more deeply before writing up my question. I was trying to do the above in a content script, which doesn't allow using captureVisibleTab; you have to do that in a background script. If, like me, you're a noob to web dev and just learned that this distinction exists, you can read about it here.

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