-
Notifications
You must be signed in to change notification settings - Fork 965
Do not open brave://welcome in guest windows #17577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
#include "chrome/test/base/in_process_browser_test.h" | ||
#include "chrome/test/base/ui_test_utils.h" | ||
#include "components/omnibox/browser/location_bar_model.h" | ||
#include "content/public/browser/navigation_entry.h" | ||
#include "content/public/browser/notification_service.h" | ||
#include "content/public/browser/notification_types.h" | ||
#include "content/public/common/url_constants.h" | ||
|
@@ -59,6 +60,31 @@ class BraveSchemeLoadBrowserTest : public InProcessBrowserTest, | |
return WaitForLoadStop(active_contents()); | ||
} | ||
|
||
// Check loading |url| in guest window is not allowed for an url. | ||
void TestURLIsNotLoadedInGuestWindow(const GURL& url) { | ||
Browser* guest_browser = CreateGuestBrowser(); | ||
TabStripModel* guest_model = guest_browser->tab_strip_model(); | ||
|
||
// Check guest window has one blank tab. | ||
EXPECT_EQ("about:blank", | ||
guest_model->GetActiveWebContents()->GetVisibleURL().spec()); | ||
EXPECT_EQ(1, guest_model->count()); | ||
EXPECT_EQ("about:blank", active_contents()->GetVisibleURL().spec()); | ||
EXPECT_EQ(1, browser()->tab_strip_model()->count()); | ||
// Unable to navigate expected url. | ||
EXPECT_FALSE( | ||
content::NavigateToURL(guest_model->GetActiveWebContents(), url)); | ||
auto* entry = guest_model->GetActiveWebContents() | ||
->GetController() | ||
.GetLastCommittedEntry(); | ||
EXPECT_EQ(entry->GetPageType(), content::PageType::PAGE_TYPE_ERROR); | ||
EXPECT_STREQ("about:blank", | ||
base::UTF16ToUTF8( | ||
browser()->location_bar_model()->GetFormattedFullURL()) | ||
.c_str()); | ||
EXPECT_EQ(1, browser()->tab_strip_model()->count()); | ||
Comment on lines
+81
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, do you want to check normal window is not affected? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep |
||
} | ||
|
||
// Check loading |url| in private window is redirected to normal | ||
// window. | ||
void TestURLIsNotLoadedInPrivateWindow(const std::string& url) { | ||
|
@@ -260,3 +286,8 @@ IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest, | |
BraveWelcomePageIsNotAllowedInPrivateWindow) { | ||
TestURLIsNotLoadedInPrivateWindow("brave://welcome"); | ||
} | ||
|
||
IN_PROC_BROWSER_TEST_F(BraveSchemeLoadBrowserTest, | ||
BraveWelcomePageIsNotAllowedInGuestWindow) { | ||
TestURLIsNotLoadedInGuestWindow(GURL("brave://welcome")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: these line can be deleted as we don't need to check normal window's state