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

Side by Side Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 972123003: Fixed behavior in case of disabled devtools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 (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/bind.h" 5 #include "base/bind.h"
6 #include "base/cancelable_callback.h" 6 #include "base/cancelable_callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/test/test_timeouts.h" 14 #include "base/test/test_timeouts.h"
15 #include "chrome/browser/chrome_notification_types.h" 15 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h" 16 #include "chrome/browser/devtools/browser_list_tabcontents_provider.h"
17 #include "chrome/browser/devtools/devtools_window_testing.h" 17 #include "chrome/browser/devtools/devtools_window_testing.h"
18 #include "chrome/browser/extensions/extension_apitest.h" 18 #include "chrome/browser/extensions/extension_apitest.h"
19 #include "chrome/browser/extensions/extension_browsertest.h" 19 #include "chrome/browser/extensions/extension_browsertest.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/unpacked_installer.h" 21 #include "chrome/browser/extensions/unpacked_installer.h"
22 #include "chrome/browser/lifetime/application_lifetime.h" 22 #include "chrome/browser/lifetime/application_lifetime.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
25 #include "chrome/browser/ui/browser_commands.h" 25 #include "chrome/browser/ui/browser_commands.h"
26 #include "chrome/browser/ui/browser_iterator.h" 26 #include "chrome/browser/ui/browser_iterator.h"
27 #include "chrome/browser/ui/tabs/tab_strip_model.h" 27 #include "chrome/browser/ui/tabs/tab_strip_model.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
31 #include "chrome/test/base/in_process_browser_test.h" 32 #include "chrome/test/base/in_process_browser_test.h"
32 #include "chrome/test/base/test_switches.h" 33 #include "chrome/test/base/test_switches.h"
33 #include "chrome/test/base/ui_test_utils.h" 34 #include "chrome/test/base/ui_test_utils.h"
34 #include "components/app_modal/javascript_app_modal_dialog.h" 35 #include "components/app_modal/javascript_app_modal_dialog.h"
35 #include "components/app_modal/native_app_modal_dialog.h" 36 #include "components/app_modal/native_app_modal_dialog.h"
36 #include "content/public/browser/child_process_data.h" 37 #include "content/public/browser/child_process_data.h"
37 #include "content/public/browser/content_browser_client.h" 38 #include "content/public/browser/content_browser_client.h"
38 #include "content/public/browser/devtools_agent_host.h" 39 #include "content/public/browser/devtools_agent_host.h"
39 #include "content/public/browser/devtools_http_handler.h" 40 #include "content/public/browser/devtools_http_handler.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return DevToolsWindowTesting::Get(window_)->main_web_contents(); 148 return DevToolsWindowTesting::Get(window_)->main_web_contents();
148 } 149 }
149 150
150 WebContents* toolbox_web_contents() { 151 WebContents* toolbox_web_contents() {
151 return DevToolsWindowTesting::Get(window_)->toolbox_web_contents(); 152 return DevToolsWindowTesting::Get(window_)->toolbox_web_contents();
152 } 153 }
153 154
154 DevToolsWindow* window_; 155 DevToolsWindow* window_;
155 }; 156 };
156 157
158
159 class DevToolsPolicyTest : public InProcessBrowserTest {
160 public:
161 DevToolsPolicyTest() : window_(NULL) {}
162
163 protected:
164 void OpenDevToolsWindowAndAgentHost(const std::string& test_page) {
dgozman 2015/03/10 19:36:34 |test_page| not used.
165 ASSERT_TRUE(test_server()->Start());
dgozman 2015/03/10 19:36:34 Don't start test server.
166 GURL url("about:blank");
dgozman 2015/03/10 19:36:34 inline
167 ui_test_utils::NavigateToURL(browser(), url);
168 content::WebContents* web_contents =
169 browser()->tab_strip_model()->GetWebContentsAt(0);
170 scoped_refptr<content::DevToolsAgentHost> agent(
171 content::DevToolsAgentHost::GetOrCreateFor(web_contents));
172 DevToolsWindow::OpenDevToolsWindow(web_contents);
173 window_ = DevToolsWindow::FindDevToolsWindow(agent.get());
174 }
175
176 void SetPolicyDevToolsDisabled(bool value) {
177 browser()->profile()->GetPrefs()->SetBoolean(prefs::kDevToolsDisabled,
178 value);
179 }
180
181 bool WindowExists() { return window_; }
182
183 DevToolsWindow* window_;
184 };
185
186
157 // Used to block until a dev tools window gets beforeunload event. 187 // Used to block until a dev tools window gets beforeunload event.
158 class DevToolsWindowBeforeUnloadObserver 188 class DevToolsWindowBeforeUnloadObserver
159 : public content::WebContentsObserver { 189 : public content::WebContentsObserver {
160 public: 190 public:
161 explicit DevToolsWindowBeforeUnloadObserver(DevToolsWindow*); 191 explicit DevToolsWindowBeforeUnloadObserver(DevToolsWindow*);
162 void Wait(); 192 void Wait();
163 private: 193 private:
164 // Invoked when the beforeunload handler fires. 194 // Invoked when the beforeunload handler fires.
165 void BeforeUnloadFired(const base::TimeTicks& proceed_time) override; 195 void BeforeUnloadFired(const base::TimeTicks& proceed_time) override;
166 196
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 ASSERT_TRUE( 896 ASSERT_TRUE(
867 content::ExecuteScriptAndExtractString( 897 content::ExecuteScriptAndExtractString(
868 main_web_contents()->GetRenderViewHost(), 898 main_web_contents()->GetRenderViewHost(),
869 "window.domAutomationController.send(" 899 "window.domAutomationController.send("
870 " '' + (window.uiTests && (typeof uiTests.runTest)));", 900 " '' + (window.uiTests && (typeof uiTests.runTest)));",
871 &result)); 901 &result));
872 ASSERT_EQ("function", result) << "DevTools front-end is broken."; 902 ASSERT_EQ("function", result) << "DevTools front-end is broken.";
873 CloseDevToolsWindow(); 903 CloseDevToolsWindow();
874 } 904 }
875 905
906 IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, PolicyTrue) {
907 SetPolicyDevToolsDisabled(true);
908 OpenDevToolsWindowAndAgentHost(kDebuggerTestPage);
909 ASSERT_FALSE(WindowExists());
910 }
911
912 IN_PROC_BROWSER_TEST_F(DevToolsPolicyTest, PolicyFalse) {
dgozman 2015/03/10 19:36:34 I don't think this tests anything. I'd rather remo
913 SetPolicyDevToolsDisabled(false);
914 OpenDevToolsWindowAndAgentHost(kDebuggerTestPage);
915 ASSERT_TRUE(WindowExists());
916 }
917
876 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest, InspectSharedWorker) { 918 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest, InspectSharedWorker) {
877 #if defined(OS_WIN) && defined(USE_ASH) 919 #if defined(OS_WIN) && defined(USE_ASH)
878 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 920 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
879 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 921 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
880 switches::kAshBrowserTests)) 922 switches::kAshBrowserTests))
881 return; 923 return;
882 #endif 924 #endif
883 925
884 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker); 926 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker);
885 } 927 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) { 988 IN_PROC_BROWSER_TEST_F(RemoteDebuggingTest, MAYBE_RemoteDebugger) {
947 #if defined(OS_WIN) && defined(USE_ASH) 989 #if defined(OS_WIN) && defined(USE_ASH)
948 // Disable this test in Metro+Ash for now (http://crbug.com/262796). 990 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
949 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 991 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
950 switches::kAshBrowserTests)) 992 switches::kAshBrowserTests))
951 return; 993 return;
952 #endif 994 #endif
953 995
954 ASSERT_TRUE(RunExtensionTest("target_list")) << message_; 996 ASSERT_TRUE(RunExtensionTest("target_list")) << message_;
955 } 997 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/devtools/devtools_window.h » ('j') | chrome/browser/devtools/devtools_window.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698