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
Firefox extension - getWindowValue() does not work

I am trying to create a Firefox extension using the sessions api to display an attribute from each recently closed session.

The code directly below works as expected. For each recently closed session, the link textContent is set to the sessions sessionId:

function listSessions() {
  browser.sessions.getRecentlyClosed().then((sessions) => {
    let sessionList = document.getElementById("session-list");
    let sessionDisplay = document.createDocumentFragment();
    sessionList.textContent = '';

    for (let session of sessions) {
      if (session.window) {
        let sessionLink = document.createElement('a');
        
        sessionLink.textContent = session.window.sessionId;

        sessionLink.setAttribute('href', session.sessionId);
        sessionLink.classList.add('switch-tabs');
        sessionDisplay.appendChild(sessionLink);
      }
    }

    sessionList.appendChild(sessionDisplay);
  });
}

However, when I try to set the textContent by getting information from browser.sessions, the links are not displayed at all. I would expect this code to name the links either "success" or "fail".

function listSessions() {
  browser.sessions.getRecentlyClosed().then((sessions) => {
    let sessionList = document.getElementById("session-list");
    let sessionDisplay = document.createDocumentFragment();
    sessionList.textContent = '';

    for (let session of sessions) {
      if (session.window) {
        let sessionLink = document.createElement('a');
        
        browser.sessions.getWindowValue(
          session.window.sessionId,
          'name'
        ).then((a) => {sessionLink.textContent = "success";}, (b) => {sessionLink.textContent = "fail";});
        
        sessionLink.setAttribute('href', session.sessionId);
        sessionLink.classList.add('switch-tabs');
        sessionDisplay.appendChild(sessionLink);
      }
    }

    sessionList.appendChild(sessionDisplay);
  });
}

Update: When I set "session.window.sessionId" manually to 0, the links do get named "fail". Also, when I set it to 1, the links do get named "success". Not sure why yet.

about 4 years ago · Santiago Gelvez
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!