Skip to content

Commit

Permalink
http/tests/site-isolation/frame-access-after-window-open.html should …
Browse files Browse the repository at this point in the history
…work with site isolation enabled

https://bugs.webkit.org/show_bug.cgi?id=264653
rdar://118064120

Reviewed by Pascoe.

The test uses window.parent.opener to go from an iframe, through a RemoteFrame parent,
to a LocalFrame opener to access properties.  It also uses openedWindow[0] to reach the
other direction to access the opened page's iframe.  In order to get this to work, I had to fix
and implement several things:

1. I had to implement JSRemoteDOMWindow::getOwnPropertySlotByIndex, which I did enough to make
this case work and I filed bugs for future work.  It needs to access the nth iframe of the window.
2. I moved the bindings of window.opener from LocalDOMWindow and RemoteDOMWindow to the shared
location of DOMWindow.idl.  I used the version from LocalDOMWindow because that is the correct
version that has been used for decades.  RemoteDOMWindow is new to site isolation.
3. I added a new parameter to RemoteFrame::createMainFrame to set the opener of a RemoteFrame
when transitioning a LocalFrame to a RemoteFrame in WebFrame::didCommitLoadInAnotherProcess
so that RemoteDOMWindow::opener has something to return.  When you call window.open, it first
creates a LocalFrame that loads about:blank then starts a provisional load in another process,
and once that load commits by receiving the first bytes after the HTTP header, that LocalFrame
becomes a RemoteFrame and the contents of the other process are shown, but the opener is not
changed by this transition.
4. I made all uses of WebPageProxy::forEachWebContentProcess get callbacks with not only the
WebProcessProxy, but also the PageIdentifier that can be used to communicate with the WebPage
in that particular process.  If you do anything with a WebPageProxy after window.open, it likely
has a different PageIdentifier in the process where it is a LocalFrame compared to the process(es)
where it is a RemoteFrame, and we need to use the correct identifier for the process to which
we are sending a message.
5. Similarly, I added WebPageProxy::webPageIDInProcessForDomain to get the webPageID to be used
to communicate with a WebPage in the particular process for that domain.  Until now we got
lucky because we were able to just use WebPageProxy::webPageID() for all the tested behavior,
but with more involved tests after window.open we need this additional bookkeeping to make
IPC work successfully.
6. I added some assertions in WebPage.cpp that were useful in noticing when I had sent messages
to the wrong page but with the correct FrameIdentifier.  A WebFrame can be thought of as being
owned by a WebPage, but the way it is currently implemented we only need a FrameIdentifier to
find a WebFrame in a process, and it will be found even if we mixed up and sent a message to the
wrong WebPage.  These assertions will prevent bookkeeping erros like the ones I made locally
when developing this PR.
7. There was already a call to Page::setMainFrame in WebFrame::transitionToLocal when the main
frame switches from being a RemoteFrame to being a LocalFrame, but we were missing on in
WebFrame::didCommitLoadInAnotherProcess when the main frame switches the other way.  That caused
some issues in this situation because we actually do things with the Page later in the test
and we needed it to have the correct main frame or strange things were broken.
8. I changed Frame's m_mainFrame from a C++ reference to a safe CheckedRef to prevent any security
issues in case of future mistakes in this area.
9. In LocalDOMWindow::open we would return early if the main frame wasn't a LocalFrame because
we need the LocalFrame's Document's DocumentLoader to make WKContentRuleList work correctly.
I filed a bug to get this working and made it proceed when site isolation has made the main
frame a RemoteFrame.  It should be easy to make WKContentRuleList work in this case because
we have Page::mainFrameURL, but that will be done in a separate PR.  This one's big enough.
10. The test needed a few tweaks because I also haven't implemented window.open in named frames
with site isolation yet, so I made the test run successfully and test all the changes I made
in this PR but still have room for that PR to come in the future and make the test behave
exactly how it did before site isolation.  Also, I took the behavior of the iframes and put
them in onload handlers in order for the callback sequence to be more deterministic to help
me debug what is going on during the tests in this and future PRs.  This change did not change
what was being tested or any results of the tests.

And that's all it takes to make this test mostly work with site isolation!  Thanks for reading.

* LayoutTests/http/tests/site-isolation/frame-access-after-window-open-expected.txt:
* LayoutTests/http/tests/site-isolation/frame-access-after-window-open.html:
* LayoutTests/http/tests/site-isolation/resources/opened-iframe-2.html:
* LayoutTests/http/tests/site-isolation/resources/opened-iframe.html:
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/platform/mac/TestExpectations:
* Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp:
(WebCore::JSLocalDOMWindow::getOwnPropertySlotByIndex):
* Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp:
(WebCore::JSRemoteDOMWindow::getOwnPropertySlotByIndex):
(WebCore::JSRemoteDOMWindow::setOpener):
* Source/WebCore/page/DOMWindow.idl:
* Source/WebCore/page/LocalDOMWindow.idl:
* Source/WebCore/page/RemoteDOMWindow.cpp:
(WebCore::RemoteDOMWindow::setOpener):
* Source/WebCore/page/RemoteDOMWindow.h:
* Source/WebCore/page/RemoteDOMWindow.idl:
* Source/WebCore/page/RemoteFrame.cpp:
(WebCore::RemoteFrame::createMainFrame):
(WebCore::RemoteFrame::RemoteFrame):
* Source/WebCore/page/RemoteFrame.h:
* Source/WebKit/UIProcess/WebFrameProxy.cpp:
(WebKit::WebFrameProxy::prepareForProvisionalNavigationInProcess):
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::dispatchActivityStateChange):
(WebKit::WebPageProxy::continueNavigationInNewProcess):
(WebKit::WebPageProxy::forEachWebContentProcess):
(WebKit::WebPageProxy::createRemoteSubframesInOtherProcesses):
(WebKit::WebPageProxy::broadcastFrameRemovalToOtherProcesses):
(WebKit::WebPageProxy::broadcastMainFrameURLChangeToOtherProcesses):
(WebKit::WebPageProxy::webPageIDInProcessForDomain const):
(WebKit::WebPageProxy::broadcastFocusedFrameToOtherProcesses):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/WebProcess/WebPage/WebFrame.cpp:
(WebKit::WebFrame::createRemoteSubframe):
(WebKit::WebFrame::didCommitLoadInAnotherProcess):
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::didCommitLoadInAnotherProcess):
(WebKit::WebPage::didFinishLoadInAnotherProcess):
(WebKit::WebPage::frameWasRemovedInAnotherProcess):
* Tools/WebKitTestRunner/InjectedBundle/InjectedBundlePage.cpp:
(WTR::InjectedBundlePage::didStartProvisionalLoadForFrame):

Canonical link: https://commits.webkit.org/270643@main
  • Loading branch information
achristensen07 committed Nov 13, 2023
1 parent 9c56ef4 commit 8dcff57
Show file tree
Hide file tree
Showing 24 changed files with 90 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
state before window.open:
PASS openedWindow[0].customProperty is 42
state after window.open with a frame name:
PASS openedWindow[0].customProperty is 43
PASS openedWindow[0].customProperty is 42
PASS successfullyParsed is true

TEST COMPLETE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- FIXME: rdar://118064120 set SiteIsolationEnabled to true here and make it work right. -->
<!-- webkit-test-runner [ SiteIsolationEnabled=true ] -->
<script src="/js-test-resources/js-test.js"></script>
<script>

Expand All @@ -14,11 +14,11 @@
function firstSameOriginIframeOpened() {
debug("state before window.open:")
shouldBe("openedWindow[0].customProperty", "42");
windowOpenedInFrame = window.open("http://127.0.0.1:8000/site-isolation/resources/opened-iframe-2.html", "openedFrameName")
windowOpenedInFrame = window.open("http://127.0.0.1:8000/site-isolation/resources/opened-iframe-2.html", "openedFrameName-remove-this-when-fixing-rdar://117092110")
}
function secondSameOriginIframeOpened() {
debug("state after window.open with a frame name:")
shouldBe("openedWindow[0].customProperty", "43");
shouldBe("openedWindow[0].customProperty", "42"); // FIXME: When <rdar://117092110> is fixed this should be 43. Also change the frame name above so the load happens in the already-opened frame.
finishJSTest();
}
</script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
window.customProperty = 43;
window.parent.opener.secondSameOriginIframeOpened()
onload = ()=>{
window.customProperty = 43;
window.parent.opener.secondSameOriginIframeOpened()
}
</script>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script>
window.customProperty = 42;
window.parent.opener.firstSameOriginIframeOpened()
onload = ()=>{
window.customProperty = 42;
window.parent.opener.firstSameOriginIframeOpened()
}
</script>
2 changes: 0 additions & 2 deletions LayoutTests/platform/ios/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -4661,6 +4661,4 @@ webkit.org/b/264001 [ Debug ] imported/w3c/web-platform-tests/requestidlecallbac

webkit.org/b/264177 requestidlecallback/requestidlecallback-deadline-shortened-by-rendering-update.html [ Pass Failure ]

webkit.org/b/264349 http/tests/site-isolation/frame-access-after-window-open.html [ Timeout ]

webkit.org/b/264527 imported/w3c/web-platform-tests/css/css-cascade/idlharness.html [ Pass Failure ]
2 changes: 0 additions & 2 deletions LayoutTests/platform/mac/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -2608,8 +2608,6 @@ webkit.org/b/263783 [ Sonoma+ ] fast/scrolling/scroll-snap-crash.html [ Skip ]

webkit.org/b/264177 requestidlecallback/requestidlecallback-deadline-shortened-by-rendering-update.html [ Pass Failure ]

webkit.org/b/264349 http/tests/site-isolation/frame-access-after-window-open.html [ Timeout ]

webkit.org/b/264527 imported/w3c/web-platform-tests/css/css-cascade/idlharness.html [ Pass Failure ]

webkit.org/b/264607 [ Sonoma+ ] css1/box_properties/acid_test.html [ Pass Timeout ]
2 changes: 2 additions & 0 deletions Source/WebCore/bindings/js/JSLocalDOMWindowCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ bool JSLocalDOMWindow::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObjec

// These are also allowed cross-origin, so come before the access check.
if (frame && index < frame->tree().scopedChildCount()) {
// FIXME: <rdar://118263337> LocalDOMWindow::length needs to include RemoteFrames.
// This should also work if it's a RemoteFrame, it should just return a RemoteDOMWindow.
if (auto* scopedChild = dynamicDowncast<LocalFrame>(frame->tree().scopedChild(index))) {
slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), toJS(lexicalGlobalObject, scopedChild->document()->domWindow()));
return true;
Expand Down
20 changes: 19 additions & 1 deletion Source/WebCore/bindings/js/JSRemoteDOMWindowCustom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,24 @@ bool JSRemoteDOMWindow::getOwnPropertySlotByIndex(JSObject* object, JSGlobalObje
{
VM& vm = lexicalGlobalObject->vm();
auto* thisObject = jsCast<JSRemoteDOMWindow*>(object);
auto& window = thisObject->wrapped();
auto* frame = window.frame();

// Indexed getters take precendence over regular properties, so caching would be invalid.
slot.disableCaching();

// FIXME: Add support for indexed properties.
// These are also allowed cross-origin, so come before the access check.
if (frame && index < frame->tree().childCount()) {
// FIXME: <rdar://118263337> This should work also if it's a RemoteFrame, it should just return a RemoteDOMWindow.
// JSLocalDOMWindow::getOwnPropertySlotByIndex uses scopedChild. Investigate the difference.
if (auto* child = dynamicDowncast<LocalFrame>(frame->tree().child(index))) {
slot.setValue(thisObject, static_cast<unsigned>(JSC::PropertyAttribute::ReadOnly), toJS(lexicalGlobalObject, child->document()->domWindow()));
return true;
}
}

// FIXME: <rdar://118263337> Make this more like JSLocalDOMWindow::getOwnPropertySlotByIndex and share code when possible.
// There is some missing functionality here, and it is likely important.

return jsLocalDOMWindowGetOwnPropertySlotRestrictedAccess<DOMWindowType::Remote>(thisObject, thisObject->wrapped(), *lexicalGlobalObject, Identifier::from(vm, index), slot, String());
}
Expand Down Expand Up @@ -132,4 +145,9 @@ bool JSRemoteDOMWindow::preventExtensions(JSObject*, JSGlobalObject*)
return false;
}

void JSRemoteDOMWindow::setOpener(JSC::JSGlobalObject&, JSC::JSValue)
{
// FIXME: <rdar://118263373> Implement, probably like JSLocalDOMWindow::setOpener.
}

} // namepace WebCore
1 change: 1 addition & 0 deletions Source/WebCore/page/DOMWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ interface mixin DOMWindow {
[CallWith=CurrentGlobalObject&IncumbentWindow, DoNotCheckSecurity] undefined postMessage(any message, optional WindowPostMessageOptions options);
[DoNotCheckSecurity, PutForwards=href, LegacyUnforgeable] readonly attribute Location location;
[DoNotCheckSecurity, CallWith=IncumbentDocument] undefined close();
[DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener;
};
2 changes: 1 addition & 1 deletion Source/WebCore/page/Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool Frame::isRootFrame() const
case FrameType::Local:
if (auto* parent = tree().parent())
return is<RemoteFrame>(parent);
ASSERT(&m_mainFrame == this);
ASSERT(m_mainFrame.ptr() == this);
return true;
case FrameType::Remote:
break;
Expand Down
9 changes: 5 additions & 4 deletions Source/WebCore/page/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "FrameIdentifier.h"
#include "FrameTree.h"
#include "PageIdentifier.h"
#include <wtf/CheckedRef.h>
#include <wtf/Ref.h>
#include <wtf/ThreadSafeRefCounted.h>
#include <wtf/UniqueRef.h>
Expand All @@ -45,7 +46,7 @@ class Settings;
class WeakPtrImplWithEventTargetData;
class WindowProxy;

class Frame : public ThreadSafeRefCounted<Frame, WTF::DestructionThread::Main>, public CanMakeWeakPtr<Frame> {
class Frame : public ThreadSafeRefCounted<Frame, WTF::DestructionThread::Main>, public CanMakeWeakPtr<Frame>, public CanMakeCheckedPtr {
public:
virtual ~Frame();

Expand All @@ -63,8 +64,8 @@ class Frame : public ThreadSafeRefCounted<Frame, WTF::DestructionThread::Main>,
inline CheckedPtr<Page> checkedPage() const; // Defined in Page.h.
WEBCORE_EXPORT std::optional<PageIdentifier> pageID() const;
Settings& settings() const { return m_settings.get(); }
Frame& mainFrame() const { return m_mainFrame; }
bool isMainFrame() const { return this == &m_mainFrame; }
Frame& mainFrame() const { return m_mainFrame.get(); }
bool isMainFrame() const { return this == m_mainFrame.ptr(); }
WEBCORE_EXPORT bool isRootFrame() const;

WEBCORE_EXPORT void detachFromPage();
Expand Down Expand Up @@ -99,7 +100,7 @@ class Frame : public ThreadSafeRefCounted<Frame, WTF::DestructionThread::Main>,
mutable FrameTree m_treeNode;
Ref<WindowProxy> m_windowProxy;
WeakPtr<HTMLFrameOwnerElement, WeakPtrImplWithEventTargetData> m_ownerElement;
Frame& m_mainFrame;
CheckedRef<Frame> m_mainFrame;
const Ref<Settings> m_settings;
FrameType m_frameType;
mutable UniqueRef<NavigationScheduler> m_navigationScheduler;
Expand Down
5 changes: 2 additions & 3 deletions Source/WebCore/page/LocalDOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2656,10 +2656,9 @@ ExceptionOr<RefPtr<WindowProxy>> LocalDOMWindow::open(LocalDOMWindow& activeWind
RefPtr firstFrameDocument = firstFrame->document();

RefPtr localFrame = dynamicDowncast<LocalFrame>(firstFrame->mainFrame());
if (!localFrame)
return RefPtr<WindowProxy> { nullptr };

RefPtr mainFrameDocument = localFrame->document();
// FIXME: <rdar://118280717> Make WKContentRuleLists apply in this case.
RefPtr mainFrameDocument = localFrame ? localFrame->document() : nullptr;
RefPtr mainFrameDocumentLoader = mainFrameDocument ? mainFrameDocument->loader() : nullptr;
if (firstFrameDocument && page && mainFrameDocumentLoader) {
auto results = page->userContentProvider().processContentRuleListsForLoad(*page, firstFrameDocument->completeURL(urlString), ContentExtensions::ResourceType::Popup, *mainFrameDocumentLoader);
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/page/LocalDOMWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
[Replaceable, DoNotCheckSecurityOnGetter, CustomGetter] readonly attribute WindowProxy frames;
[Replaceable, DoNotCheckSecurityOnGetter] readonly attribute unsigned long length;
[DoNotCheckSecurityOnGetter, LegacyUnforgeable] readonly attribute WindowProxy? top;
[DoNotCheckSecurityOnGetter, CustomSetter] attribute WindowProxy? opener;
[Replaceable, DoNotCheckSecurityOnGetter] readonly attribute WindowProxy? parent;
[CheckSecurityForNode] readonly attribute Element? frameElement;
[CallWith=ActiveWindow&FirstWindow] WindowProxy? open(optional USVString url = "", optional [AtomString] DOMString target = "_blank", optional [LegacyNullToEmptyString] DOMString features = "");
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/page/LocalFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ enum OverflowScrollAction { DoNotPerformOverflowScroll, PerformOverflowScroll };
using NodeQualifier = Function<Node* (const HitTestResult&, Node* terminationNode, IntRect* nodeBounds)>;
#endif

class LocalFrame final : public Frame, public CanMakeCheckedPtr {
class LocalFrame final : public Frame {
public:
WEBCORE_EXPORT static Ref<LocalFrame> createMainFrame(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier);
WEBCORE_EXPORT static Ref<LocalFrame> createSubframe(Page&, UniqueRef<LocalFrameLoaderClient>&&, FrameIdentifier, HTMLFrameOwnerElement&);
Expand Down
6 changes: 6 additions & 0 deletions Source/WebCore/page/RemoteDOMWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ WindowProxy* RemoteDOMWindow::opener() const
return &openerFrame->windowProxy();
}

void RemoteDOMWindow::setOpener(WindowProxy*)
{
// FIXME: <rdar://118263373> Implement.
// JSLocalDOMWindow::setOpener has some security checks. Are they needed here?
}

WindowProxy* RemoteDOMWindow::parent() const
{
if (!m_frame)
Expand Down
1 change: 1 addition & 0 deletions Source/WebCore/page/RemoteDOMWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class RemoteDOMWindow final : public DOMWindow {
unsigned length() const;
WindowProxy* top() const;
WindowProxy* opener() const;
void setOpener(WindowProxy*);
WindowProxy* parent() const;
ExceptionOr<void> postMessage(JSC::JSGlobalObject&, LocalDOMWindow& incumbentWindow, JSC::JSValue message, WindowPostMessageOptions&&);
ExceptionOr<void> postMessage(JSC::JSGlobalObject& globalObject, LocalDOMWindow& incumbentWindow, JSC::JSValue message, String&& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
Expand Down
1 change: 0 additions & 1 deletion Source/WebCore/page/RemoteDOMWindow.idl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
[Replaceable, ImplementedAs=self] readonly attribute WindowProxy frames;
[Replaceable] readonly attribute unsigned long length;
[LegacyUnforgeable] readonly attribute WindowProxy? top;
readonly attribute WindowProxy? opener;
[Replaceable] readonly attribute WindowProxy? parent;
};

Expand Down
7 changes: 4 additions & 3 deletions Source/WebCore/page/RemoteFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@

namespace WebCore {

Ref<RemoteFrame> RemoteFrame::createMainFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier)
Ref<RemoteFrame> RemoteFrame::createMainFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier, Frame* opener)
{
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, nullptr, nullptr, std::nullopt));
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, nullptr, nullptr, std::nullopt, opener));
}

Ref<RemoteFrame> RemoteFrame::createSubframe(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier identifier, Frame& parent)
Expand All @@ -50,9 +50,10 @@ Ref<RemoteFrame> RemoteFrame::createSubframeWithContentsInAnotherProcess(Page& p
return adoptRef(*new RemoteFrame(page, WTFMove(client), identifier, &ownerElement, ownerElement.document().frame(), layerHostingContextIdentifier));
}

RemoteFrame::RemoteFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier frameID, HTMLFrameOwnerElement* ownerElement, Frame* parent, Markable<LayerHostingContextIdentifier> layerHostingContextIdentifier)
RemoteFrame::RemoteFrame(Page& page, UniqueRef<RemoteFrameClient>&& client, FrameIdentifier frameID, HTMLFrameOwnerElement* ownerElement, Frame* parent, Markable<LayerHostingContextIdentifier> layerHostingContextIdentifier, Frame* opener)
: Frame(page, frameID, FrameType::Remote, ownerElement, parent)
, m_window(RemoteDOMWindow::create(*this, GlobalWindowIdentifier { Process::identifier(), WindowIdentifier::generate() }))
, m_opener(opener)
, m_client(WTFMove(client))
, m_layerHostingContextIdentifier(layerHostingContextIdentifier)
{
Expand Down
5 changes: 3 additions & 2 deletions Source/WebCore/page/RemoteFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ enum class RenderAsTextFlag : uint16_t;

class RemoteFrame final : public Frame {
public:
WEBCORE_EXPORT static Ref<RemoteFrame> createMainFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier);
WEBCORE_EXPORT static Ref<RemoteFrame> createMainFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, Frame* opener = nullptr);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframe(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, Frame& parent);
WEBCORE_EXPORT static Ref<RemoteFrame> createSubframeWithContentsInAnotherProcess(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, HTMLFrameOwnerElement&, std::optional<LayerHostingContextIdentifier>);
~RemoteFrame();

RemoteDOMWindow& window() const;

// FIXME: <rdar://118263278> Move this to a pure virtual function on Frame or just a function on Frame, move LocalDOMWindow::opener to DOMWindow.
void setOpener(Frame* opener) { m_opener = opener; }
Frame* opener() const { return m_opener.get(); }

Expand All @@ -63,7 +64,7 @@ class RemoteFrame final : public Frame {
String renderTreeAsText(size_t baseIndent, OptionSet<RenderAsTextFlag>);

private:
WEBCORE_EXPORT explicit RemoteFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame*, Markable<LayerHostingContextIdentifier>);
WEBCORE_EXPORT explicit RemoteFrame(Page&, UniqueRef<RemoteFrameClient>&&, FrameIdentifier, HTMLFrameOwnerElement*, Frame* parent, Markable<LayerHostingContextIdentifier>, Frame* opener = nullptr);

void frameDetached() final;
bool preventsParentFromBeingComplete() const final;
Expand Down
4 changes: 2 additions & 2 deletions Source/WebKit/UIProcess/WebFrameProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,9 @@ void WebFrameProxy::prepareForProvisionalNavigationInProcess(WebProcessProxy& pr
return completionHandler();
}

RegistrableDomain navigationDomain(navigation.currentRequest().url());
if (!m_provisionalFrame || navigation.currentRequestIsCrossSiteRedirect()) {
// FIXME: Main resource (of main or subframe) request redirects should go straight from the network to UI process so we don't need to make the processes for each domain in a redirect chain. <rdar://116202119>
RegistrableDomain navigationDomain(navigation.currentRequest().url());
RefPtr remotePageProxy = m_page->remotePageProxyForRegistrableDomain(navigationDomain);
RegistrableDomain mainFrameDomain(m_page->mainFrame()->url());

Expand All @@ -420,7 +420,7 @@ void WebFrameProxy::prepareForProvisionalNavigationInProcess(WebProcessProxy& pr
LocalFrameCreationParameters localFrameCreationParameters {
m_provisionalFrame->layerHostingContextIdentifier()
};
process.send(Messages::WebPage::TransitionFrameToLocal(localFrameCreationParameters, frameID()), page()->webPageID());
process.send(Messages::WebPage::TransitionFrameToLocal(localFrameCreationParameters, frameID()), page()->webPageIDInProcessForDomain(navigationDomain));
}

if (completionHandler)
Expand Down
Loading

0 comments on commit 8dcff57

Please sign in to comment.