Commit 75454ab1 authored by Natalia Csoregi's avatar Natalia Csoregi
Browse files

Backed out 2 changesets (bug 1828816) for frequent failures on /html-aam/roles.html CLOSED TREE

Backed out changeset f3f51a672d70 (bug 1828816)
Backed out changeset 190da2ededf7 (bug 1828816)
parent 758b1779
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -140,34 +140,7 @@ accessibility.getAccessible = async function(element) {
  }

  // First, wait for accessibility to be ready for the element's document.
  // We do not use a timeout here because we can guarantee that the document
  // accessible will be ready eventually, even if it takes a while.
  await waitForDocumentAccessibility(element.ownerDocument);

  const acc = accessibility.service.getAccessibleFor(element);
  if (acc) {
    return acc;
  }

  // The Accessible doesn't exist yet. This can happen because a11y tree
  // mutations happen during refresh driver ticks. Wait for a11y events,
  // checking after each event to see if the Accessible exists yet and returning
  // it if it does. Stop waiting after a short timeout because the Accessible
  // might never be created and we want to report a failure without breaking
  // subsequent tests.
  try {
    await lazy.waitForObserverTopic("accessible-event", {
      checkFn: subject => {
        return !!accessibility.service.getAccessibleFor(element);
      },
      timeout: 500,
    });
  } catch (e) {
    // Don't treat a timeout as an error. We will most likely return null below.
    if (!(e instanceof lazy.error.TimeoutError)) {
      throw e;
    }
  }
  return accessibility.service.getAccessibleFor(element);
};

+8 −49
Original line number Diff line number Diff line
@@ -468,73 +468,32 @@ export function waitForMessage(
 *     if the notification is the expected one, or false if it should be
 *     ignored and listening should continue. If not specified, the first
 *     notification for the specified topic resolves the returned promise.
 * @param {number=} options.timeout
 *     Timeout duration in milliseconds, if provided.
 *     If specified, then the returned promise will be rejected with
 *     TimeoutError, if not already resolved, after this duration has elapsed.
 *     If not specified, then no timeout is used. Defaults to null.
 *
 * @returns {Promise.<Array<string, object>>}
 *     Promise which is either resolved to an array of ``subject``, and ``data``
 *     from the observed notification, or rejected with TimeoutError after
 *     options.timeout milliseconds if specified.
 *
 * @throws {TypeError}
 * @throws {RangeError}
 *     Promise which resolves to an array of ``subject``, and ``data`` from
 *     the observed notification.
 */
export function waitForObserverTopic(topic, options = {}) {
  const { checkFn = null, timeout = null } = options;
export function waitForObserverTopic(topic, { checkFn = null } = {}) {
  if (typeof topic != "string") {
    throw new TypeError();
  }
  if (
    (checkFn != null && typeof checkFn != "function") ||
    (timeout !== null && typeof timeout != "number")
  ) {
  if (checkFn != null && typeof checkFn != "function") {
    throw new TypeError();
  }
  if (timeout && (!Number.isInteger(timeout) || timeout < 0)) {
    throw new RangeError();
  }

  return new Promise((resolve, reject) => {
    let timer;

    function cleanUp() {
      Services.obs.removeObserver(observer, topic);
      timer?.cancel();
    }

    function observer(subject, topic, data) {
    Services.obs.addObserver(function observer(subject, topic, data) {
      lazy.logger.trace(`Received observer notification ${topic}`);
      try {
        if (checkFn && !checkFn(subject, data)) {
          return;
        }
        cleanUp();
        Services.obs.removeObserver(observer, topic);
        resolve({ subject, data });
      } catch (ex) {
        cleanUp();
        Services.obs.removeObserver(observer, topic);
        reject(ex);
      }
    }

    Services.obs.addObserver(observer, topic);

    if (timeout !== null) {
      timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
      timer.init(
        () => {
          cleanUp();
          reject(
            new lazy.error.TimeoutError(
              `waitForObserverTopic timed out after ${timeout} ms`
            )
          );
        },
        timeout,
        TYPE_ONE_SHOT
      );
    }
    }, topic);
  });
}
+0 −35
Original line number Diff line number Diff line
@@ -382,38 +382,3 @@ add_task(async function test_waitForObserverTopic_checkFnTypes() {
    equal(expected_data, result.data);
  }
});

add_task(async function test_waitForObserverTopic_timeoutTypes() {
  for (let timeout of ["foo", true, [], {}]) {
    Assert.throws(
      () => waitForObserverTopic("message", { timeout }),
      /TypeError/
    );
  }
  for (let timeout of [1.2, -1]) {
    Assert.throws(
      () => waitForObserverTopic("message", { timeout }),
      /RangeError/
    );
  }
  for (let timeout of [null, undefined, 42]) {
    let data = { foo: "bar" };
    let sent = waitForObserverTopic("message", { timeout });
    Services.obs.notifyObservers(this, "message", data);
    let result = await sent;
    equal(this, result.subject);
    equal(data, result.data);
  }
});

add_task(async function test_waitForObserverTopic_timeoutElapse() {
  try {
    await waitForObserverTopic("message", { timeout: 0 });
    ok(false, "Expected Timeout error not raised");
  } catch (e) {
    ok(
      e.message.includes("waitForObserverTopic timed out after"),
      "Expected error received"
    );
  }
});
+147 −0
Original line number Diff line number Diff line
[roles.html]
  [role: alertdialog]
    expected: [PASS, FAIL]

  [role: application]
    expected: [PASS, FAIL]

  [role: article]
    expected: [PASS, FAIL]

  [role: banner]
    expected: [PASS, FAIL]

  [role: button]
    expected: [PASS, FAIL]

  [role: checkbox]
    expected: [PASS, FAIL]

  [role: combobox]
    expected: [PASS, FAIL]

  [role: complementary]
    expected: [PASS, FAIL]

  [role: contentinfo]
    expected: [PASS, FAIL]

  [role: definition]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1829028

  [role: deletion]
    expected: [PASS, FAIL]

  [role: document]
    expected: [PASS, FAIL]

  [role: emphasis]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306

  [role: feed]
    expected: [PASS, FAIL]

  [role: generic]
    expected: [PASS, FAIL]

  [role: group]
    expected: [PASS, FAIL]

  [role: insertion]
    expected: [PASS, FAIL]

  [role: log]
    expected: [PASS, FAIL]

  [role: main]
    expected: [PASS, FAIL]

  [role: marquee]
    expected: [PASS, FAIL]

  [role: math]
    expected: [PASS, FAIL]

  [role: navigation]
    expected: [PASS, FAIL]

  [role: radio]
    expected: [PASS, FAIL]

  [role: radiogroup]
    expected: [PASS, FAIL]

  [role: search]
    expected: [PASS, FAIL]

  [role: searchbox]
    expected: [PASS, FAIL]

  [role: status]
    expected: [PASS, FAIL]

  [role: strong]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306

  [role: textbox]
    expected: [PASS, FAIL]

  [role: time]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1732306

  [role: timer]
    expected: [PASS, FAIL]

  [role: blockquote]
    expected: [PASS, FAIL]

  [role: caption]
    expected: [PASS, FAIL]

  [role: code]
    expected: [PASS, FAIL]

  [role: dialog]
    expected: [PASS, FAIL]

  [role: figure]
    expected: [PASS, FAIL]

  [role: form]
    expected: [PASS, FAIL]

  [role: heading]
    expected: [PASS, FAIL]

  [role: link]
    expected: [PASS, FAIL]

  [role: meter]
    expected: [PASS, FAIL]

  [role: note]
    expected: [PASS, FAIL]

  [role: paragraph]
    expected: [PASS, FAIL]

  [role: progressbar]
    expected: [PASS, FAIL]

  [role: scrollbar]
    expected: [PASS, FAIL]

  [role: separator]
    expected: [PASS, FAIL]

  [role: slider]
    expected: [PASS, FAIL]

  [role: spinbutton]
    expected: [PASS, FAIL]

  [role: subscript]
    expected: [PASS, FAIL]

  [role: suggestion]
    expected: [PASS, FAIL]

  [role: superscript]
    expected: [PASS, FAIL]

  [role: switch]
    expected: [PASS, FAIL]

  [role: term]
    expected: FAIL
    bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1829028

  [role: toolbar]
    expected: [PASS, FAIL]

  [role: tooltip]
    expected: [PASS, FAIL]