diff options
Diffstat (limited to 'test-suite/unit/session-cleanup.test.mjs')
| -rw-r--r-- | test-suite/unit/session-cleanup.test.mjs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test-suite/unit/session-cleanup.test.mjs b/test-suite/unit/session-cleanup.test.mjs index 7e3285f..604e691 100644 --- a/test-suite/unit/session-cleanup.test.mjs +++ b/test-suite/unit/session-cleanup.test.mjs @@ -19,7 +19,7 @@ function harness(send, sessionKey = "session:test") { const events = []; let shutdown; const token = Symbol(); - const globalState = { loaded: { token } }; + const globalState = { loaded: { token }, auth: { until: "indefinite" } }; const context = { AbortController, Promise, setTimeout(fn, ms) { const key = Symbol(); timers.set(key, { fn, ms }); return key; }, @@ -27,7 +27,7 @@ function harness(send, sessionKey = "session:test") { bridge: { send(...args) { events.push("send"); return send(...args); }, stop() { events.push("stop"); } }, sessionCtx: {}, sessionKeyFor: () => sessionKey ?? undefined, clearAuthExpiryTimer() {}, clearCountdownInterval() {}, - globalState, PI_CHROME_GLOBAL_KEY: "loaded", instanceToken: token, + globalState, PI_CHROME_GLOBAL_KEY: "loaded", PI_CHROME_AUTH_KEY: "auth", instanceToken: token, pi: { on(name, handler) { assert.equal(name, "session_shutdown"); shutdown = handler; } }, }; vm.runInNewContext(`${helper}\n${listener}`, context); @@ -78,6 +78,14 @@ for (const reason of ["quit", "new", "resume", "fork"]) { const h = harness(() => Promise.resolve({})); await h.shutdown({ reason }); assert.deepEqual(h.events, ["send", "stop"]); + // A /chrome authorize grant stays with its session: a session switch drops it, quit leaves it + // for a parent session sharing this process. + assert.equal("auth" in h.globalState, reason === "quit", `grant after ${reason}`); +} +{ + const h = harness(() => Promise.resolve({})); + await h.shutdown({ reason: "reload" }); + assert.deepEqual(h.globalState.auth, { until: "indefinite" }, "grant after reload"); } for (const send of [() => Promise.reject(new Error("offline")), () => { throw new Error("offline"); }]) { const h = harness(send); @@ -90,4 +98,4 @@ for (const send of [() => Promise.reject(new Error("offline")), () => { throw ne await h.shutdown({ reason: "exit" }); assert.deepEqual(h.events, ["stop"]); } -console.log("session-cleanup: shutdown ordering, reload, deadline, failures, and missing identity passed"); +console.log("session-cleanup: shutdown ordering, reload, deadline, failures, missing identity, and grant scope passed"); |
