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

Side by Side Diff: chrome/browser/extensions/lazy_background_page_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, 4 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/file_path.h" 6 #include "base/file_path.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/bookmarks/bookmark_model.h" 8 #include "chrome/browser/bookmarks/bookmark_model.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h" 9 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/extension_apitest.h" 10 #include "chrome/browser/extensions/extension_apitest.h"
11 #include "chrome/browser/extensions/extension_host.h" 11 #include "chrome/browser/extensions/extension_host.h"
12 #include "chrome/browser/extensions/extension_test_message_listener.h" 12 #include "chrome/browser/extensions/extension_test_message_listener.h"
13 #include "chrome/browser/extensions/extension_service.h" 13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/lazy_background_page_test_util.h" 14 #include "chrome/browser/extensions/lazy_background_page_test_util.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_tabstrip.h" 17 #include "chrome/browser/ui/browser_tabstrip.h"
18 #include "chrome/browser/ui/browser_window.h" 18 #include "chrome/browser/ui/browser_window.h"
19 #include "chrome/browser/ui/omnibox/location_bar.h" 19 #include "chrome/browser/ui/omnibox/location_bar.h"
20 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
21 #include "chrome/common/chrome_switches.h" 21 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/extensions/extension.h" 22 #include "chrome/common/extensions/extension.h"
23 #include "chrome/test/base/ui_test_utils.h" 23 #include "chrome/test/base/ui_test_utils.h"
24 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
26 #include "content/public/test/browser_test_utils.h"
26 #include "googleurl/src/gurl.h" 27 #include "googleurl/src/gurl.h"
27 #include "net/base/mock_host_resolver.h" 28 #include "net/base/mock_host_resolver.h"
28 29
29 using extensions::Extension; 30 using extensions::Extension;
30 31
31 namespace { 32 namespace {
32 33
33 // This unfortunate bit of silliness is necessary when loading an extension in 34 // This unfortunate bit of silliness is necessary when loading an extension in
34 // incognito. The goal is to load the extension, enable incognito, then wait 35 // incognito. The goal is to load the extension, enable incognito, then wait
35 // for both background pages to load and close. The problem is that enabling 36 // for both background pages to load and close. The problem is that enabling
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 240
240 // Lazy Background Page still exists, because the extension started a request. 241 // Lazy Background Page still exists, because the extension started a request.
241 ExtensionProcessManager* pm = 242 ExtensionProcessManager* pm =
242 browser()->profile()->GetExtensionProcessManager(); 243 browser()->profile()->GetExtensionProcessManager();
243 ExtensionHost* host = 244 ExtensionHost* host =
244 pm->GetBackgroundHostForExtension(last_loaded_extension_id_); 245 pm->GetBackgroundHostForExtension(last_loaded_extension_id_);
245 ASSERT_TRUE(host); 246 ASSERT_TRUE(host);
246 247
247 // Abort the request. 248 // Abort the request.
248 bool result = false; 249 bool result = false;
249 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 250 EXPECT_TRUE(content::ExecuteJavaScriptAndExtractBool(
250 host->render_view_host(), std::wstring(), L"abortRequest()", &result)); 251 host->render_view_host(), std::wstring(), L"abortRequest()", &result));
251 EXPECT_TRUE(result); 252 EXPECT_TRUE(result);
252 page_complete.Wait(); 253 page_complete.Wait();
253 254
254 // Lazy Background Page has been shut down. 255 // Lazy Background Page has been shut down.
255 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 256 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
256 } 257 }
257 258
258 // Tests that an incognito split mode extension gets 2 lazy background pages, 259 // Tests that an incognito split mode extension gets 2 lazy background pages,
259 // and they each load and unload at the proper times. 260 // and they each load and unload at the proper times.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_)); 365 EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id_));
365 366
366 // The browser action has a new title. 367 // The browser action has a new title.
367 BrowserActionTestUtil browser_action(browser()); 368 BrowserActionTestUtil browser_action(browser());
368 ASSERT_EQ(1, browser_action.NumberOfBrowserActions()); 369 ASSERT_EQ(1, browser_action.NumberOfBrowserActions());
369 EXPECT_EQ("Success", browser_action.GetTooltip(0)); 370 EXPECT_EQ("Success", browser_action.GetTooltip(0));
370 } 371 }
371 372
372 // TODO: background page with timer. 373 // TODO: background page with timer.
373 // TODO: background page that interacts with popup. 374 // TODO: background page that interacts with popup.
OLDNEW
« no previous file with comments | « chrome/browser/extensions/isolated_app_browsertest.cc ('k') | chrome/browser/extensions/options_page_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698