summaryrefslogtreecommitdiff
path: root/chromium/ui/views/controls/webview/webview_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/views/controls/webview/webview_unittest.cc')
-rw-r--r--chromium/ui/views/controls/webview/webview_unittest.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/chromium/ui/views/controls/webview/webview_unittest.cc b/chromium/ui/views/controls/webview/webview_unittest.cc
index 5c28d3091f8..1f2322d2fb9 100644
--- a/chromium/ui/views/controls/webview/webview_unittest.cc
+++ b/chromium/ui/views/controls/webview/webview_unittest.cc
@@ -566,6 +566,25 @@ TEST_F(WebViewUnitTest, CrashedOverlayViewOwnedbyClient) {
delete crashed_overlay_view;
}
+// Tests to make sure we can default construct the WebView class and set the
+// BrowserContext after construction.
+TEST_F(WebViewUnitTest, DefaultConstructability) {
+ auto browser_context = std::make_unique<content::TestBrowserContext>();
+ auto web_view = std::make_unique<WebView>();
+
+ // Test to make sure the WebView returns a nullptr in the absence of an
+ // explicitly supplied WebContents and BrowserContext.
+ EXPECT_EQ(nullptr, web_view->GetWebContents());
+
+ web_view->SetBrowserContext(browser_context.get());
+
+ // WebView should be able to create a WebContents object from the previously
+ // set |browser_context|.
+ auto* web_contents = web_view->GetWebContents();
+ EXPECT_NE(nullptr, web_contents);
+ EXPECT_EQ(browser_context.get(), web_contents->GetBrowserContext());
+}
+
#if defined(USE_AURA)
namespace {