OLD | NEW |
---|---|
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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/cancelable_callback.h" | 8 #include "base/cancelable_callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/files/file_path.h" | |
11 #include "base/location.h" | 12 #include "base/location.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
18 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
20 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "content/public/common/content_switches.h" | 58 #include "content/public/common/content_switches.h" |
58 #include "content/public/test/browser_test_utils.h" | 59 #include "content/public/test/browser_test_utils.h" |
59 #include "content/public/test/test_navigation_observer.h" | 60 #include "content/public/test/test_navigation_observer.h" |
60 #include "extensions/browser/extension_registry.h" | 61 #include "extensions/browser/extension_registry.h" |
61 #include "extensions/browser/extension_system.h" | 62 #include "extensions/browser/extension_system.h" |
62 #include "extensions/browser/notification_types.h" | 63 #include "extensions/browser/notification_types.h" |
63 #include "extensions/common/switches.h" | 64 #include "extensions/common/switches.h" |
64 #include "extensions/common/value_builder.h" | 65 #include "extensions/common/value_builder.h" |
65 #include "net/dns/mock_host_resolver.h" | 66 #include "net/dns/mock_host_resolver.h" |
66 #include "net/test/spawned_test_server/spawned_test_server.h" | 67 #include "net/test/spawned_test_server/spawned_test_server.h" |
68 #include "net/test/url_request/url_request_mock_http_job.h" | |
69 #include "net/url_request/url_request_context.h" | |
70 #include "net/url_request/url_request_filter.h" | |
71 #include "net/url_request/url_request_http_job.h" | |
67 #include "third_party/WebKit/public/web/WebInputEvent.h" | 72 #include "third_party/WebKit/public/web/WebInputEvent.h" |
68 #include "ui/compositor/compositor_switches.h" | 73 #include "ui/compositor/compositor_switches.h" |
69 #include "ui/gl/gl_switches.h" | 74 #include "ui/gl/gl_switches.h" |
75 #include "url/gurl.h" | |
70 | 76 |
71 using app_modal::AppModalDialog; | 77 using app_modal::AppModalDialog; |
72 using app_modal::JavaScriptAppModalDialog; | 78 using app_modal::JavaScriptAppModalDialog; |
73 using app_modal::NativeAppModalDialog; | 79 using app_modal::NativeAppModalDialog; |
74 using content::BrowserThread; | 80 using content::BrowserThread; |
75 using content::DevToolsAgentHost; | 81 using content::DevToolsAgentHost; |
76 using content::NavigationController; | 82 using content::NavigationController; |
77 using content::RenderViewHost; | 83 using content::RenderViewHost; |
78 using content::WebContents; | 84 using content::WebContents; |
79 using content::WorkerService; | 85 using content::WorkerService; |
80 using content::WorkerServiceObserver; | 86 using content::WorkerServiceObserver; |
81 using extensions::Extension; | 87 using extensions::Extension; |
82 | 88 |
83 namespace { | 89 namespace { |
84 | 90 |
85 const char kDebuggerTestPage[] = "files/devtools/debugger_test_page.html"; | 91 const char kDebuggerTestPage[] = "files/devtools/debugger_test_page.html"; |
86 const char kPauseWhenLoadingDevTools[] = | 92 const char kPauseWhenLoadingDevTools[] = |
87 "files/devtools/pause_when_loading_devtools.html"; | 93 "files/devtools/pause_when_loading_devtools.html"; |
88 const char kPauseWhenScriptIsRunning[] = | 94 const char kPauseWhenScriptIsRunning[] = |
89 "files/devtools/pause_when_script_is_running.html"; | 95 "files/devtools/pause_when_script_is_running.html"; |
90 const char kPageWithContentScript[] = | 96 const char kPageWithContentScript[] = |
91 "files/devtools/page_with_content_script.html"; | 97 "files/devtools/page_with_content_script.html"; |
92 const char kNavigateBackTestPage[] = | 98 const char kNavigateBackTestPage[] = |
93 "files/devtools/navigate_back.html"; | 99 "files/devtools/navigate_back.html"; |
94 const char kWindowOpenTestPage[] = "files/devtools/window_open.html"; | 100 const char kWindowOpenTestPage[] = "files/devtools/window_open.html"; |
95 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html"; | 101 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html"; |
96 const char kChunkedTestPage[] = "chunked"; | 102 const char kChunkedTestPage[] = "chunked"; |
103 const char kPushTestPage[] = "files/devtools/push_test_page.html"; | |
104 // The resource is not really pushed, but mock url request job pretends it is. | |
105 const char kPushTestResource[] = "devtools/image.png"; | |
106 const char kPushUseNullEndTime[] = "pushUseNullEndTime"; | |
97 const char kSlowTestPage[] = | 107 const char kSlowTestPage[] = |
98 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; | 108 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; |
99 const char kSharedWorkerTestPage[] = | 109 const char kSharedWorkerTestPage[] = |
100 "files/workers/workers_ui_shared_worker.html"; | 110 "files/workers/workers_ui_shared_worker.html"; |
101 const char kSharedWorkerTestWorker[] = | 111 const char kSharedWorkerTestWorker[] = |
102 "files/workers/workers_ui_shared_worker.js"; | 112 "files/workers/workers_ui_shared_worker.js"; |
103 const char kReloadSharedWorkerTestPage[] = | 113 const char kReloadSharedWorkerTestPage[] = |
104 "files/workers/debug_shared_worker_initialization.html"; | 114 "files/workers/debug_shared_worker_initialization.html"; |
105 const char kReloadSharedWorkerTestWorker[] = | 115 const char kReloadSharedWorkerTestWorker[] = |
106 "files/workers/debug_shared_worker_initialization.js"; | 116 "files/workers/debug_shared_worker_initialization.js"; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 const Extension* devtools_extension, | 168 const Extension* devtools_extension, |
159 const char* panel_name) { | 169 const char* panel_name) { |
160 // The full name is the concatenation of the extension URL (stripped of its | 170 // The full name is the concatenation of the extension URL (stripped of its |
161 // trailing '/') and the |panel_name| that was passed to panels.create(). | 171 // trailing '/') and the |panel_name| that was passed to panels.create(). |
162 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/", | 172 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/", |
163 base::TRIM_TRAILING) | 173 base::TRIM_TRAILING) |
164 .as_string(); | 174 .as_string(); |
165 SwitchToPanel(window, (prefix + panel_name).c_str()); | 175 SwitchToPanel(window, (prefix + panel_name).c_str()); |
166 } | 176 } |
167 | 177 |
178 class PushTimesMockURLRequestJob : public net::URLRequestMockHTTPJob { | |
179 public: | |
180 PushTimesMockURLRequestJob(net::URLRequest* request, | |
181 net::NetworkDelegate* network_delegate, | |
182 base::FilePath file_path) | |
183 : net::URLRequestMockHTTPJob( | |
184 request, | |
185 network_delegate, | |
186 file_path, | |
187 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | |
188 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {} | |
189 | |
190 void Start() override { | |
191 load_timing_info_.socket_reused = true; | |
192 load_timing_info_.request_start_time = base::Time::Now(); | |
193 load_timing_info_.request_start = base::TimeTicks::Now(); | |
194 load_timing_info_.send_start = base::TimeTicks::Now(); | |
195 load_timing_info_.send_end = base::TimeTicks::Now(); | |
196 load_timing_info_.receive_headers_end = base::TimeTicks::Now(); | |
197 | |
198 net::URLRequestMockHTTPJob::Start(); | |
199 } | |
200 | |
201 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override { | |
202 load_timing_info_.push_start = load_timing_info_.request_start - | |
203 base::TimeDelta::FromMilliseconds(100); | |
204 if (load_timing_info_.push_end.is_null() && | |
205 request()->url().query() != kPushUseNullEndTime) { | |
206 load_timing_info_.push_end = base::TimeTicks::Now(); | |
207 } | |
208 *load_timing_info = load_timing_info_; | |
209 } | |
210 | |
211 private: | |
212 mutable net::LoadTimingInfo load_timing_info_; | |
213 DISALLOW_COPY_AND_ASSIGN(PushTimesMockURLRequestJob); | |
214 }; | |
215 | |
216 class TestInterceptor : public net::URLRequestInterceptor { | |
217 public: | |
218 // Creates TestInterceptor and registers it with the URLRequestFilter, | |
219 // which takes ownership of it. | |
220 static void Register(const GURL& url, const base::FilePath& file_path) { | |
221 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
222 net::URLRequestFilter::GetInstance()->AddHostnameInterceptor( | |
223 url.scheme(), url.host(), | |
224 make_scoped_ptr(new TestInterceptor(url, file_path))); | |
225 } | |
226 | |
227 // Unregisters previously created TestInterceptor, which should delete it. | |
228 static void Unregister(const GURL& url) { | |
229 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
230 net::URLRequestFilter::GetInstance()->RemoveHostnameHandler(url.scheme(), | |
231 url.host()); | |
232 } | |
233 | |
234 // net::URLRequestJobFactory::ProtocolHandler implementation: | |
235 net::URLRequestJob* MaybeInterceptRequest( | |
236 net::URLRequest* request, | |
237 net::NetworkDelegate* network_delegate) const override { | |
238 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
239 if (request->url().path() != url_.path()) | |
240 return nullptr; | |
241 return new PushTimesMockURLRequestJob(request, network_delegate, | |
242 file_path_); | |
243 } | |
244 | |
245 private: | |
246 TestInterceptor(const GURL& url, const base::FilePath& file_path) | |
247 : url_(url), file_path_(file_path) {} | |
248 | |
249 const GURL url_; | |
250 const base::FilePath file_path_; | |
251 | |
252 DISALLOW_COPY_AND_ASSIGN(TestInterceptor); | |
253 }; | |
254 | |
168 } // namespace | 255 } // namespace |
169 | 256 |
170 class DevToolsSanityTest : public InProcessBrowserTest { | 257 class DevToolsSanityTest : public InProcessBrowserTest { |
171 public: | 258 public: |
172 DevToolsSanityTest() : window_(NULL) {} | 259 DevToolsSanityTest() : window_(NULL) {} |
173 | 260 |
174 void SetUpOnMainThread() override { | 261 void SetUpOnMainThread() override { |
175 host_resolver()->AddRule("*", "127.0.0.1"); | 262 host_resolver()->AddRule("*", "127.0.0.1"); |
176 } | 263 } |
177 | 264 |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 // Tests raw headers text. | 1022 // Tests raw headers text. |
936 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) { | 1023 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) { |
937 RunTest("testNetworkSyncSize", kChunkedTestPage); | 1024 RunTest("testNetworkSyncSize", kChunkedTestPage); |
938 } | 1025 } |
939 | 1026 |
940 // Tests raw headers text. | 1027 // Tests raw headers text. |
941 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) { | 1028 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) { |
942 RunTest("testNetworkRawHeadersText", kChunkedTestPage); | 1029 RunTest("testNetworkRawHeadersText", kChunkedTestPage); |
943 } | 1030 } |
944 | 1031 |
1032 // Tests raw headers text. | |
dgozman
2016/04/15 21:13:16
Wrong comment. Just remove it.
| |
1033 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkPushTime) { | |
1034 OpenDevToolsWindow(kPushTestPage, false); | |
1035 GURL push_url = spawned_test_server()->GetURL(kPushTestResource); | |
1036 base::FilePath file_path = | |
1037 spawned_test_server()->document_root().AppendASCII(kPushTestResource); | |
1038 | |
1039 BrowserThread::PostTask( | |
1040 BrowserThread::IO, FROM_HERE, | |
1041 base::Bind(&TestInterceptor::Register, push_url, file_path)); | |
1042 | |
1043 DispatchOnTestSuite(window_, "testPushTimes", push_url.spec().c_str()); | |
1044 | |
1045 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
1046 base::Bind(&TestInterceptor::Unregister, push_url)); | |
1047 | |
1048 CloseDevToolsWindow(); | |
1049 } | |
1050 | |
945 // Tests that console messages are not duplicated on navigation back. | 1051 // Tests that console messages are not duplicated on navigation back. |
946 #if defined(OS_WIN) | 1052 #if defined(OS_WIN) |
947 // Flaking on windows swarm try runs: crbug.com/409285. | 1053 // Flaking on windows swarm try runs: crbug.com/409285. |
948 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack | 1054 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack |
949 #else | 1055 #else |
950 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack | 1056 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack |
951 #endif | 1057 #endif |
952 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { | 1058 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { |
953 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); | 1059 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); |
954 } | 1060 } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 | 1347 |
1242 SimulateTapAt(web_contents, gfx::Point(30, 60)); | 1348 SimulateTapAt(web_contents, gfx::Point(30, 60)); |
1243 DispatchInPageAndWait("waitForEvent", "gesturetap"); | 1349 DispatchInPageAndWait("waitForEvent", "gesturetap"); |
1244 | 1350 |
1245 DispatchAndWait("stopTimeline"); | 1351 DispatchAndWait("stopTimeline"); |
1246 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown", | 1352 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown", |
1247 "MouseWheel", "GestureTap"); | 1353 "MouseWheel", "GestureTap"); |
1248 | 1354 |
1249 CloseDevToolsWindow(); | 1355 CloseDevToolsWindow(); |
1250 } | 1356 } |
OLD | NEW |