Commit 541505de authored by Adithya Srinivasan's avatar Adithya Srinivasan Committed by Commit Bot

Portals: Clear activating portal contents after activation

Bug: 1003813
Change-Id: I250c4becaec287ba3e317d69e5afb61e754832a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1807701
Commit-Queue: Adithya Srinivasan <adithyas@chromium.org>
Reviewed-by: default avatarLucas Gadani <lfg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#698545}
parent 8b472c44
...@@ -48,6 +48,7 @@ class DocumentPortals final : public GarbageCollected<DocumentPortals>, ...@@ -48,6 +48,7 @@ class DocumentPortals final : public GarbageCollected<DocumentPortals>,
DCHECK(!activating_portal_); DCHECK(!activating_portal_);
activating_portal_ = portal; activating_portal_ = portal;
} }
void ClearActivatingPortalContents() { activating_portal_ = nullptr; }
explicit DocumentPortals(Document&); explicit DocumentPortals(Document&);
......
...@@ -70,6 +70,11 @@ ScriptPromise PortalContents::Activate(ScriptState* script_state, ...@@ -70,6 +70,11 @@ ScriptPromise PortalContents::Activate(ScriptState* script_state,
void PortalContents::OnActivateResponse(bool was_adopted) { void PortalContents::OnActivateResponse(bool was_adopted) {
if (was_adopted) if (was_adopted)
GetDocument().GetPage()->SetInsidePortal(true); GetDocument().GetPage()->SetInsidePortal(true);
DocumentPortals& document_portals = DocumentPortals::From(GetDocument());
DCHECK_EQ(document_portals.GetActivatingPortalContents(), this);
document_portals.ClearActivatingPortalContents();
activate_resolver_->Resolve(); activate_resolver_->Resolve();
activate_resolver_ = nullptr; activate_resolver_ = nullptr;
Destroy(); Destroy();
......
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
async_test(async t => {
let win = window.open("resources/portal-repeated-activate-window.html");
win.onload = () => win.activate();
window.onmessage = t.step_func_done(() => {});
}, "test activation in page that has been reactivated")
</script>
<!DOCTYPE html>
<body>
<portal src="simple-portal-adopts-and-activates-predecessor.html">
<script>
function activate() {
var portal = document.querySelector("portal");
portal.activate().then(() => document.body.removeChild(portal));
}
var count = 0;
window.onportalactivate = e => {
++count;
if (count == 1) {
e.adoptPredecessor().activate();
} else {
window.opener.postMessage("done", "*");
}
};
</script>
</body>
<!DOCTYPE html>
<body>
<script>
window.onportalactivate = e => e.adoptPredecessor().activate();
</script>
</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