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" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "content/public/common/content_switches.h" | 57 #include "content/public/common/content_switches.h" |
58 #include "content/public/test/browser_test_utils.h" | 58 #include "content/public/test/browser_test_utils.h" |
59 #include "content/public/test/test_navigation_observer.h" | 59 #include "content/public/test/test_navigation_observer.h" |
60 #include "extensions/browser/extension_registry.h" | 60 #include "extensions/browser/extension_registry.h" |
61 #include "extensions/browser/extension_system.h" | 61 #include "extensions/browser/extension_system.h" |
62 #include "extensions/browser/notification_types.h" | 62 #include "extensions/browser/notification_types.h" |
63 #include "extensions/common/switches.h" | 63 #include "extensions/common/switches.h" |
64 #include "extensions/common/value_builder.h" | 64 #include "extensions/common/value_builder.h" |
65 #include "net/dns/mock_host_resolver.h" | 65 #include "net/dns/mock_host_resolver.h" |
66 #include "net/test/spawned_test_server/spawned_test_server.h" | 66 #include "net/test/spawned_test_server/spawned_test_server.h" |
67 #include "net/test/url_request/url_request_mock_http_job.h" | |
68 #include "net/url_request/url_request_context.h" | |
69 #include "net/url_request/url_request_filter.h" | |
70 #include "net/url_request/url_request_http_job.h" | |
67 #include "third_party/WebKit/public/web/WebInputEvent.h" | 71 #include "third_party/WebKit/public/web/WebInputEvent.h" |
68 #include "ui/compositor/compositor_switches.h" | 72 #include "ui/compositor/compositor_switches.h" |
69 #include "ui/gl/gl_switches.h" | 73 #include "ui/gl/gl_switches.h" |
70 | 74 |
71 using app_modal::AppModalDialog; | 75 using app_modal::AppModalDialog; |
72 using app_modal::JavaScriptAppModalDialog; | 76 using app_modal::JavaScriptAppModalDialog; |
73 using app_modal::NativeAppModalDialog; | 77 using app_modal::NativeAppModalDialog; |
74 using content::BrowserThread; | 78 using content::BrowserThread; |
75 using content::DevToolsAgentHost; | 79 using content::DevToolsAgentHost; |
76 using content::NavigationController; | 80 using content::NavigationController; |
(...skipping 10 matching lines...) Expand all Loading... | |
87 "files/devtools/pause_when_loading_devtools.html"; | 91 "files/devtools/pause_when_loading_devtools.html"; |
88 const char kPauseWhenScriptIsRunning[] = | 92 const char kPauseWhenScriptIsRunning[] = |
89 "files/devtools/pause_when_script_is_running.html"; | 93 "files/devtools/pause_when_script_is_running.html"; |
90 const char kPageWithContentScript[] = | 94 const char kPageWithContentScript[] = |
91 "files/devtools/page_with_content_script.html"; | 95 "files/devtools/page_with_content_script.html"; |
92 const char kNavigateBackTestPage[] = | 96 const char kNavigateBackTestPage[] = |
93 "files/devtools/navigate_back.html"; | 97 "files/devtools/navigate_back.html"; |
94 const char kWindowOpenTestPage[] = "files/devtools/window_open.html"; | 98 const char kWindowOpenTestPage[] = "files/devtools/window_open.html"; |
95 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html"; | 99 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html"; |
96 const char kChunkedTestPage[] = "chunked"; | 100 const char kChunkedTestPage[] = "chunked"; |
101 const char kPushTestPage[] = "files/devtools/push_test_page.html"; | |
102 // The resource is not really pushed, but mock url request job pretends it is. | |
103 const char kPushTestResource[] = "devtools/image.png"; | |
97 const char kSlowTestPage[] = | 104 const char kSlowTestPage[] = |
98 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; | 105 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; |
99 const char kSharedWorkerTestPage[] = | 106 const char kSharedWorkerTestPage[] = |
100 "files/workers/workers_ui_shared_worker.html"; | 107 "files/workers/workers_ui_shared_worker.html"; |
101 const char kSharedWorkerTestWorker[] = | 108 const char kSharedWorkerTestWorker[] = |
102 "files/workers/workers_ui_shared_worker.js"; | 109 "files/workers/workers_ui_shared_worker.js"; |
103 const char kReloadSharedWorkerTestPage[] = | 110 const char kReloadSharedWorkerTestPage[] = |
104 "files/workers/debug_shared_worker_initialization.html"; | 111 "files/workers/debug_shared_worker_initialization.html"; |
105 const char kReloadSharedWorkerTestWorker[] = | 112 const char kReloadSharedWorkerTestWorker[] = |
106 "files/workers/debug_shared_worker_initialization.js"; | 113 "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, | 165 const Extension* devtools_extension, |
159 const char* panel_name) { | 166 const char* panel_name) { |
160 // The full name is the concatenation of the extension URL (stripped of its | 167 // 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(). | 168 // trailing '/') and the |panel_name| that was passed to panels.create(). |
162 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/", | 169 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/", |
163 base::TRIM_TRAILING) | 170 base::TRIM_TRAILING) |
164 .as_string(); | 171 .as_string(); |
165 SwitchToPanel(window, (prefix + panel_name).c_str()); | 172 SwitchToPanel(window, (prefix + panel_name).c_str()); |
166 } | 173 } |
167 | 174 |
175 class PushTimesMockURLRequestJob : public net::URLRequestMockHTTPJob { | |
176 public: | |
177 PushTimesMockURLRequestJob(net::URLRequest* request, | |
178 net::NetworkDelegate* network_delegate, | |
179 base::FilePath file_path) | |
180 : net::URLRequestMockHTTPJob( | |
181 request, | |
182 network_delegate, | |
183 file_path, | |
184 BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior( | |
185 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)) {} | |
186 | |
187 void Start() override { | |
188 load_timing_info_.socket_reused = true; | |
189 load_timing_info_.request_start_time = base::Time::Now(); | |
190 load_timing_info_.request_start = base::TimeTicks::Now(); | |
191 load_timing_info_.send_start = base::TimeTicks::Now(); | |
192 load_timing_info_.send_end = base::TimeTicks::Now(); | |
193 load_timing_info_.receive_headers_end = base::TimeTicks::Now(); | |
194 net::URLRequestMockHTTPJob::Start(); | |
195 } | |
196 | |
197 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override { | |
198 load_timing_info_.push_start = load_timing_info_.request_start - | |
199 base::TimeDelta::FromMilliseconds(100); | |
200 if (load_timing_info_.push_end.is_null()) | |
201 load_timing_info_.push_end = base::TimeTicks::Now(); | |
mmenke
2016/04/11 17:45:52
If we're going to keep the behavior, we should als
caseq
2016/04/13 21:48:45
Done.
| |
202 *load_timing_info = load_timing_info_; | |
203 } | |
204 | |
205 private: | |
206 mutable net::LoadTimingInfo load_timing_info_; | |
207 DISALLOW_COPY_AND_ASSIGN(PushTimesMockURLRequestJob); | |
208 }; | |
209 | |
210 class TestInterceptor : public net::URLRequestInterceptor { | |
211 public: | |
212 // Creates TestInterceptor and registers it with the URLRequestFilter, | |
213 // which takes ownership of it. | |
214 static void Register(const GURL& url, const base::FilePath& file_path) { | |
215 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
216 net::URLRequestFilter::GetInstance()->AddUrlInterceptor( | |
217 url, make_scoped_ptr(new TestInterceptor(url, file_path))); | |
218 } | |
219 | |
220 // Unregisters previously created TestInterceptor, which should delete it. | |
221 static void Unregister(const GURL& url) { | |
222 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
223 net::URLRequestFilter::GetInstance()->RemoveUrlHandler(url); | |
224 } | |
225 | |
226 // net::URLRequestJobFactory::ProtocolHandler implementation: | |
227 net::URLRequestJob* MaybeInterceptRequest( | |
228 net::URLRequest* request, | |
229 net::NetworkDelegate* network_delegate) const override { | |
230 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
231 return new PushTimesMockURLRequestJob(request, network_delegate, | |
232 file_path_); | |
233 } | |
234 | |
235 private: | |
236 TestInterceptor(const GURL& url, const base::FilePath& file_path) | |
237 : url_(url), file_path_(file_path) {} | |
238 | |
239 GURL url_; | |
240 base::FilePath file_path_; | |
mmenke
2016/04/11 17:45:52
nit: Both these can be const
mmenke
2016/04/11 17:45:52
nit: include url/gurl.h, and file_path.h
caseq
2016/04/13 21:48:45
Done.
| |
241 | |
242 DISALLOW_COPY_AND_ASSIGN(TestInterceptor); | |
243 }; | |
244 | |
168 } // namespace | 245 } // namespace |
169 | 246 |
170 class DevToolsSanityTest : public InProcessBrowserTest { | 247 class DevToolsSanityTest : public InProcessBrowserTest { |
171 public: | 248 public: |
172 DevToolsSanityTest() : window_(NULL) {} | 249 DevToolsSanityTest() : window_(NULL) {} |
173 | 250 |
174 void SetUpOnMainThread() override { | 251 void SetUpOnMainThread() override { |
175 host_resolver()->AddRule("*", "127.0.0.1"); | 252 host_resolver()->AddRule("*", "127.0.0.1"); |
176 } | 253 } |
177 | 254 |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
935 // Tests raw headers text. | 1012 // Tests raw headers text. |
936 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) { | 1013 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) { |
937 RunTest("testNetworkSyncSize", kChunkedTestPage); | 1014 RunTest("testNetworkSyncSize", kChunkedTestPage); |
938 } | 1015 } |
939 | 1016 |
940 // Tests raw headers text. | 1017 // Tests raw headers text. |
941 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) { | 1018 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) { |
942 RunTest("testNetworkRawHeadersText", kChunkedTestPage); | 1019 RunTest("testNetworkRawHeadersText", kChunkedTestPage); |
943 } | 1020 } |
944 | 1021 |
1022 // Tests raw headers text. | |
1023 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkPushTime) { | |
1024 OpenDevToolsWindow(kPushTestPage, false); | |
1025 GURL push_url = spawned_test_server()->GetURL(kPushTestResource); | |
1026 base::FilePath file_path = | |
1027 spawned_test_server()->document_root().AppendASCII(kPushTestResource); | |
1028 | |
1029 BrowserThread::PostTask( | |
1030 BrowserThread::IO, FROM_HERE, | |
1031 base::Bind(&TestInterceptor::Register, push_url, file_path)); | |
1032 | |
1033 DispatchOnTestSuite(window_, "testPushTimes", push_url.spec().c_str()); | |
1034 | |
1035 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | |
1036 base::Bind(&TestInterceptor::Unregister, push_url)); | |
1037 | |
1038 CloseDevToolsWindow(); | |
1039 } | |
1040 | |
945 // Tests that console messages are not duplicated on navigation back. | 1041 // Tests that console messages are not duplicated on navigation back. |
946 #if defined(OS_WIN) | 1042 #if defined(OS_WIN) |
947 // Flaking on windows swarm try runs: crbug.com/409285. | 1043 // Flaking on windows swarm try runs: crbug.com/409285. |
948 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack | 1044 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack |
949 #else | 1045 #else |
950 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack | 1046 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack |
951 #endif | 1047 #endif |
952 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { | 1048 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { |
953 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); | 1049 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); |
954 } | 1050 } |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1241 | 1337 |
1242 SimulateTapAt(web_contents, gfx::Point(30, 60)); | 1338 SimulateTapAt(web_contents, gfx::Point(30, 60)); |
1243 DispatchInPageAndWait("waitForEvent", "gesturetap"); | 1339 DispatchInPageAndWait("waitForEvent", "gesturetap"); |
1244 | 1340 |
1245 DispatchAndWait("stopTimeline"); | 1341 DispatchAndWait("stopTimeline"); |
1246 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown", | 1342 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown", |
1247 "MouseWheel", "GestureTap"); | 1343 "MouseWheel", "GestureTap"); |
1248 | 1344 |
1249 CloseDevToolsWindow(); | 1345 CloseDevToolsWindow(); |
1250 } | 1346 } |
OLD | NEW |