diff options
| author | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-21 16:54:34 +0900 | 
|---|---|---|
| committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2021-03-21 23:03:12 +0900 | 
| commit | 690c9c080a2a511a30d555a90e5005e06b750351 (patch) | |
| tree | 803a2c4de08fef75ad9f499d6e30866d16c6bef2 | |
| parent | b89a87220f93844a95266638b9eb01ec74732fb0 (diff) | |
change bootstrap order
| -rw-r--r-- | e2e/lib/Page.ts | 13 | ||||
| -rw-r--r-- | src/content/Application.ts | 8 | ||||
| -rw-r--r-- | src/content/index.ts | 14 | 
3 files changed, 23 insertions, 12 deletions
| diff --git a/e2e/lib/Page.ts b/e2e/lib/Page.ts index 46d67b0..13bf70f 100644 --- a/e2e/lib/Page.ts +++ b/e2e/lib/Page.ts @@ -122,8 +122,17 @@ export default class Page {      if (!topFrame) {        return;      } -    await webdriver.wait(until.elementLocated(By.id("vimvixen-console-frame"))); -    await webdriver.switchTo().frame(0); +    // style tag is injected at end of add-on loading +    await webdriver.wait(until.elementLocated(By.tagName("style"))); + +    const iframe = await webdriver.findElements( +      By.id("vimvixen-console-frame") +    ); +    if (iframe.length === 0) { +      return; +    } + +    await webdriver.switchTo().frame(iframe[0]);      await Page.waitForDocumentCompleted(webdriver);      await webdriver.switchTo().parentFrame();    } diff --git a/src/content/Application.ts b/src/content/Application.ts index 7c8e588..b09edfa 100644 --- a/src/content/Application.ts +++ b/src/content/Application.ts @@ -36,12 +36,12 @@ export default class Application {      private navigateController: NavigateController    ) {} -  run() { -    this.routeCommonComponents(); +  init(): Promise<void> {      this.routeFocusEvents();      if (window.self === window.top) {        this.routeMasterComponents();      } +    return this.routeCommonComponents();    }    private routeMasterComponents() { @@ -76,7 +76,7 @@ export default class Application {      });    } -  private routeCommonComponents() { +  private routeCommonComponents(): Promise<void> {      this.messageListener.onWebMessage((msg: Message) => {        switch (msg.type) {          case messages.FOLLOW_REQUEST_COUNT_TARGETS: @@ -117,7 +117,7 @@ export default class Application {      inputDriver.onKey((key) => this.markKeyController.press(key));      inputDriver.onKey((key) => this.keymapController.press(key)); -    this.settingController.initSettings(); +    return this.settingController.initSettings();    }    private routeFocusEvents() { diff --git a/src/content/index.ts b/src/content/index.ts index 20dbbcc..82f3a4c 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -7,12 +7,14 @@ import { container } from "tsyringe";  import "./di";  const initDom = () => { -  try { -    const app = container.resolve(Application); -    app.run(); -  } catch (e) { -    console.error(e); -  } +  (async () => { +    try { +      const app = container.resolve(Application); +      await app.init(); +    } catch (e) { +      console.error(e); +    } +  })();    const style = window.document.createElement("style");    style.textContent = consoleFrameStyle; | 
