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

151
Views
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 answers
Answer question

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 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!