|
16 | 16 | #include "chrome/test/base/in_process_browser_test.h"
|
17 | 17 | #include "chrome/test/base/ui_test_utils.h"
|
18 | 18 | #include "components/omnibox/browser/location_bar_model.h"
|
| 19 | +#include "content/public/browser/navigation_entry.h" |
19 | 20 | #include "content/public/browser/notification_service.h"
|
20 | 21 | #include "content/public/browser/notification_types.h"
|
21 | 22 | #include "content/public/common/url_constants.h"
|
@@ -59,6 +60,31 @@ class BraveSchemeLoadBrowserTest : public InProcessBrowserTest,
|
59 | 60 | return WaitForLoadStop(active_contents());
|
60 | 61 | }
|
61 | 62 |
|
| 63 | + // Check loading |url| in guest window is not allowed for an url. |
| 64 | + void TestURLIsNotLoadedInGuestWindow(const GURL& url) { |
| 65 | + Browser* guest_browser = CreateGuestBrowser(); |
| 66 | + TabStripModel* guest_model = guest_browser->tab_strip_model(); |
| 67 | + |
| 68 | + // Check guest window has one blank tab. |
| 69 | + EXPECT_EQ("about:blank", |
| 70 | + guest_model->GetActiveWebContents()->GetVisibleURL().spec()); |
| 71 | + EXPECT_EQ(1, guest_model->count()); |
| 72 | + EXPECT_EQ("about:blank", active_contents()->GetVisibleURL().spec()); |
| 73 | + EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 74 | + // Unable to navigate expected url. |
| 75 | + EXPECT_FALSE( |
| 76 | + content::NavigateToURL(guest_model->GetActiveWebContents(), url)); |
| 77 | + auto* entry = guest_model->GetActiveWebContents() |
| 78 | + ->GetController() |
| 79 | + .GetLastCommittedEntry(); |
| 80 | + EXPECT_EQ(entry->GetPageType(), content::PageType::PAGE_TYPE_ERROR); |
| 81 | + EXPECT_STREQ("about:blank", |
| 82 | + base::UTF16ToUTF8( |
| 83 | + browser()->location_bar_model()->GetFormattedFullURL()) |
| 84 | + .c_str()); |
| 85 | + EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 86 | + } |
| 87 | + |
62 | 88 | // Check loading |url| in private window is redirected to normal
|
63 | 89 | // window.
|
64 | 90 | void TestURLIsNotLoadedInPrivateWindow(const std::string& url) {
|
@@ -260,3 +286,8 @@ IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest,
|
260 | 286 | BraveWelcomePageIsNotAllowedInPrivateWindow) {
|
261 | 287 | TestURLIsNotLoadedInPrivateWindow("brave://welcome");
|
262 | 288 | }
|
| 289 | + |
| 290 | +IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest, |
| 291 | + BraveWelcomePageIsNotAllowedInGuestWindow) { |
| 292 | + TestURLIsNotLoadedInGuestWindow(GURL("brave://welcome")); |
| 293 | +} |
0 commit comments