Bug 1565079 [wpt PR 17744] - Portals: Allow adopted portal to be activated without insertion, a=testonly

Automatic update from web-platform-tests
Portals: Allow adopted portal to be activated without insertion

This CL allows us to activate an adopted predecessor inside the
onportalactivtate event handler without inserting it into the DOM.

Bug: 971709
Change-Id: Idbbbaf89080d19d19e9782376c4e51558c07e81b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1690387
Reviewed-by: Lucas Gadani <lfg@chromium.org>
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#677580}

--

wpt-commits: 787e5a9ad59f8c04ee3ac0a2a7241dd2152ca601
wpt-pr: 17744
This commit is contained in:
Adithya Srinivasan 2019-07-22 11:08:14 +00:00 коммит произвёл James Graham
Родитель 33a073b75f
Коммит 876e39e511
3 изменённых файлов: 34 добавлений и 0 удалений

Просмотреть файл

@ -35,4 +35,21 @@
});
window.open(`resources/portals-adopt-predecessor.html?test=${test}`);
}, "Tests that trying to adopt the predecessor after the PortalActivateEvent will throw an exception.");
promise_test(async t => {
var test = "adopt-and-activate";
window.open(`resources/portals-adopt-predecessor.html?test=${test}`);
var message = await waitForCompletion(test);
assert_equals(message, "passed");
}, "Tests that activating an adopted predecessor without inserting it works");
async_test(t => {
var test = "adopt-attach-remove";
var bc = new BroadcastChannel(`test-${test}`);
bc.onmessage = t.step_func_done(function(e) {
assert_equals(e.data, "passed");
bc.close();
});
window.open(`resources/portals-adopt-predecessor.html?test=${test}`);
}, "Tests that an adopting, inserting and then removing a predecessor works correctly");
</script>

Просмотреть файл

@ -37,5 +37,19 @@
}
});
}
if (test == "adopt-and-activate") {
var portal = e.adoptPredecessor();
portal.activate();
}
if (test == "adopt-attach-remove") {
var portal = e.adoptPredecessor();
document.body.appendChild(portal);
setTimeout(() => {
document.body.removeChild(portal);
var bc_test = new BroadcastChannel(`test-${test}`);
bc_test.postMessage("passed");
bc_test.close();
});
}
}
</script>

Просмотреть файл

@ -8,6 +8,9 @@
portal.src = `portals-adopt-predecessor-portal.html?test=${test}`;
portal.onload = () => {
portal.activate().then(() => {
window.addEventListener("portalactivate", e => {
window.opener.postMessage({test, message: "passed"}, "*");
});
window.portalHost.addEventListener("message", e => {
window.opener.postMessage({test, message: e.data}, "*");
});