Commit 3c907c5
committed
document should not be null after navigation with site isolation enabled
https://bugs.webkit.org/show_bug.cgi?id=294228
rdar://152872994
Reviewed by Charlie Wolfe.
https://commits.webkit.org/292437@main introduced a case where we take the WindowProxy
from one page to another when navigating the main frame from one domain to another.
If the WindowProxy that we are taking had its JSWindowProxy initialized by an iframe
on the previous page accessing its parent's properties, then JSDOMWindowBase::initStaticGlobals
has already been called to initialize document to null, but ScriptController::initScriptForWindowProxy
won't call JSDOMWindowBase::updateDocument to set document to the document instead of null
because WindowProxy::jsWindowProxy will find an already existing JSWindowProxy initialized
where WindowProxy::createJSWindowProxyWithInitializedScript has skipped the call to
initScriptForWindowProxy because the Frame was a RemoteFrame when it was initialized.
To fix this issue, we add another call to didBecomeCurrentDocumentInFrame after swapping
from a RemoteFrame to a LocalFrame. That will call updateDocument as well as do
possibly other initialization needed.
I also restore an assertion that was removed in 292437@main, but I added a condition to
make it pass when taking a WindowProxy from one page to another.
This fixes one of the issues I found in rdar://152460976 but not the initial one, so
that still needs more investigation.
* LayoutTests/http/tests/site-isolation/document-access-expected.txt: Added.
* LayoutTests/http/tests/site-isolation/document-access.html: Added.
* LayoutTests/http/tests/site-isolation/resources/access-document.html: Added.
* LayoutTests/http/tests/site-isolation/resources/access-parent.html: Added.
* Source/WebCore/dom/Document.h:
* Source/WebCore/page/Frame.cpp:
(WebCore::Frame::takeWindowProxyAndOpenerFrom):
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::commitProvisionalFrame):
Canonical link: https://commits.webkit.org/296022@main1 parent 3b698e6 commit 3c907c5
7 files changed
Lines changed: 21 additions & 1 deletion
File tree
- LayoutTests/http/tests/site-isolation
- resources
- Source
- WebCore
- dom
- page
- WebKit/WebProcess/WebPage
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
754 | 754 | | |
755 | 755 | | |
756 | 756 | | |
757 | | - | |
| 757 | + | |
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
176 | 177 | | |
177 | 178 | | |
178 | 179 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
| 521 | + | |
| 522 | + | |
521 | 523 | | |
522 | 524 | | |
523 | 525 | | |
| |||
0 commit comments