blob: 55fbb070a3b482b1546a52eef0285f9e7e5483f0 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>Cross-realm XPathNSResolver throws TypeError of its associated Realm</title>
<link rel="help" href="https://webidl.spec.whatwg.org/#ref-for-prepare-to-run-script">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="resources/invalid_namespace_test.js"></script>
<iframe name="resolverGlobalObject" src="resources/empty-document.html"></iframe>
<script>
setup({ allow_uncaught_exception: true });
const iframeLoaded = new Promise(resolve => { window.addEventListener("load", resolve); });
promise_test(async t => {
await iframeLoaded;
const resolver = new resolverGlobalObject.Object;
return promise_rejects_js(t, resolverGlobalObject.TypeError,
invalid_namespace_test(t, resolver, resolverGlobalObject)
);
}, "XPathNSResolver is cross-realm plain object without 'lookupNamespaceURI' property");
promise_test(async t => {
await iframeLoaded;
const resolver = new resolverGlobalObject.Object;
resolver.lookupNamespaceURI = {};
return promise_rejects_js(t, resolverGlobalObject.TypeError,
invalid_namespace_test(t, resolver, resolverGlobalObject)
);
}, "XPathNSResolver is cross-realm plain object with non-callable 'lookupNamespaceURI' property");
promise_test(async t => {
await iframeLoaded;
const { proxy, revoke } = Proxy.revocable(() => {}, {});
revoke();
const resolver = new resolverGlobalObject.Object;
resolver.lookupNamespaceURI = proxy;
return promise_rejects_js(t, resolverGlobalObject.TypeError,
invalid_namespace_test(t, resolver, resolverGlobalObject)
);
}, "XPathNSResolver is cross-realm plain object with revoked Proxy as 'lookupNamespaceURI' property");
promise_test(async t => {
await iframeLoaded;
const { proxy, revoke } = resolverGlobalObject.Proxy.revocable({}, {});
revoke();
return promise_rejects_js(t, resolverGlobalObject.TypeError,
invalid_namespace_test(t, proxy, resolverGlobalObject)
);
}, "XPathNSResolver is cross-realm non-callable revoked Proxy");
promise_test(async t => {
await iframeLoaded;
const { proxy, revoke } = resolverGlobalObject.Proxy.revocable(() => {}, {});
revoke();
return promise_rejects_js(t, resolverGlobalObject.TypeError,
invalid_namespace_test(t, proxy, resolverGlobalObject)
);
}, "XPathNSResolver is cross-realm callable revoked Proxy");
</script>