diff --git a/test/account-boundary.test.js b/test/account-boundary.test.js index bc418349..8fd3fe26 100644 --- a/test/account-boundary.test.js +++ b/test/account-boundary.test.js @@ -1118,3 +1118,22 @@ test('a transient passive owner read failure cannot be mistaken for absent owner assert.equal(b.reloads(), 0); } finally { b.close(); } }); + +test('the same person signing in again in another tab is adopted, not reloaded', async () => { + // Opening the app in a second tab while signed in elsewhere makes a new + // session for the same account. The old tab used to freeze with "Your + // account session changed" — the message meant for a *different* account + // taking over the cookie. The same owner is adopted silently; a different + // one, or none, still reloads. + const b = await browser(); + b.owner(1); + const shared = JSON.parse(b.w.localStorage.getItem(b.c.AccountBoundary.key)); + b.storageMessage({ ...shared, generation: 'another-tab-same-person' }); + assert.equal(b.c.AccountBoundary.blocked(), false, 'not frozen'); + assert.equal(b.reloads(), 0, 'not reloaded'); + assert.equal(b.c.AccountBoundary.capture(), 1, 'still working as the same owner'); + b.storageMessage({ ...shared, owner: 2, generation: 'another-tab-other-person' }); + assert.equal(b.c.AccountBoundary.blocked(), true, 'a different account still freezes this tab'); + assert.ok(b.reloads()); + b.close(); +});