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

Side by Side Diff: content/shell/renderer/test_runner/web_test_proxy.cc

Issue 995773002: Add testRunner.dumpNavigationPolicy() to be able to the the navigation policy (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
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/shell/renderer/test_runner/web_test_proxy.h" 5 #include "content/shell/renderer/test_runner/web_test_proxy.h"
6 6
7 #include <cctype> 7 #include <cctype>
8 8
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 case blink::WebNavigationTypeReload: 231 case blink::WebNavigationTypeReload:
232 return kReloadString; 232 return kReloadString;
233 case blink::WebNavigationTypeFormResubmitted: 233 case blink::WebNavigationTypeFormResubmitted:
234 return kFormResubmittedString; 234 return kFormResubmittedString;
235 case blink::WebNavigationTypeOther: 235 case blink::WebNavigationTypeOther:
236 return kOtherString; 236 return kOtherString;
237 } 237 }
238 return kIllegalString; 238 return kIllegalString;
239 } 239 }
240 240
241 const char* kPolicyIgnore = "Ignore";
242 const char* kPolicyDownload = "download";
243 const char* kPolicyCurrentTab = "current tab";
244 const char* kPolicyNewBackgroundTab = "new background tab";
245 const char* kPolicyNewForegroundTab = "new foreground tab";
246 const char* kPolicyNewWindow = "new window";
247 const char* kPolicyNewPopup = "new popup";
248
249 const char* WebNavigationPolicyToString(blink::WebNavigationPolicy policy) {
250 switch (policy) {
251 case blink::WebNavigationPolicyIgnore:
252 return kPolicyIgnore;
253 case blink::WebNavigationPolicyDownload:
254 return kPolicyDownload;
255 case blink::WebNavigationPolicyCurrentTab:
256 return kPolicyCurrentTab;
257 case blink::WebNavigationPolicyNewBackgroundTab:
258 return kPolicyNewBackgroundTab;
259 case blink::WebNavigationPolicyNewForegroundTab:
260 return kPolicyNewForegroundTab;
261 case blink::WebNavigationPolicyNewWindow:
262 return kPolicyNewWindow;
263 case blink::WebNavigationPolicyNewPopup:
264 return kPolicyNewPopup;
265 }
266 return kIllegalString;
267 }
268
241 std::string DumpFrameHeaderIfNeeded(blink::WebFrame* frame) { 269 std::string DumpFrameHeaderIfNeeded(blink::WebFrame* frame) {
242 std::string result; 270 std::string result;
243 271
244 // Add header for all but the main frame. Skip empty frames. 272 // Add header for all but the main frame. Skip empty frames.
245 if (frame->parent() && !frame->document().documentElement().isNull()) { 273 if (frame->parent() && !frame->document().documentElement().isNull()) {
246 result.append("\n--------\nFrame: '"); 274 result.append("\n--------\nFrame: '");
247 result.append(frame->uniqueName().utf8().data()); 275 result.append(frame->uniqueName().utf8().data());
248 result.append("'\n--------\n"); 276 result.append("'\n--------\n");
249 } 277 }
250 278
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1286 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame()) 1314 if (frame != test_interfaces_->GetTestRunner()->topLoadingFrame())
1287 return; 1315 return;
1288 if (reason != MainResourceLoadFailed && 1316 if (reason != MainResourceLoadFailed &&
1289 (frame->isResourceLoadInProgress() || frame->isLoading())) 1317 (frame->isResourceLoadInProgress() || frame->isLoading()))
1290 return; 1318 return;
1291 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true); 1319 test_interfaces_->GetTestRunner()->setTopLoadingFrame(frame, true);
1292 } 1320 }
1293 1321
1294 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation( 1322 blink::WebNavigationPolicy WebTestProxyBase::DecidePolicyForNavigation(
1295 const blink::WebFrameClient::NavigationPolicyInfo& info) { 1323 const blink::WebFrameClient::NavigationPolicyInfo& info) {
1324 if (test_interfaces_->GetTestRunner()->shouldDumpNavigationPolicy()) {
1325 delegate_->PrintMessage("Default policy for navigation to " +
1326 URLDescription(info.urlRequest.url()) + " is '" +
Mike West 2015/03/10 13:10:35 Nit: If you put quotes around the URL, it'll stand
1327 WebNavigationPolicyToString(info.defaultPolicy) +
1328 "'\n");
1329 }
1330
1296 blink::WebNavigationPolicy result; 1331 blink::WebNavigationPolicy result;
1297 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled()) 1332 if (!test_interfaces_->GetTestRunner()->policyDelegateEnabled())
1298 return info.defaultPolicy; 1333 return info.defaultPolicy;
1299 1334
1300 delegate_->PrintMessage( 1335 delegate_->PrintMessage(
1301 std::string("Policy delegate: attempt to load ") + 1336 std::string("Policy delegate: attempt to load ") +
1302 URLDescription(info.urlRequest.url()) + " with navigation type '" + 1337 URLDescription(info.urlRequest.url()) + " with navigation type '" +
1303 WebNavigationTypeToString(info.navigationType) + "'\n"); 1338 WebNavigationTypeToString(info.navigationType) + "'\n");
1304 if (test_interfaces_->GetTestRunner()->policyDelegateIsPermissive()) 1339 if (test_interfaces_->GetTestRunner()->policyDelegateIsPermissive())
1305 result = blink::WebNavigationPolicyCurrentTab; 1340 result = blink::WebNavigationPolicyCurrentTab;
(...skipping 30 matching lines...) Expand all
1336 // to cancel the input method's ongoing composition session. 1371 // to cancel the input method's ongoing composition session.
1337 if (web_widget_) 1372 if (web_widget_)
1338 web_widget_->confirmComposition(); 1373 web_widget_->confirmComposition();
1339 } 1374 }
1340 1375
1341 blink::WebString WebTestProxyBase::acceptLanguages() { 1376 blink::WebString WebTestProxyBase::acceptLanguages() {
1342 return blink::WebString::fromUTF8(accept_languages_); 1377 return blink::WebString::fromUTF8(accept_languages_);
1343 } 1378 }
1344 1379
1345 } // namespace content 1380 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698