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

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

Issue 2925193002: NOT YET READY: UMA recording the kind of target frame when extensions pierce browsing instance.
Patch Set: Rebasing... Created 3 years, 6 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
« no previous file with comments | « base/test/histogram_tester.h ('k') | chrome/browser/extensions/extension_management.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/test/histogram_tester.h"
7 #include "build/build_config.h" 8 #include "build/build_config.h"
8 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
10 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_util.h" 12 #include "chrome/browser/extensions/extension_util.h"
13 #include "chrome/browser/metrics/subprocess_metrics_provider.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_commands.h" 16 #include "chrome/browser/ui/browser_commands.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_frame_host.h" 20 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/test/browser_test_utils.h" 21 #include "content/public/test/browser_test_utils.h"
20 #include "content/public/test/test_utils.h" 22 #include "content/public/test/test_utils.h"
21 #include "extensions/browser/extension_registry.h" 23 #include "extensions/browser/extension_registry.h"
22 #include "extensions/browser/extension_system.h" 24 #include "extensions/browser/extension_system.h"
23 #include "extensions/browser/extension_util.h" 25 #include "extensions/browser/extension_util.h"
24 #include "extensions/browser/notification_types.h" 26 #include "extensions/browser/notification_types.h"
25 #include "extensions/browser/test_extension_registry_observer.h" 27 #include "extensions/browser/test_extension_registry_observer.h"
28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h"
26 30
27 namespace extensions { 31 namespace extensions {
28 32
29 class ExtensionFunctionalTest : public ExtensionBrowserTest { 33 class ExtensionFunctionalTest : public ExtensionBrowserTest {
30 public: 34 public:
31 void InstallExtensionSilently(ExtensionService* service, 35 void InstallExtensionSilently(ExtensionService* service,
32 const char* filename) { 36 const char* filename) {
33 ExtensionRegistry* registry = ExtensionRegistry::Get(profile()); 37 ExtensionRegistry* registry = ExtensionRegistry::Get(profile());
34 size_t num_before = registry->enabled_extensions().size(); 38 size_t num_before = registry->enabled_extensions().size();
35 39
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 &did_create_popup)); 156 &did_create_popup));
153 ASSERT_TRUE(did_create_popup); 157 ASSERT_TRUE(did_create_popup);
154 content::WebContents* popup_window = new_window_observer.GetWebContents(); 158 content::WebContents* popup_window = new_window_observer.GetWebContents();
155 WaitForLoadStop(popup_window); 159 WaitForLoadStop(popup_window);
156 tab1_popup = popup_window->GetMainFrame(); 160 tab1_popup = popup_window->GetMainFrame();
157 } 161 }
158 EXPECT_EQ(GURL(url::kAboutBlankURL), tab1_popup->GetLastCommittedURL()); 162 EXPECT_EQ(GURL(url::kAboutBlankURL), tab1_popup->GetLastCommittedURL());
159 163
160 // Verify that |tab1_popup| can find unrelated frames from the same extension 164 // Verify that |tab1_popup| can find unrelated frames from the same extension
161 // (i.e. that it can find |tab2|. 165 // (i.e. that it can find |tab2|.
166 base::HistogramTester histogram_tester;
162 std::string location_of_opened_window; 167 std::string location_of_opened_window;
163 EXPECT_TRUE(ExecuteScriptAndExtractString( 168 EXPECT_TRUE(ExecuteScriptAndExtractString(
164 tab1_popup, 169 tab1_popup,
165 "var w = window.open('', 'tab2');\n" 170 "var w = window.open('', 'tab2');\n"
166 "window.domAutomationController.send(w.location.href);", 171 "window.domAutomationController.send(w.location.href);",
167 &location_of_opened_window)); 172 &location_of_opened_window));
168 EXPECT_EQ(tab2->GetLastCommittedURL(), location_of_opened_window); 173 EXPECT_EQ(tab2->GetLastCommittedURL(), location_of_opened_window);
174
175 // Verify UMA got recorded as expected.
176 SubprocessMetricsProvider::MergeHistogramDeltasForTesting();
177 EXPECT_THAT(histogram_tester.GetAllSamples(
178 "Extensions.BrowsingInstanceViolation.ExtensionType"),
179 testing::ElementsAre(base::Bucket(Manifest::TYPE_EXTENSION, 1)));
180 EXPECT_THAT(histogram_tester.GetAllSamples(
181 "Extensions.BrowsingInstanceViolation.ExtensionViewType"),
182 testing::ElementsAre(base::Bucket(VIEW_TYPE_TAB_CONTENTS, 1)));
169 } 183 }
170 184
171 } // namespace extensions 185 } // namespace extensions
OLDNEW
« no previous file with comments | « base/test/histogram_tester.h ('k') | chrome/browser/extensions/extension_management.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698