Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

164
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda