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

Side by Side Diff: chrome/browser/ui/search/instant_browsertest.cc

Issue 13516002: Whitelist Instant processes for content settings (Closed) Base URL: http://git.chromium.org/chromium/src.git@omniboxtest
Patch Set: 4 Created 7 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 "chrome/browser/content_settings/host_content_settings_map.h" 5 #include "chrome/browser/content_settings/host_content_settings_map.h"
6 #include "chrome/browser/history/history_service_factory.h" 6 #include "chrome/browser/history/history_service_factory.h"
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search/instant_service.h" 8 #include "chrome/browser/search/instant_service.h"
9 #include "chrome/browser/search/instant_service_factory.h" 9 #include "chrome/browser/search/instant_service_factory.h"
10 #include "chrome/browser/search_engines/template_url_service.h" 10 #include "chrome/browser/search_engines/template_url_service.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/task_manager/task_manager.h" 12 #include "chrome/browser/task_manager/task_manager.h"
13 #include "chrome/browser/task_manager/task_manager_browsertest_util.h" 13 #include "chrome/browser/task_manager/task_manager_browsertest_util.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_commands.h" 15 #include "chrome/browser/ui/browser_commands.h"
16 #include "chrome/browser/ui/host_desktop.h" 16 #include "chrome/browser/ui/host_desktop.h"
17 #include "chrome/browser/ui/omnibox/omnibox_view.h" 17 #include "chrome/browser/ui/omnibox/omnibox_view.h"
18 #include "chrome/browser/ui/search/instant_overlay.h" 18 #include "chrome/browser/ui/search/instant_overlay.h"
19 #include "chrome/browser/ui/search/instant_test_utils.h" 19 #include "chrome/browser/ui/search/instant_test_utils.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/common/content_settings_types.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/interactive_test_utils.h" 24 #include "chrome/test/base/interactive_test_utils.h"
24 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
25 #include "content/public/browser/render_process_host.h" 26 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
27 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
30 31
(...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 content::WebContents* active_tab = 995 content::WebContents* active_tab =
995 browser()->tab_strip_model()->GetActiveWebContents(); 996 browser()->tab_strip_model()->GetActiveWebContents();
996 EXPECT_TRUE(instant_service->IsInstantProcess( 997 EXPECT_TRUE(instant_service->IsInstantProcess(
997 active_tab->GetRenderProcessHost()->GetID())); 998 active_tab->GetRenderProcessHost()->GetID()));
998 999
999 // Navigating away should change the process. 1000 // Navigating away should change the process.
1000 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); 1001 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
1001 EXPECT_FALSE(instant_service->IsInstantProcess( 1002 EXPECT_FALSE(instant_service->IsInstantProcess(
1002 active_tab->GetRenderProcessHost()->GetID())); 1003 active_tab->GetRenderProcessHost()->GetID()));
1003 } 1004 }
1005
1006 IN_PROC_BROWSER_TEST_F(InstantTest, ContentSettingsWhitelist) {
1007 // Creates a 2x2 pixel image element and checks its height after it loads.
1008 const char* kImageRenderScript =
1009 "var testImage = document.createElement('img');"
1010 "testImage.onload = function () {"
1011 " domAutomationController.send(testImage.height > 0); };"
1012 "testImage.src = 'data:image/png;base64,Qk1GAAAAAAAAADYAAAAoAAAAAgAAAAIA"
1013 "AAABABgAAAAAAAAAAADEDgAAxA4AAAAAAAAAAAAAAAAAAAAAAP8AAAAAAAAA/w==';";
1014
1015 Profile* profile = browser()->profile();
1016
1017 // Block images through content settings.
1018 profile->GetHostContentSettingsMap()->SetDefaultContentSetting(
1019 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
1020
1021 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
1022 FocusOmniboxAndWaitForInstantSupport();
1023
1024 InstantService* instant_service =
1025 InstantServiceFactory::GetForProfile(profile);
1026 ASSERT_NE(static_cast<InstantService*>(NULL), instant_service);
1027
1028 // Make sure this is an Instant process.
1029 content::WebContents* overlay = instant()->GetOverlayContents();
1030 EXPECT_TRUE(instant_service->IsInstantProcess(
1031 overlay->GetRenderProcessHost()->GetID()));
1032
1033 bool result;
1034 EXPECT_TRUE(ExecuteScriptAndExtractBool(overlay, kImageRenderScript,
1035 &result));
1036 EXPECT_TRUE(result);
1037 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/content_settings_observer.cc » ('j') | chrome/renderer/content_settings_observer.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698