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

173
Vistas
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
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