diff options
-rw-r--r-- | src/content/presenters/ConsoleFramePresenter.ts | 6 | ||||
-rw-r--r-- | src/content/usecases/AddonEnabledUseCase.ts | 10 | ||||
-rw-r--r-- | test/content/operators/impls/MockConsoleFramePresenter.ts | 4 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/content/presenters/ConsoleFramePresenter.ts b/src/content/presenters/ConsoleFramePresenter.ts index 9c4b3f1..0db58f0 100644 --- a/src/content/presenters/ConsoleFramePresenter.ts +++ b/src/content/presenters/ConsoleFramePresenter.ts @@ -6,6 +6,8 @@ export default interface ConsoleFramePresenter { blur(): void; resize(width: number, height: number): void; + + isTopWindow(): boolean; } export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { @@ -47,4 +49,8 @@ export class ConsoleFramePresenterImpl implements ConsoleFramePresenter { } ele.style.height = `${height}px`; } + + isTopWindow(): boolean { + return window.top === window; + } } diff --git a/src/content/usecases/AddonEnabledUseCase.ts b/src/content/usecases/AddonEnabledUseCase.ts index b45c47f..f49fde5 100644 --- a/src/content/usecases/AddonEnabledUseCase.ts +++ b/src/content/usecases/AddonEnabledUseCase.ts @@ -34,10 +34,12 @@ export default class AddonEnabledUseCase { private async setEnabled(on: boolean): Promise<void> { this.repository.set(on); - if (on) { - this.consoleFramePresenter.attach(); - } else { - this.consoleFramePresenter.detach(); + if (this.consoleFramePresenter.isTopWindow()) { + if (on) { + this.consoleFramePresenter.attach(); + } else { + this.consoleFramePresenter.detach(); + } } await this.indicator.setEnabled(on); } diff --git a/test/content/operators/impls/MockConsoleFramePresenter.ts b/test/content/operators/impls/MockConsoleFramePresenter.ts index f8ac70b..23bc27f 100644 --- a/test/content/operators/impls/MockConsoleFramePresenter.ts +++ b/test/content/operators/impls/MockConsoleFramePresenter.ts @@ -19,4 +19,8 @@ export default class MockConsoleFramePresenter resize(_width: number, _height: number): void { throw new Error("not implemented"); } + + isTopWindow(): boolean { + return true; + } } |