Commit d5c7f690 authored by Henrik Skupin's avatar Henrik Skupin
Browse files

Bug 1789659 - [remote] Make TabManager.removeTab asynchronous. r=webdriver-reviewers,jdescottes

parent 91ed81b7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ class Target extends Domain {
    return { targetId: target.id };
  }

  closeTarget(options = {}) {
  async closeTarget(options = {}) {
    const { targetId } = options;
    const { targetList } = this.session.target;
    const target = targetList.getById(targetId);
@@ -114,7 +114,7 @@ class Target extends Domain {
      throw new Error(`Unable to find target with id '${targetId}'`);
    }

    lazy.TabManager.removeTab(target.tab);
    await lazy.TabManager.removeTab(target.tab);
  }

  async activateTarget(options = {}) {
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ add_task(async function triggersTargetDestroyed({ client, tab }) {
  const targetDestroyed = Target.targetDestroyed();

  info("Closing the target");
  Target.closeTarget({ targetId: targetInfo.targetId });
  await Target.closeTarget({ targetId: targetInfo.targetId });

  await tabClosed;
  info("Tab was closed");
+3 −3
Original line number Diff line number Diff line
@@ -211,7 +211,7 @@ browser.Context = class {
   * @throws UnsupportedOperationError
   *     If tab handling for the current application isn't supported.
   */
  closeTab() {
  async closeTab() {
    // If the current window is not a browser then close it directly. Do the
    // same if only one remaining tab is open, or no tab selected at all.
    //
@@ -233,10 +233,10 @@ browser.Context = class {
    let tabClosed;

    if (lazy.AppInfo.isAndroid) {
      lazy.TabManager.removeTab(this.tab);
      await lazy.TabManager.removeTab(this.tab);
    } else if (lazy.AppInfo.isFirefox) {
      tabClosed = new lazy.EventPromise(this.tab, "TabClose");
      this.tabBrowser.removeTab(this.tab);
      await this.tabBrowser.removeTab(this.tab);
    } else {
      throw new lazy.error.UnsupportedOperationError(
        `closeTab() not supported for ${lazy.AppInfo.name}`
+2 −2
Original line number Diff line number Diff line
@@ -264,10 +264,10 @@ var TabManager = {
   * @param {Tab} tab
   *     Tab to remove.
   */
  removeTab(tab) {
  async removeTab(tab) {
    const ownerWindow = this._getWindowForTab(tab);
    const tabBrowser = this.getTabBrowser(ownerWindow);
    tabBrowser.removeTab(tab);
    await tabBrowser.removeTab(tab);
  },

  /**
+3 −2
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ class BrowsingContextModule extends Module {
   * @throws {InvalidArgumentError}
   *     If the browsing context is not a top-level one.
   */
  close(options = {}) {
  async close(options = {}) {
    const { context: contextId } = options;

    lazy.assert.string(
@@ -134,7 +134,8 @@ class BrowsingContextModule extends Module {
    const browser = context.embedderElement;
    const tabBrowser = lazy.TabManager.getTabBrowser(browser.ownerGlobal);
    const tab = tabBrowser.getTabForBrowser(browser);
    lazy.TabManager.removeTab(tab);

    await lazy.TabManager.removeTab(tab);
  }

  /**
Loading