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

Side by Side Diff: chrome/browser/extensions/window_open_apitest.cc

Issue 10795090: Move ExecuteJavaScript functions from ui_test_utils.h to browser_test_utils.h so they can be reused… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/memory/scoped_vector.h" 6 #include "base/memory/scoped_vector.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "chrome/browser/extensions/extension_apitest.h" 8 #include "chrome/browser/extensions/extension_apitest.h"
9 #include "chrome/browser/extensions/extension_test_message_listener.h" 9 #include "chrome/browser/extensions/extension_test_message_listener.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_finder.h" 11 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/browser_list.h" 12 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/test/base/ui_test_utils.h" 16 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/web_contents.h" 17 #include "content/public/browser/web_contents.h"
18 #include "content/public/test/browser_test_utils.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 #include "net/base/mock_host_resolver.h" 20 #include "net/base/mock_host_resolver.h"
20 21
21 using content::OpenURLParams; 22 using content::OpenURLParams;
22 using content::Referrer; 23 using content::Referrer;
23 using content::WebContents; 24 using content::WebContents;
24 25
25 // Disabled, http://crbug.com/64899. 26 // Disabled, http://crbug.com/64899.
26 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpen) { 27 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, DISABLED_WindowOpen) {
27 CommandLine::ForCurrentProcess()->AppendSwitch( 28 CommandLine::ForCurrentProcess()->AppendSwitch(
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 276 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
276 277
277 GURL start_url(std::string("chrome-extension://") + 278 GURL start_url(std::string("chrome-extension://") +
278 last_loaded_extension_id_ + "/test.html"); 279 last_loaded_extension_id_ + "/test.html");
279 ui_test_utils::NavigateToURL(browser(), start_url); 280 ui_test_utils::NavigateToURL(browser(), start_url);
280 WebContents* newtab; 281 WebContents* newtab;
281 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), 282 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()),
282 start_url.Resolve("newtab.html"), true, &newtab)); 283 start_url.Resolve("newtab.html"), true, &newtab));
283 284
284 bool result = false; 285 bool result = false;
285 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 286 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
286 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); 287 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result));
287 EXPECT_TRUE(result); 288 EXPECT_TRUE(result);
288 } 289 }
289 290
290 // Tests that if an extension page calls window.open to an invalid extension 291 // Tests that if an extension page calls window.open to an invalid extension
291 // URL, the browser doesn't crash. 292 // URL, the browser doesn't crash.
292 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { 293 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) {
293 ASSERT_TRUE(LoadExtension( 294 ASSERT_TRUE(LoadExtension(
294 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 295 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
295 296
(...skipping 16 matching lines...) Expand all
312 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 313 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
313 314
314 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); 315 ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
315 WebContents* newtab; 316 WebContents* newtab;
316 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()), 317 ASSERT_NO_FATAL_FAILURE(OpenWindow(chrome::GetActiveWebContents(browser()),
317 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + 318 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ +
318 "/newtab.html"), false, &newtab)); 319 "/newtab.html"), false, &newtab));
319 320
320 // Extension API should succeed. 321 // Extension API should succeed.
321 bool result = false; 322 bool result = false;
322 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 323 ASSERT_TRUE(content::ExecuteJavaScriptAndExtractBool(
323 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); 324 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result));
324 EXPECT_TRUE(result); 325 EXPECT_TRUE(result);
325 } 326 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698