Chromium Code Reviews| 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..f21fe93fcaab7aa395b955925abbae7e7fbda3cb 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 = "uninitialized"; |
|
Devlin
2017/05/12 01:19:42
is this just to allow contrast with the expected v
ncarter (slow)
2017/05/12 17:32:19
Removed; EXPECT_TRUE here suffices to make sure th
|
| + EXPECT_TRUE(content::ExecuteScriptAndExtractString( |
| + newtab, "domAutomationController.send(document.body.innerText);", |
| + &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); |
|
Devlin
2017/05/12 01:19:42
This looks like it's failing because the result is
ncarter (slow)
2017/05/12 17:32:19
Did the trim() in js. Done.
|
| } |
| // Tests that calling window.open from the newtab page to an extension URL |