summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/domxpath/resources/invalid_namespace_test.js
blob: 8b934eff4e8d14d41ec30caecfcd4a7dcad305bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"use strict";
setup({ allow_uncaught_exception: true });

const invalid_namespace_test = (t, resolver, resolverWindow = window) => {
  const result = new Promise((resolve, reject) => {
    const handler = event => {
      reject(event.error);
    };

    resolverWindow.addEventListener("error", handler);
    t.add_cleanup(() => {
      resolverWindow.removeEventListener("error", handler);
    });

    t.step_timeout(resolve, 0);
  });

  assert_throws_dom("NAMESPACE_ERR", () => {
    document.evaluate("/foo:bar", document.documentElement, resolver);
  });

  return result;
};