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

Unified Diff: chrome/browser/extensions/window_open_apitest.cc

Issue 2830893002: Refactor of ExtensionNavigationThrottle (Closed)
Patch Set: \ Created 3 years, 7 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
Index: chrome/browser/extensions/window_open_apitest.cc
diff --git a/chrome/browser/extensions/window_open_apitest.cc b/chrome/browser/extensions/window_open_apitest.cc
index 249386fa768f3d7597469b6c7c996a95c4d17f45..da1e5d7b6eda4633172ed0c988a875f4f9243e1e 100644
--- a/chrome/browser/extensions/window_open_apitest.cc
+++ b/chrome/browser/extensions/window_open_apitest.cc
@@ -17,11 +17,13 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/ui_test_utils.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/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/common/browser_side_navigation_policy.h"
#include "content/public/common/result_codes.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
@@ -244,7 +246,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) {
WebContents* newtab = NULL;
ASSERT_NO_FATAL_FAILURE(
OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(),
- start_url.Resolve("newtab.html"), true, &newtab));
+ start_url.Resolve("newtab.html"), true, &newtab));
bool result = false;
ASSERT_TRUE(content::ExecuteScriptAndExtractBool(newtab, "testExtensionApi()",
@@ -255,19 +257,32 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) {
// Tests that if an extension page calls window.open to an invalid extension
// URL, the browser doesn't crash.
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) {
- ASSERT_TRUE(LoadExtension(
- test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
+ const extensions::Extension* extension = LoadExtension(
+ test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"));
+ ASSERT_TRUE(extension);
- GURL start_url(std::string(extensions::kExtensionScheme) +
- url::kStandardSchemeSeparator +
- last_loaded_extension_id() + "/test.html");
+ GURL start_url = extension->GetResourceURL("/test.html");
ui_test_utils::NavigateToURL(browser(), start_url);
- ASSERT_NO_FATAL_FAILURE(
- OpenWindow(browser()->tab_strip_model()->GetActiveWebContents(),
+ WebContents* newtab = nullptr;
+ bool expect_error_page_in_new_process =
+ content::IsBrowserSideNavigationEnabled();
+ ASSERT_NO_FATAL_FAILURE(OpenWindow(
+ browser()->tab_strip_model()->GetActiveWebContents(),
GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"),
- false, NULL));
+ expect_error_page_in_new_process, &newtab));
+
+ // This is expected to commit an error page.
+ ASSERT_EQ(content::PAGE_TYPE_ERROR,
+ newtab->GetController().GetLastCommittedEntry()->GetPageType());
+
+ std::string document_body;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractString(
+ newtab, "domAutomationController.send(document.body.innerText.trim());",
+ &document_body));
- // If we got to this point, we didn't crash, so we're good.
+ // Currently, in this test, the error page is blocked by CSP. This is
+ // https://crbug.com/703801.
+ EXPECT_EQ("", document_body);
}
// Tests that calling window.open from the newtab page to an extension URL
« no previous file with comments | « chrome/browser/extensions/process_manager_browsertest.cc ('k') | chrome/browser/ui/toolbar/toolbar_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698