Commit a386e492 authored by Kevin McNee's avatar Kevin McNee Committed by Commit Bot

Specify which window is creating exceptions in portals WPTs

promise_rejects_dom and promise_rejects_js are strict about which
constructor is being used for the exception. In portals WPTs, we
frequently open a new window to run the test as we can't destroy the
context the test harness is running in. We now specify which window is
producing the expected errors.

Bug: 1057783
Change-Id: Ia3b4b55a0a12f0df96fc4bed45cd7c82a97ed5d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2083826Reviewed-by: default avatarAdithya Srinivasan <adithyas@chromium.org>
Commit-Queue: Kevin McNee <mcnee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746124}
parent cd4cec6b
This is a testharness.js-based test.
FAIL about:blank cannot host a portal promise_rejects_dom: function "function() { throw e }" threw an exception from the wrong global
Harness: the test ran to completion.
...@@ -12,7 +12,7 @@ promise_test(async (t) => { ...@@ -12,7 +12,7 @@ promise_test(async (t) => {
portal.src = "resources/simple-portal.html"; portal.src = "resources/simple-portal.html";
hostWindow.document.body.appendChild(portal); hostWindow.document.body.appendChild(portal);
await promise_rejects_dom(t, "InvalidStateError", portal.activate()); await promise_rejects_dom(t, "InvalidStateError", hostWindow.DOMException, portal.activate());
}, "about:blank cannot host a portal"); }, "about:blank cannot host a portal");
</script> </script>
This is a testharness.js-based test.
PASS A string can be passed through activate data.
PASS An array buffer can be transferred through activate data.
PASS An image bitmap can be transferred through activate data.
PASS A message port can be passed through activate data.
FAIL A SharedArrayBuffer cannot be passed through activate data. promise_rejects_dom: function "function() { throw e }" threw an exception from the wrong global
PASS Uncloneable data has its exception propagated.
FAIL Errors during transfer list processing are propagated. promise_rejects_js: function "function() { throw e }" threw object "TypeError: Failed to execute 'activate' on 'HTMLPortalElement': Failed to convert value to 'object'." ("TypeError") expected instance of function "function TypeError() { [native code] }" ("TypeError")
Harness: the test ran to completion.
...@@ -12,9 +12,9 @@ function nextMessage(target) { ...@@ -12,9 +12,9 @@ function nextMessage(target) {
}); });
} }
async function openPortalAndActivate(logic, activateOptions) { async function openPortalAndActivate(logic, activateOptions, testWindow) {
assert_precondition("HTMLPortalElement" in self); assert_precondition("HTMLPortalElement" in self);
const w = await openBlankPortalHost(); const w = testWindow || await openBlankPortalHost();
try { try {
const portal = w.document.createElement('portal'); const portal = w.document.createElement('portal');
portal.src = new URL('resources/portal-activate-data-portal.html?logic=' + encodeURIComponent(logic), location.href); portal.src = new URL('resources/portal-activate-data-portal.html?logic=' + encodeURIComponent(logic), location.href);
...@@ -71,9 +71,10 @@ promise_test(async () => { ...@@ -71,9 +71,10 @@ promise_test(async () => {
}, "A message port can be passed through activate data."); }, "A message port can be passed through activate data.");
promise_test(async t => { promise_test(async t => {
await promise_rejects_dom( const w = await openBlankPortalHost();
t, 'DataCloneError', await promise_rejects_dom(
openPortalAndActivate('', {data: new SharedArrayBuffer})); t, 'DataCloneError', w.DOMException,
openPortalAndActivate('', {data: new SharedArrayBuffer}, w));
}, "A SharedArrayBuffer cannot be passed through activate data."); }, "A SharedArrayBuffer cannot be passed through activate data.");
promise_test(async t => { promise_test(async t => {
...@@ -83,9 +84,10 @@ promise_test(async t => { ...@@ -83,9 +84,10 @@ promise_test(async t => {
}, "Uncloneable data has its exception propagated."); }, "Uncloneable data has its exception propagated.");
promise_test(async t => { promise_test(async t => {
const w = await openBlankPortalHost();
await promise_rejects_js( await promise_rejects_js(
t, TypeError, t, w.TypeError,
openPortalAndActivate('', {data: null, transfer: [null]})); openPortalAndActivate('', {data: null, transfer: [null]}, w));
}, "Errors during transfer list processing are propagated."); }, "Errors during transfer list processing are propagated.");
</script> </script>
</body> </body>
This is a testharness.js-based test.
FAIL activating portal inside iframe should fail promise_rejects_dom: function "function() { throw e }" threw an exception from the wrong global
Harness: the test ran to completion.
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
document.body.appendChild(iframe); document.body.appendChild(iframe);
await waitForLoad; await waitForLoad;
const portal = iframe.contentDocument.getElementById("portal"); const portal = iframe.contentDocument.getElementById("portal");
return promise_rejects_dom(t, "InvalidStateError", portal.activate()); return promise_rejects_dom(t, "InvalidStateError",
iframe.contentWindow.DOMException,
portal.activate());
}, "activating portal inside iframe should fail"); }, "activating portal inside iframe should fail");
</script> </script>
</body> </body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment