Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Unified Diff: third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp

Issue 2035973002: Don't allow deferred frames to create new windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WebView::create update Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp
diff --git a/third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp b/third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp
index 8e5c72e8872f74790c449045990ac52310b0bfd8..f8a6dc50d3a2b32f5e7ac081d5e38c91a5ee2b6b 100644
--- a/third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp
+++ b/third_party/WebKit/Source/web/tests/ChromeClientImplTest.cpp
@@ -28,6 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "core/loader/FrameLoadRequest.h"
#include "core/page/Page.h"
#include "public/web/WebFrameClient.h"
#include "public/web/WebInputEvent.h"
@@ -35,6 +36,7 @@
#include "public/web/WebView.h"
#include "public/web/WebViewClient.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "web/WebLocalFrameImpl.h"
#include "web/WebViewImpl.h"
#include "web/tests/FrameTestHelpers.h"
@@ -255,4 +257,48 @@ TEST_F(GetNavigationPolicyTest, NotResizableForcesPopup)
EXPECT_FALSE(isNavigationPolicyPopup());
}
+class ViewCreatingClient : public FrameTestHelpers::TestWebViewClient {
+public:
+ WebView* createView(WebLocalFrame* opener, const WebURLRequest&, const WebWindowFeatures&, const WebString& name, WebNavigationPolicy, bool) override
+ {
+ return m_webViewHelper.initializeWithOpener(opener, true);
+ }
+
+private:
+ FrameTestHelpers::WebViewHelper m_webViewHelper;
+};
+
+class CreateWindowTest : public testing::Test {
+protected:
+ void SetUp() override
+ {
+ m_webView = toWebViewImpl(WebView::create(&m_webViewClient, WebPageVisibilityStateVisible));
+ m_mainFrame = WebLocalFrame::create(WebTreeScopeType::Document, &m_webFrameClient);
+ m_webView->setMainFrame(m_mainFrame);
+ m_chromeClientImpl = toChromeClientImpl(&m_webView->page()->chromeClient());
+ }
+
+ void TearDown() override
+ {
+ m_webView->close();
+ m_mainFrame->close();
+ }
+
+ ViewCreatingClient m_webViewClient;
+ WebViewImpl* m_webView;
+ WebFrame* m_mainFrame;
+ FrameTestHelpers::TestWebFrameClient m_webFrameClient;
+ Persistent<ChromeClientImpl> m_chromeClientImpl;
+};
+
+TEST_F(CreateWindowTest, CreateWindowFromDeferredPage)
+{
+ m_webView->page()->setDefersLoading(true);
+ LocalFrame* frame = toWebLocalFrameImpl(m_mainFrame)->frame();
+ FrameLoadRequest request(frame->document());
+ WindowFeatures features;
+ EXPECT_EQ(nullptr, m_chromeClientImpl->createWindow(frame, request, features, NavigationPolicyNewForegroundTab));
+ m_webView->page()->setDefersLoading(false);
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/web/ChromeClientImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698