Commit 76221152 authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Portals: Handle edge case with connecting child frames

We shouldn't set the portal element's content frame if
SubframeLoadingDisabler::CanLoadFrame() returns false, this can lead to
discrepancies in the connected subframe count and result in frames not
being disconnected.

In the test case in this CL, we try inserting a portal into a subtree
that is being disconnected.

Bug: 1041406
Change-Id: I7e0377392457f5b0ca6537c27cb6a5835b8eedd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002859
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#744350}
parent a294ec28
......@@ -310,13 +310,16 @@ const base::UnguessableToken& HTMLPortalElement::GetToken() const {
return portal_->GetToken();
}
HTMLPortalElement::InsertionNotificationRequest HTMLPortalElement::InsertedInto(
Node::InsertionNotificationRequest HTMLPortalElement::InsertedInto(
ContainerNode& node) {
auto result = HTMLFrameOwnerElement::InsertedInto(node);
if (!CheckPortalsEnabledOrWarn())
return result;
if (!SubframeLoadingDisabler::CanLoadFrame(*this))
return result;
switch (GetGuestContentsEligibility()) {
case GuestContentsEligibility::kIneligible:
return result;
......
<!DOCTYPE html>
<title>Regression test for https://crbug.com/1041406</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
setup({single_test: true});
// Callback ordering in test:
// 1) iframe loads and runs cb1()
// 2) during appendChild, iframe gets disconnected, during which body load is
// marked as complete and cb2() runs
function cb1() {
var div_b = document.getElementById('b');
var div_a = document.getElementById('a');
div_b.appendChild(div_a);
}
function cb2() {
var portal = document.querySelector('portal');
var iframe = document.querySelector('iframe');
iframe.after(portal);
done();
}
</script>
<body onload="cb2()">
<div id="a">
<iframe src="resources/simple-portal.html" onload="cb1()"></iframe>
</div>
<div id="b"></div>
<portal src="resources/simple-portal.html"></portal>
</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