Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cherry-pick 265870.486@safari-7616-branch (3fc6931). https://bugs.web…
…kit.org/show_bug.cgi?id=260907 Crash under HTMLBodyElement::didFinishInsertingNode() https://bugs.webkit.org/show_bug.cgi?id=260907 rdar://114177696 Reviewed by Ryosuke Niwa. When a <body> is inserted into the document, `HTMLBodyElement::insertedIntoAncestor()` gets called. This function would only return `InsertedIntoAncestorResult::NeedsPostInsertionCallback` if `is<HTMLFrameElementBase>(document().ownerElement())`, causing `HTMLBodyElement::didFinishInsertingNode()` to get called later on. We would then assume in didFinishInsertingNode() that the document's owner element is a non-null HTMLFrameElementBase. However, as proven by the test, DOM manipulations can happen in between the 2 calls causing the assertion to no longer hold. To address the issue we now early return if `is<HTMLFrameElementBase>(document().ownerElement())` is no longer true in `HTMLBodyElement::didFinishInsertingNode()`. In the case of the test, `document().frame()` becomes null because the frame gets detached, causing `document().ownerElement()` to return null as well. * LayoutTests/fast/frames/frame-append-body-child-crash-expected.txt: Added. * LayoutTests/fast/frames/frame-append-body-child-crash.html: Added. * Source/WebCore/html/HTMLBodyElement.cpp: (WebCore::HTMLBodyElement::didFinishInsertingNode): Canonical link: https://commits.webkit.org/265870.486@safari-7616-branch
- Loading branch information