This repository was archived by the owner on Apr 3, 2020. It is now read-only.
File tree 2 files changed +25
-1
lines changed
2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -778,9 +778,12 @@ void FrameLoader::load(const FrameLoadRequest& passedRequest)
778
778
779
779
RefPtrWillBeRawPtr<LocalFrame> targetFrame = toLocalFrame (request.formState () ? nullptr : m_frame->findFrameForNavigation (AtomicString (request.frameName ()), *m_frame));
780
780
if (targetFrame && targetFrame.get () != m_frame) {
781
+ bool wasInSamePage = targetFrame->page () == m_frame->page ();
782
+
781
783
request.setFrameName (" _self" );
782
784
targetFrame->loader ().load (request);
783
- if (Page* page = targetFrame->page ())
785
+ Page* page = targetFrame->page ();
786
+ if (!wasInSamePage && page)
784
787
page->chrome ().focus ();
785
788
return ;
786
789
}
Original file line number Diff line number Diff line change @@ -1602,6 +1602,27 @@ class ViewCreatingWebViewClient : public FrameTestHelpers::TestWebViewClient {
1602
1602
bool m_didFocusCalled;
1603
1603
};
1604
1604
1605
+ TEST_F (WebViewTest, DoNotFocusCurrentFrameOnNavigateFromLocalFrame)
1606
+ {
1607
+ ViewCreatingWebViewClient client;
1608
+ FrameTestHelpers::WebViewHelper m_webViewHelper;
1609
+ WebViewImpl* webViewImpl = m_webViewHelper.initialize (true , 0 , &client);
1610
+ webViewImpl->page ()->settings ().setJavaScriptCanOpenWindowsAutomatically (true );
1611
+
1612
+ WebURL baseURL = URLTestHelpers::toKURL (" http://example.com/" );
1613
+ FrameTestHelpers::loadHTMLString (webViewImpl->mainFrame (), " <html><body><iframe src=\" about:blank\" ></iframe></body></html>" , baseURL);
1614
+
1615
+ // Make a request from a local frame.
1616
+ WebURLRequest webURLRequestWithTargetStart;
1617
+ webURLRequestWithTargetStart.initialize ();
1618
+ LocalFrame* localFrame = toWebLocalFrameImpl (webViewImpl->mainFrame ()->firstChild ())->frame ();
1619
+ FrameLoadRequest requestWithTargetStart (localFrame->document (), webURLRequestWithTargetStart.toResourceRequest (), " _top" );
1620
+ localFrame->loader ().load (requestWithTargetStart);
1621
+ EXPECT_FALSE (client.didFocusCalled ());
1622
+
1623
+ m_webViewHelper.reset (); // Remove dependency on locally scoped client.
1624
+ }
1625
+
1605
1626
TEST_F (WebViewTest, FocusExistingFrameOnNavigate)
1606
1627
{
1607
1628
ViewCreatingWebViewClient client;
You can’t perform that action at this time.
0 commit comments