OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 9 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); | 29 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
30 https_server_->ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); | 30 https_server_->ServeFilesFromSourceDirectory(base::FilePath(kDocRoot)); |
31 ASSERT_TRUE(https_server_->Start()); | 31 ASSERT_TRUE(https_server_->Start()); |
32 } | 32 } |
33 | 33 |
34 TabSpecificContentSettings* GetActiveTabSpecificContentSettings() { | 34 TabSpecificContentSettings* GetActiveTabSpecificContentSettings() { |
35 return TabSpecificContentSettings::FromWebContents( | 35 return TabSpecificContentSettings::FromWebContents( |
36 browser()->tab_strip_model()->GetActiveWebContents()); | 36 browser()->tab_strip_model()->GetActiveWebContents()); |
37 } | 37 } |
38 | 38 |
39 scoped_ptr<net::EmbeddedTestServer> https_server_; | 39 std::unique_ptr<net::EmbeddedTestServer> https_server_; |
40 }; | 40 }; |
41 | 41 |
42 // Tests that a MIXEDSCRIPT type ContentSettingBubbleModel sends appropriate | 42 // Tests that a MIXEDSCRIPT type ContentSettingBubbleModel sends appropriate |
43 // IPCs to allow the renderer to load unsafe scripts and refresh the page | 43 // IPCs to allow the renderer to load unsafe scripts and refresh the page |
44 // automatically. | 44 // automatically. |
45 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMixedScriptTest, MainFrame) { | 45 IN_PROC_BROWSER_TEST_F(ContentSettingBubbleModelMixedScriptTest, MainFrame) { |
46 GURL url(https_server_->GetURL("/content_setting_bubble/mixed_script.html")); | 46 GURL url(https_server_->GetURL("/content_setting_bubble/mixed_script.html")); |
47 | 47 |
48 // Load a page with mixed content and do quick verification by looking at | 48 // Load a page with mixed content and do quick verification by looking at |
49 // the title string. | 49 // the title string. |
50 ui_test_utils::NavigateToURL(browser(), url); | 50 ui_test_utils::NavigateToURL(browser(), url); |
51 | 51 |
52 EXPECT_TRUE(GetActiveTabSpecificContentSettings()->IsContentBlocked( | 52 EXPECT_TRUE(GetActiveTabSpecificContentSettings()->IsContentBlocked( |
53 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | 53 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
54 | 54 |
55 // Emulate link clicking on the mixed script bubble. | 55 // Emulate link clicking on the mixed script bubble. |
56 scoped_ptr<ContentSettingBubbleModel> model( | 56 std::unique_ptr<ContentSettingBubbleModel> model( |
57 ContentSettingBubbleModel::CreateContentSettingBubbleModel( | 57 ContentSettingBubbleModel::CreateContentSettingBubbleModel( |
58 browser()->content_setting_bubble_model_delegate(), | 58 browser()->content_setting_bubble_model_delegate(), |
59 browser()->tab_strip_model()->GetActiveWebContents(), | 59 browser()->tab_strip_model()->GetActiveWebContents(), |
60 browser()->profile(), | 60 browser()->profile(), CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
61 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | |
62 model->OnCustomLinkClicked(); | 61 model->OnCustomLinkClicked(); |
63 | 62 |
64 // Wait for reload | 63 // Wait for reload |
65 content::TestNavigationObserver observer( | 64 content::TestNavigationObserver observer( |
66 browser()->tab_strip_model()->GetActiveWebContents()); | 65 browser()->tab_strip_model()->GetActiveWebContents()); |
67 observer.Wait(); | 66 observer.Wait(); |
68 | 67 |
69 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( | 68 EXPECT_FALSE(GetActiveTabSpecificContentSettings()->IsContentBlocked( |
70 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); | 69 CONTENT_SETTINGS_TYPE_MIXEDSCRIPT)); |
71 } | 70 } |
(...skipping 23 matching lines...) Expand all Loading... |
95 base::FilePath().AppendASCII("content_setting_bubble"), | 94 base::FilePath().AppendASCII("content_setting_bubble"), |
96 base::FilePath().AppendASCII("mixed_script.html"))); | 95 base::FilePath().AppendASCII("mixed_script.html"))); |
97 ui_test_utils::NavigateToURL(browser(), url); | 96 ui_test_utils::NavigateToURL(browser(), url); |
98 content::WebContents* original_tab = GetActiveTab(); | 97 content::WebContents* original_tab = GetActiveTab(); |
99 | 98 |
100 // Create a bubble with the given camera and microphone access state. | 99 // Create a bubble with the given camera and microphone access state. |
101 TabSpecificContentSettings::FromWebContents(original_tab)-> | 100 TabSpecificContentSettings::FromWebContents(original_tab)-> |
102 OnMediaStreamPermissionSet( | 101 OnMediaStreamPermissionSet( |
103 original_tab->GetLastCommittedURL(), | 102 original_tab->GetLastCommittedURL(), |
104 state, std::string(), std::string(), std::string(), std::string()); | 103 state, std::string(), std::string(), std::string(), std::string()); |
105 scoped_ptr<ContentSettingBubbleModel> bubble( | 104 std::unique_ptr<ContentSettingBubbleModel> bubble( |
106 new ContentSettingMediaStreamBubbleModel( | 105 new ContentSettingMediaStreamBubbleModel( |
107 browser()->content_setting_bubble_model_delegate(), | 106 browser()->content_setting_bubble_model_delegate(), original_tab, |
108 original_tab, | |
109 browser()->profile())); | 107 browser()->profile())); |
110 | 108 |
111 // Click the management link, which opens in a new tab or window. | 109 // Click the management link, which opens in a new tab or window. |
112 // Wait until it loads. | 110 // Wait until it loads. |
113 bubble->OnManageLinkClicked(); | 111 bubble->OnManageLinkClicked(); |
114 ASSERT_NE(GetActiveTab(), original_tab); | 112 ASSERT_NE(GetActiveTab(), original_tab); |
115 content::TestNavigationObserver observer(GetActiveTab()); | 113 content::TestNavigationObserver observer(GetActiveTab()); |
116 observer.Wait(); | 114 observer.Wait(); |
117 } | 115 } |
118 | 116 |
(...skipping 25 matching lines...) Expand all Loading... |
144 | 142 |
145 // In ChromeOS, we do not sanitize chrome://settings-frame to | 143 // In ChromeOS, we do not sanitize chrome://settings-frame to |
146 // chrome://settings for same-document navigations. See crbug.com/416157. For | 144 // chrome://settings for same-document navigations. See crbug.com/416157. For |
147 // this reason, order the tests so no same-document navigation occurs. | 145 // this reason, order the tests so no same-document navigation occurs. |
148 | 146 |
149 // The camera bubble links to camera exceptions. | 147 // The camera bubble links to camera exceptions. |
150 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); | 148 ManageMediaStreamSettings(TabSpecificContentSettings::CAMERA_ACCESSED); |
151 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), | 149 EXPECT_EQ(GURL("chrome://settings/contentExceptions#media-stream-camera"), |
152 GetActiveTab()->GetLastCommittedURL()); | 150 GetActiveTab()->GetLastCommittedURL()); |
153 } | 151 } |
OLD | NEW |