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

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

Issue 1828203005: Expose SPDY pushes in DevTools (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added a test Created 4 years, 8 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 <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
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/url_request/url_request_context.h"
68 #include "net/url_request/url_request_filter.h"
69 #include "net/url_request/url_request_http_job.h"
67 #include "third_party/WebKit/public/web/WebInputEvent.h" 70 #include "third_party/WebKit/public/web/WebInputEvent.h"
68 #include "ui/compositor/compositor_switches.h" 71 #include "ui/compositor/compositor_switches.h"
69 #include "ui/gl/gl_switches.h" 72 #include "ui/gl/gl_switches.h"
70 73
71 using app_modal::AppModalDialog; 74 using app_modal::AppModalDialog;
72 using app_modal::JavaScriptAppModalDialog; 75 using app_modal::JavaScriptAppModalDialog;
73 using app_modal::NativeAppModalDialog; 76 using app_modal::NativeAppModalDialog;
74 using content::BrowserThread; 77 using content::BrowserThread;
75 using content::DevToolsAgentHost; 78 using content::DevToolsAgentHost;
76 using content::NavigationController; 79 using content::NavigationController;
(...skipping 10 matching lines...) Expand all
87 "files/devtools/pause_when_loading_devtools.html"; 90 "files/devtools/pause_when_loading_devtools.html";
88 const char kPauseWhenScriptIsRunning[] = 91 const char kPauseWhenScriptIsRunning[] =
89 "files/devtools/pause_when_script_is_running.html"; 92 "files/devtools/pause_when_script_is_running.html";
90 const char kPageWithContentScript[] = 93 const char kPageWithContentScript[] =
91 "files/devtools/page_with_content_script.html"; 94 "files/devtools/page_with_content_script.html";
92 const char kNavigateBackTestPage[] = 95 const char kNavigateBackTestPage[] =
93 "files/devtools/navigate_back.html"; 96 "files/devtools/navigate_back.html";
94 const char kWindowOpenTestPage[] = "files/devtools/window_open.html"; 97 const char kWindowOpenTestPage[] = "files/devtools/window_open.html";
95 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html"; 98 const char kLatencyInfoTestPage[] = "files/devtools/latency_info.html";
96 const char kChunkedTestPage[] = "chunked"; 99 const char kChunkedTestPage[] = "chunked";
100 const char kPushTestPage[] = "files/devtools/push_test_page.html";
101 // The resource is not really pushed, but mock url request job pretends it is.
102 const char kPushTestResource[] = "files/devtools/image.png";
97 const char kSlowTestPage[] = 103 const char kSlowTestPage[] =
98 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2"; 104 "chunked?waitBeforeHeaders=100&waitBetweenChunks=100&chunksNumber=2";
99 const char kSharedWorkerTestPage[] = 105 const char kSharedWorkerTestPage[] =
100 "files/workers/workers_ui_shared_worker.html"; 106 "files/workers/workers_ui_shared_worker.html";
101 const char kSharedWorkerTestWorker[] = 107 const char kSharedWorkerTestWorker[] =
102 "files/workers/workers_ui_shared_worker.js"; 108 "files/workers/workers_ui_shared_worker.js";
103 const char kReloadSharedWorkerTestPage[] = 109 const char kReloadSharedWorkerTestPage[] =
104 "files/workers/debug_shared_worker_initialization.html"; 110 "files/workers/debug_shared_worker_initialization.html";
105 const char kReloadSharedWorkerTestWorker[] = 111 const char kReloadSharedWorkerTestWorker[] =
106 "files/workers/debug_shared_worker_initialization.js"; 112 "files/workers/debug_shared_worker_initialization.js";
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const Extension* devtools_extension, 164 const Extension* devtools_extension,
159 const char* panel_name) { 165 const char* panel_name) {
160 // The full name is the concatenation of the extension URL (stripped of its 166 // 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(). 167 // trailing '/') and the |panel_name| that was passed to panels.create().
162 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/", 168 std::string prefix = base::TrimString(devtools_extension->url().spec(), "/",
163 base::TRIM_TRAILING) 169 base::TRIM_TRAILING)
164 .as_string(); 170 .as_string();
165 SwitchToPanel(window, (prefix + panel_name).c_str()); 171 SwitchToPanel(window, (prefix + panel_name).c_str());
166 } 172 }
167 173
174 class PushTimesMockURLRequestJob : public net::URLRequestHttpJob {
mmenke 2016/04/08 16:21:36 I'd rather this not inherit from URLRequestHttpJob
caseq 2016/04/08 22:39:28 Done. Note I also took a liberty to nuke another s
175 public:
176 PushTimesMockURLRequestJob(net::URLRequest* request,
177 net::NetworkDelegate* network_delegate)
178 : net::URLRequestHttpJob(request,
179 network_delegate,
180 request->context()->http_user_agent_settings()) {
181 }
182
183 void GetLoadTimingInfo(net::LoadTimingInfo* load_timing_info) const override {
184 net::URLRequestHttpJob::GetLoadTimingInfo(load_timing_info);
185 if (push_end_.is_null())
186 push_end_ = base::TimeTicks::Now();
187 load_timing_info->push_start =
188 request()->creation_time() - base::TimeDelta::FromMilliseconds(10);
189 load_timing_info->push_end = push_end_;
190 }
191
192 private:
193 mutable base::TimeTicks push_end_;
194 DISALLOW_COPY_AND_ASSIGN(PushTimesMockURLRequestJob);
195 };
196
197 class TestInterceptor : public net::URLRequestInterceptor {
198 public:
199 explicit TestInterceptor(const GURL& url) : url_(url) {}
200
201 // Registers |this| with the URLRequestFilter, which takes ownership of it.
202 void Register() {
mmenke 2016/04/08 16:21:36 Suggest making this static, and having it create t
caseq 2016/04/08 22:39:28 Done.
203 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
204 net::URLRequestFilter::GetInstance()->AddUrlInterceptor(
205 url_, scoped_ptr<net::URLRequestInterceptor>(this));
mmenke 2016/04/08 16:21:36 scoped_ptr<net::URLRequestInterceptor> -> make_sco
caseq 2016/04/08 22:39:28 Done.
206 }
207
208 // Unregisters |this| with the URLRequestFilter, which should then delete
209 // |this|.
210 void Unregister() {
mmenke 2016/04/08 16:21:36 Again, suggest making this static. Does mean you'
caseq 2016/04/08 22:39:28 Done.
211 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
212 net::URLRequestFilter::GetInstance()->RemoveUrlHandler(url_);
213 }
214
215 // net::URLRequestJobFactory::ProtocolHandler implementation:
216 net::URLRequestJob* MaybeInterceptRequest(
217 net::URLRequest* request,
218 net::NetworkDelegate* network_delegate) const override {
219 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
220 return new PushTimesMockURLRequestJob(request, network_delegate);
221 }
222
223 private:
224 GURL url_;
225
226 DISALLOW_COPY_AND_ASSIGN(TestInterceptor);
227 };
228
168 } // namespace 229 } // namespace
169 230
170 class DevToolsSanityTest : public InProcessBrowserTest { 231 class DevToolsSanityTest : public InProcessBrowserTest {
171 public: 232 public:
172 DevToolsSanityTest() : window_(NULL) {} 233 DevToolsSanityTest() : window_(NULL) {}
173 234
174 void SetUpOnMainThread() override { 235 void SetUpOnMainThread() override {
175 host_resolver()->AddRule("*", "127.0.0.1"); 236 host_resolver()->AddRule("*", "127.0.0.1");
176 } 237 }
177 238
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
935 // Tests raw headers text. 996 // Tests raw headers text.
936 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) { 997 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkSyncSize) {
937 RunTest("testNetworkSyncSize", kChunkedTestPage); 998 RunTest("testNetworkSyncSize", kChunkedTestPage);
938 } 999 }
939 1000
940 // Tests raw headers text. 1001 // Tests raw headers text.
941 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) { 1002 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkRawHeadersText) {
942 RunTest("testNetworkRawHeadersText", kChunkedTestPage); 1003 RunTest("testNetworkRawHeadersText", kChunkedTestPage);
943 } 1004 }
944 1005
1006 // Tests raw headers text.
1007 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestNetworkPushTime) {
1008 OpenDevToolsWindow(kPushTestPage, false);
1009 GURL push_url = spawned_test_server()->GetURL(kPushTestResource);
1010 TestInterceptor* test_interceptor = new TestInterceptor(push_url);
1011 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1012 base::Bind(&TestInterceptor::Register,
1013 base::Unretained(test_interceptor)));
1014
1015 DispatchOnTestSuite(window_, "testPushTimes", push_url.spec().c_str());
mmenke 2016/04/08 16:21:36 Can we check that the push time is less that send_
caseq 2016/04/08 22:39:28 That's exactly what happens in testPushTime() -- h
mmenke 2016/04/11 17:45:52 Wait....So a chrome/browser/devtools/ test is usin
caseq 2016/04/13 21:48:45 It's been this way since about the time we introdu
mmenke 2016/04/14 15:50:33 The question isn't what's common, or what we expec
mmenke 2016/04/14 15:50:33 Happy to defer to him on that, but he should take
1016
1017 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE,
1018 base::Bind(&TestInterceptor::Unregister,
1019 base::Unretained(test_interceptor)));
1020 CloseDevToolsWindow();
1021 }
1022
945 // Tests that console messages are not duplicated on navigation back. 1023 // Tests that console messages are not duplicated on navigation back.
946 #if defined(OS_WIN) 1024 #if defined(OS_WIN)
947 // Flaking on windows swarm try runs: crbug.com/409285. 1025 // Flaking on windows swarm try runs: crbug.com/409285.
948 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack 1026 #define MAYBE_TestConsoleOnNavigateBack DISABLED_TestConsoleOnNavigateBack
949 #else 1027 #else
950 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack 1028 #define MAYBE_TestConsoleOnNavigateBack TestConsoleOnNavigateBack
951 #endif 1029 #endif
952 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) { 1030 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, MAYBE_TestConsoleOnNavigateBack) {
953 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage); 1031 RunTest("testConsoleOnNavigateBack", kNavigateBackTestPage);
954 } 1032 }
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 1319
1242 SimulateTapAt(web_contents, gfx::Point(30, 60)); 1320 SimulateTapAt(web_contents, gfx::Point(30, 60));
1243 DispatchInPageAndWait("waitForEvent", "gesturetap"); 1321 DispatchInPageAndWait("waitForEvent", "gesturetap");
1244 1322
1245 DispatchAndWait("stopTimeline"); 1323 DispatchAndWait("stopTimeline");
1246 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown", 1324 RunTestMethod("checkInputEventsPresent", "MouseMove", "MouseDown",
1247 "MouseWheel", "GestureTap"); 1325 "MouseWheel", "GestureTap");
1248 1326
1249 CloseDevToolsWindow(); 1327 CloseDevToolsWindow();
1250 } 1328 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/devtools/image.png » ('j') | content/common/inter_process_time_ticks_converter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698