Commit b99f663c authored by Sandor Molnar's avatar Sandor Molnar
Browse files

Backed out changeset 8ef568d7513d (bug 1834971) for causing leakcheck failures. CLOSED TREE

parent 2f2588cf
Loading
Loading
Loading
Loading
+1 −6
Original line number Diff line number Diff line
@@ -159,12 +159,7 @@ async function webdriverClickElement(el, a11y) {
  let clickPoint = lazy.element.getInViewCentrePoint(rects[0], win);

  if (lazy.element.isObscured(containerEl)) {
    throw new lazy.error.ElementClickInterceptedError(
      null,
      {},
      containerEl,
      clickPoint
    );
    throw new lazy.error.ElementClickInterceptedError(containerEl, clickPoint);
  }

  let acc = await a11y.assertAccessible(el, true);
+83 −283
Original line number Diff line number Diff line
@@ -175,29 +175,18 @@ export const error = {
 */
class WebDriverError extends RemoteError {
  /**
   * Base error for WebDriver protocols.
   *
   * @param {(string|Error)=} obj
   * @param {(string|Error)=} x
   *     Optional string describing error situation or Error instance
   *     to propagate.
   * @param {object=} data
   *     Additional error data helpful in diagnosing the error.
   */
  constructor(obj, data = {}) {
    super(obj);

  constructor(x) {
    super(x);
    this.name = this.constructor.name;
    this.status = "webdriver error";
    this.data = data;

    // Error's ctor does not preserve x' stack
    if (error.isError(obj)) {
      this.stack = obj.stack;
    }

    if (error.isWebDriverError(obj)) {
      this.message = obj.message;
      this.data = obj.data;
    if (error.isError(x)) {
      this.stack = x.stack;
    }
  }

@@ -206,18 +195,11 @@ class WebDriverError extends RemoteError {
   *     JSON serialisation of error prototype.
   */
  toJSON() {
    const result = {
    return {
      error: this.status,
      message: this.message || "",
      stacktrace: this.stack || "",
    };

    // Only add the field if additional data has been specified.
    if (Object.keys(this.data).length) {
      result.data = this.data;
    }

    return result;
  }

  /**
@@ -247,25 +229,14 @@ class WebDriverError extends RemoteError {
    if ("stacktrace" in json) {
      err.stack = json.stacktrace;
    }
    if ("data" in json) {
      err.data = json.data;
    }

    return err;
  }
}

/**
 * The Gecko a11y API indicates that the element is not accessible.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** The Gecko a11y API indicates that the element is not accessible. */
class ElementNotAccessibleError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "element not accessible";
  }
}
@@ -274,61 +245,41 @@ class ElementNotAccessibleError extends WebDriverError {
 * An element click could not be completed because the element receiving
 * the events is obscuring the element that was requested clicked.
 *
 * @param {string=} message
 *     Optional string describing error situation. Will be replaced if both
 *     `data.obscuredEl` and `data.coords` are provided.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 * @param {Element=} obscuredEl
 *     Element obscuring the element receiving the click.  Providing this
 *     is not required, but will produce a nicer error message.
 * @param {Map.<string, number>=} coords
 * @param {Map.<string, number>} coords
 *     Original click location.  Providing this is not required, but
 *     will produce a nicer error message.
 */
class ElementClickInterceptedError extends WebDriverError {
  constructor(message, data = {}, obscuredEl = undefined, coords = undefined) {
    let obscuredElDetails = null;
    let overlayingElDetails = null;

  constructor(obscuredEl = undefined, coords = undefined) {
    let msg = "";
    if (obscuredEl && coords) {
      const doc = obscuredEl.ownerDocument;
      const overlayingEl = doc.elementFromPoint(coords.x, coords.y);

      obscuredElDetails = lazy.pprint`${obscuredEl}`;
      overlayingElDetails = lazy.pprint`${overlayingEl}`;

      switch (obscuredEl.style.pointerEvents) {
        case "none":
          message =
            `Element ${obscuredElDetails} is not clickable ` +
          msg =
            lazy.pprint`Element ${obscuredEl} is not clickable ` +
            `at point (${coords.x},${coords.y}) ` +
            `because it does not have pointer events enabled, ` +
            `and element ${overlayingElDetails} ` +
            lazy.pprint`and element ${overlayingEl} ` +
            `would receive the click instead`;
          break;

        default:
          message =
            `Element ${obscuredElDetails} is not clickable ` +
          msg =
            lazy.pprint`Element ${obscuredEl} is not clickable ` +
            `at point (${coords.x},${coords.y}) ` +
            `because another element ${overlayingElDetails} ` +
            lazy.pprint`because another element ${overlayingEl} ` +
            `obscures it`;
          break;
      }
    }

    if (coords) {
      data.coords = coords;
    }
    if (obscuredElDetails) {
      data.obscuredElement = obscuredElDetails;
    }
    if (overlayingElDetails) {
      data.overlayingElement = overlayingElDetails;
    }

    super(message, data);
    super(msg);
    this.status = "element click intercepted";
  }
}
@@ -336,15 +287,10 @@ class ElementClickInterceptedError extends WebDriverError {
/**
 * A command could not be completed because the element is not pointer-
 * or keyboard interactable.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class ElementNotInteractableError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "element not interactable";
  }
}
@@ -352,30 +298,18 @@ class ElementNotInteractableError extends WebDriverError {
/**
 * Navigation caused the user agent to hit a certificate warning, which
 * is usually the result of an expired or invalid TLS certificate.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class InsecureCertificateError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "insecure certificate";
  }
}

/**
 * The arguments passed to a command are either invalid or malformed.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** The arguments passed to a command are either invalid or malformed. */
class InvalidArgumentError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "invalid argument";
  }
}
@@ -383,15 +317,10 @@ class InvalidArgumentError extends WebDriverError {
/**
 * An illegal attempt was made to set a cookie under a different
 * domain than the current page.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class InvalidCookieDomainError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "invalid cookie domain";
  }
}
@@ -400,30 +329,18 @@ class InvalidCookieDomainError extends WebDriverError {
 * A command could not be completed because the element is in an
 * invalid state, e.g. attempting to clear an element that isn't both
 * editable and resettable.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class InvalidElementStateError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "invalid element state";
  }
}

/**
 * Argument was an invalid selector.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** Argument was an invalid selector. */
class InvalidSelectorError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "invalid selector";
  }
}
@@ -431,30 +348,18 @@ class InvalidSelectorError extends WebDriverError {
/**
 * Occurs if the given session ID is not in the list of active sessions,
 * meaning the session either does not exist or that it's not active.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class InvalidSessionIDError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "invalid session id";
  }
}

/**
 * An error occurred whilst executing JavaScript supplied by the user.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** An error occurred whilst executing JavaScript supplied by the user. */
class JavaScriptError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(x) {
    super(x);
    this.status = "javascript error";
  }
}
@@ -462,15 +367,10 @@ class JavaScriptError extends WebDriverError {
/**
 * The target for mouse interaction is not in the browser's viewport
 * and cannot be brought into that viewport.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class MoveTargetOutOfBoundsError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "move target out of bounds";
  }
}
@@ -478,15 +378,10 @@ class MoveTargetOutOfBoundsError extends WebDriverError {
/**
 * An attempt was made to operate on a modal dialog when one was
 * not open.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchAlertError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such alert";
  }
}
@@ -494,60 +389,40 @@ class NoSuchAlertError extends WebDriverError {
/**
 * An element could not be located on the page using the given
 * search parameters.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchElementError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such element";
  }
}

/**
 * A command tried to remove an unknown preload script.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchScriptError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such script";
  }
}

/**
 * A shadow root was not attached to the element.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchShadowRootError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such shadow root";
  }
}

/**
 * A shadow root is no longer attached to the document.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 * A shadow root is no longer attached to the document
 */
class DetachedShadowRootError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "detached shadow root";
  }
}
@@ -555,30 +430,20 @@ class DetachedShadowRootError extends WebDriverError {
/**
 * A command to switch to a frame could not be satisfied because
 * the frame could not be found.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchFrameError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such frame";
  }
}

/**
 * The handle of a strong object reference could not be found.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 * The handle of a strong object reference could not be found
 */
class NoSuchHandleError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such handle";
  }
}
@@ -586,15 +451,10 @@ class NoSuchHandleError extends WebDriverError {
/**
 * A node as given by its unique shared id could not be found within the cache
 * of known nodes.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchNodeError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such node";
  }
}
@@ -602,45 +462,26 @@ class NoSuchNodeError extends WebDriverError {
/**
 * A command to switch to a window could not be satisfied because
 * the window could not be found.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class NoSuchWindowError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "no such window";
  }
}

/**
 * A script did not complete before its timeout expired.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** A script did not complete before its timeout expired. */
class ScriptTimeoutError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "script timeout";
  }
}

/**
 * A new session could not be created.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** A new session could not be created. */
class SessionNotCreatedError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "session not created";
  }
}
@@ -648,60 +489,34 @@ class SessionNotCreatedError extends WebDriverError {
/**
 * A command failed because the referenced element is no longer
 * attached to the DOM.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class StaleElementReferenceError extends WebDriverError {
  constructor(message, options = {}) {
    super(message, options);
  constructor(message) {
    super(message);
    this.status = "stale element reference";
  }
}

/**
 * An operation did not complete before its timeout expired.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** An operation did not complete before its timeout expired. */
class TimeoutError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "timeout";
  }
}

/**
 * A command to set a cookie's value could not be satisfied.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** A command to set a cookie's value could not be satisfied. */
class UnableToSetCookieError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "unable to set cookie";
  }
}

/**
 * A modal dialog was open, blocking this operation.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
/** A modal dialog was open, blocking this operation. */
class UnexpectedAlertOpenError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "unexpected alert open";
  }
}
@@ -709,15 +524,10 @@ class UnexpectedAlertOpenError extends WebDriverError {
/**
 * A command could not be executed because the remote end is not
 * aware of it.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class UnknownCommandError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "unknown command";
  }
}
@@ -725,15 +535,10 @@ class UnknownCommandError extends WebDriverError {
/**
 * An unknown error occurred in the remote end while processing
 * the command.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class UnknownError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "unknown error";
  }
}
@@ -741,15 +546,10 @@ class UnknownError extends WebDriverError {
/**
 * Indicates that a command that should have executed properly
 * cannot be supported for some reason.
 *
 * @param {string=} message
 *     Optional string describing error situation.
 * @param {object=} data
 *     Additional error data helpful in diagnosing the error.
 */
class UnsupportedOperationError extends WebDriverError {
  constructor(message, data = {}) {
    super(message, data);
  constructor(message) {
    super(message);
    this.status = "unsupported operation";
  }
}
+110 −172

File changed.

Preview size limit exceeded, changes collapsed.