From a0f2c3ee107508e406a4a41cbda76ecd2d3f0d8f Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 25 Sep 2021 18:17:50 +0900 Subject: Discover frames on search by count of connections When a tab switches pages quickly, a disconnect event on top frame is sometime delivered after second connect event. In addition, `tabs.onUpdated()` event is independent on port connection event. Now the background script finds alive frames by only port connection. --- test/background/mock/MockReadyFrameRepository.ts | 4 ---- test/background/repositories/ReadyFrameRepository.test.ts | 13 ++++++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/background/mock/MockReadyFrameRepository.ts b/test/background/mock/MockReadyFrameRepository.ts index a95b2e1..4a5ec52 100644 --- a/test/background/mock/MockReadyFrameRepository.ts +++ b/test/background/mock/MockReadyFrameRepository.ts @@ -1,10 +1,6 @@ import ReadyFrameRepository from "../../../src/background/repositories/ReadyFrameRepository"; export default class MockReadyFrameRepository implements ReadyFrameRepository { - clearFrameIds(_tabId: number): Promise { - throw new Error("not implemented"); - } - addFrameId(_tabId: number, _fraemId: number): Promise { throw new Error("not implemented"); } diff --git a/test/background/repositories/ReadyFrameRepository.test.ts b/test/background/repositories/ReadyFrameRepository.test.ts index 888f3f5..71f20af 100644 --- a/test/background/repositories/ReadyFrameRepository.test.ts +++ b/test/background/repositories/ReadyFrameRepository.test.ts @@ -15,12 +15,19 @@ describe("background/repositories/ReadyFrameRepositoryImpl", () => { await sut.addFrameId(1, 12); await sut.addFrameId(1, 11); await sut.addFrameId(2, 20); + await sut.addFrameId(2, 21); + await sut.addFrameId(2, 21); expect(await sut.getFrameIds(1)).to.deep.equal([10, 11, 12]); - expect(await sut.getFrameIds(2)).to.deep.equal([20]); + expect(await sut.getFrameIds(2)).to.deep.equal([20, 21]); - await sut.clearFrameIds(1); + await sut.removeFrameId(2, 21); + expect(await sut.getFrameIds(2)).to.deep.equal([20, 21]); - expect(await sut.getFrameIds(1)).to.be.undefined; + await sut.removeFrameId(2, 21); + expect(await sut.getFrameIds(2)).to.deep.equal([20]); + + await sut.removeFrameId(2, 20); + expect(await sut.getFrameIds(2)).to.be.undefined; }); }); -- cgit v1.2.3