Commit 8f98e0ab authored by Nate Chapin's avatar Nate Chapin Committed by Commit Bot

Fix crash when printing in the middle of frame swap

Bug: 1061686
Change-Id: Ia6ee7028e5a5e37041d61869792ef492213ba272
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2107311
Commit-Queue: Nate Chapin <japhet@chromium.org>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752079}
parent ab8977ac
...@@ -877,11 +877,12 @@ Element* LocalDOMWindow::frameElement() const { ...@@ -877,11 +877,12 @@ Element* LocalDOMWindow::frameElement() const {
void LocalDOMWindow::blur() {} void LocalDOMWindow::blur() {}
void LocalDOMWindow::print(ScriptState* script_state) { void LocalDOMWindow::print(ScriptState* script_state) {
if (!GetFrame()) // Don't print after detach begins, even if GetFrame() hasn't been nulled out yet.
return; // TODO(crbug.com/1063150): When a frame is being detached for a swap, the document has already
// been Shutdown() and is no longer in a consistent state, even though GetFrame() is not yet
Page* page = GetFrame()->GetPage(); // nulled out. This is an ordering violation, and checking whether we're in the middle of detach
if (!page) // here is probably not the right long-term fix.
if (!GetFrame() || !GetFrame()->IsAttached())
return; return;
if (script_state && if (script_state &&
...@@ -901,7 +902,7 @@ void LocalDOMWindow::print(ScriptState* script_state) { ...@@ -901,7 +902,7 @@ void LocalDOMWindow::print(ScriptState* script_state) {
WebFeature::kCrossOriginWindowPrint); WebFeature::kCrossOriginWindowPrint);
should_print_when_finished_loading_ = false; should_print_when_finished_loading_ = false;
page->GetChromeClient().Print(GetFrame()); GetFrame()->GetPage()->GetChromeClient().Print(GetFrame());
} }
void LocalDOMWindow::stop() { void LocalDOMWindow::stop() {
......
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