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

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

Issue 302043002: Add testRunner callbacks for better handling of view-source frames (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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 | Annotate | Revision Log
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/test_runner.h" 5 #include "content/shell/renderer/test_runner/test_runner.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "content/shell/common/test_runner/test_preferences.h" 10 #include "content/shell/common/test_runner/test_preferences.h"
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 void SetPointerLockWillRespondAsynchronously(); 180 void SetPointerLockWillRespondAsynchronously();
181 void SetPopupBlockingEnabled(bool block_popups); 181 void SetPopupBlockingEnabled(bool block_popups);
182 void SetJavaScriptCanAccessClipboard(bool can_access); 182 void SetJavaScriptCanAccessClipboard(bool can_access);
183 void SetXSSAuditorEnabled(bool enabled); 183 void SetXSSAuditorEnabled(bool enabled);
184 void SetAllowUniversalAccessFromFileURLs(bool allow); 184 void SetAllowUniversalAccessFromFileURLs(bool allow);
185 void SetAllowFileAccessFromFileURLs(bool allow); 185 void SetAllowFileAccessFromFileURLs(bool allow);
186 void OverridePreference(const std::string key, v8::Handle<v8::Value> value); 186 void OverridePreference(const std::string key, v8::Handle<v8::Value> value);
187 void SetAcceptLanguages(const std::string& accept_languages); 187 void SetAcceptLanguages(const std::string& accept_languages);
188 void SetPluginsEnabled(bool enabled); 188 void SetPluginsEnabled(bool enabled);
189 void DumpEditingCallbacks(); 189 void DumpEditingCallbacks();
190 void DumpAsMarkup();
190 void DumpAsText(); 191 void DumpAsText();
191 void DumpAsTextWithPixelResults(); 192 void DumpAsTextWithPixelResults();
192 void DumpChildFrameScrollPositions(); 193 void DumpChildFrameScrollPositions();
194 void DumpChildFramesAsMarkup();
193 void DumpChildFramesAsText(); 195 void DumpChildFramesAsText();
194 void DumpIconChanges(); 196 void DumpIconChanges();
195 void SetAudioData(const gin::ArrayBufferView& view); 197 void SetAudioData(const gin::ArrayBufferView& view);
196 void DumpFrameLoadCallbacks(); 198 void DumpFrameLoadCallbacks();
197 void DumpPingLoaderCallbacks(); 199 void DumpPingLoaderCallbacks();
198 void DumpUserGestureInFrameLoadCallbacks(); 200 void DumpUserGestureInFrameLoadCallbacks();
199 void DumpTitleChanges(); 201 void DumpTitleChanges();
200 void DumpCreateView(); 202 void DumpCreateView();
201 void SetCanOpenWindows(); 203 void SetCanOpenWindows();
202 void DumpResourceLoadCallbacks(); 204 void DumpResourceLoadCallbacks();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 void AddMockSpeechRecognitionResult(const std::string& transcript, 242 void AddMockSpeechRecognitionResult(const std::string& transcript,
241 double confidence); 243 double confidence);
242 void SetMockSpeechRecognitionError(const std::string& error, 244 void SetMockSpeechRecognitionError(const std::string& error,
243 const std::string& message); 245 const std::string& message);
244 bool WasMockSpeechRecognitionAborted(); 246 bool WasMockSpeechRecognitionAborted();
245 void AddWebPageOverlay(); 247 void AddWebPageOverlay();
246 void RemoveWebPageOverlay(); 248 void RemoveWebPageOverlay();
247 void DisplayAsync(); 249 void DisplayAsync();
248 void DisplayAsyncThen(v8::Handle<v8::Function> callback); 250 void DisplayAsyncThen(v8::Handle<v8::Function> callback);
249 void SetCustomTextOutput(std::string output); 251 void SetCustomTextOutput(std::string output);
252 void SetViewSourceForFrame(const std::string& name, bool enabled);
250 253
251 bool GlobalFlag(); 254 bool GlobalFlag();
252 void SetGlobalFlag(bool value); 255 void SetGlobalFlag(bool value);
253 std::string PlatformName(); 256 std::string PlatformName();
254 std::string TooltipText(); 257 std::string TooltipText();
255 bool DisableNotifyDone(); 258 bool DisableNotifyDone();
256 int WebHistoryItemCount(); 259 int WebHistoryItemCount();
257 bool InterceptPostMessage(); 260 bool InterceptPostMessage();
258 void SetInterceptPostMessage(bool value); 261 void SetInterceptPostMessage(bool value);
259 262
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 &TestRunnerBindings::SetXSSAuditorEnabled) 384 &TestRunnerBindings::SetXSSAuditorEnabled)
382 .SetMethod("setAllowUniversalAccessFromFileURLs", 385 .SetMethod("setAllowUniversalAccessFromFileURLs",
383 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) 386 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs)
384 .SetMethod("setAllowFileAccessFromFileURLs", 387 .SetMethod("setAllowFileAccessFromFileURLs",
385 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) 388 &TestRunnerBindings::SetAllowFileAccessFromFileURLs)
386 .SetMethod("overridePreference", &TestRunnerBindings::OverridePreference) 389 .SetMethod("overridePreference", &TestRunnerBindings::OverridePreference)
387 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages) 390 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages)
388 .SetMethod("setPluginsEnabled", &TestRunnerBindings::SetPluginsEnabled) 391 .SetMethod("setPluginsEnabled", &TestRunnerBindings::SetPluginsEnabled)
389 .SetMethod("dumpEditingCallbacks", 392 .SetMethod("dumpEditingCallbacks",
390 &TestRunnerBindings::DumpEditingCallbacks) 393 &TestRunnerBindings::DumpEditingCallbacks)
394 .SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup)
391 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) 395 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText)
392 .SetMethod("dumpAsTextWithPixelResults", 396 .SetMethod("dumpAsTextWithPixelResults",
393 &TestRunnerBindings::DumpAsTextWithPixelResults) 397 &TestRunnerBindings::DumpAsTextWithPixelResults)
394 .SetMethod("dumpChildFrameScrollPositions", 398 .SetMethod("dumpChildFrameScrollPositions",
395 &TestRunnerBindings::DumpChildFrameScrollPositions) 399 &TestRunnerBindings::DumpChildFrameScrollPositions)
396 .SetMethod("dumpChildFramesAsText", 400 .SetMethod("dumpChildFramesAsText",
397 &TestRunnerBindings::DumpChildFramesAsText) 401 &TestRunnerBindings::DumpChildFramesAsText)
402 .SetMethod("dumpChildFramesAsMarkup",
403 &TestRunnerBindings::DumpChildFramesAsMarkup)
398 .SetMethod("dumpIconChanges", &TestRunnerBindings::DumpIconChanges) 404 .SetMethod("dumpIconChanges", &TestRunnerBindings::DumpIconChanges)
399 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) 405 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData)
400 .SetMethod("dumpFrameLoadCallbacks", 406 .SetMethod("dumpFrameLoadCallbacks",
401 &TestRunnerBindings::DumpFrameLoadCallbacks) 407 &TestRunnerBindings::DumpFrameLoadCallbacks)
402 .SetMethod("dumpPingLoaderCallbacks", 408 .SetMethod("dumpPingLoaderCallbacks",
403 &TestRunnerBindings::DumpPingLoaderCallbacks) 409 &TestRunnerBindings::DumpPingLoaderCallbacks)
404 .SetMethod("dumpUserGestureInFrameLoadCallbacks", 410 .SetMethod("dumpUserGestureInFrameLoadCallbacks",
405 &TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks) 411 &TestRunnerBindings::DumpUserGestureInFrameLoadCallbacks)
406 .SetMethod("dumpTitleChanges", &TestRunnerBindings::DumpTitleChanges) 412 .SetMethod("dumpTitleChanges", &TestRunnerBindings::DumpTitleChanges)
407 .SetMethod("dumpCreateView", &TestRunnerBindings::DumpCreateView) 413 .SetMethod("dumpCreateView", &TestRunnerBindings::DumpCreateView)
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 &TestRunnerBindings::SetMockSpeechRecognitionError) 479 &TestRunnerBindings::SetMockSpeechRecognitionError)
474 .SetMethod("wasMockSpeechRecognitionAborted", 480 .SetMethod("wasMockSpeechRecognitionAborted",
475 &TestRunnerBindings::WasMockSpeechRecognitionAborted) 481 &TestRunnerBindings::WasMockSpeechRecognitionAborted)
476 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay) 482 .SetMethod("addWebPageOverlay", &TestRunnerBindings::AddWebPageOverlay)
477 .SetMethod("removeWebPageOverlay", 483 .SetMethod("removeWebPageOverlay",
478 &TestRunnerBindings::RemoveWebPageOverlay) 484 &TestRunnerBindings::RemoveWebPageOverlay)
479 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync) 485 .SetMethod("displayAsync", &TestRunnerBindings::DisplayAsync)
480 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen) 486 .SetMethod("displayAsyncThen", &TestRunnerBindings::DisplayAsyncThen)
481 .SetMethod("setCustomTextOutput", 487 .SetMethod("setCustomTextOutput",
482 &TestRunnerBindings::SetCustomTextOutput) 488 &TestRunnerBindings::SetCustomTextOutput)
489 .SetMethod("setViewSourceForFrame",
490 &TestRunnerBindings::SetViewSourceForFrame)
483 491
484 // Properties. 492 // Properties.
485 .SetProperty("globalFlag", 493 .SetProperty("globalFlag",
486 &TestRunnerBindings::GlobalFlag, 494 &TestRunnerBindings::GlobalFlag,
487 &TestRunnerBindings::SetGlobalFlag) 495 &TestRunnerBindings::SetGlobalFlag)
488 .SetProperty("platformName", &TestRunnerBindings::PlatformName) 496 .SetProperty("platformName", &TestRunnerBindings::PlatformName)
489 .SetProperty("tooltipText", &TestRunnerBindings::TooltipText) 497 .SetProperty("tooltipText", &TestRunnerBindings::TooltipText)
490 .SetProperty("disableNotifyDone", &TestRunnerBindings::DisableNotifyDone) 498 .SetProperty("disableNotifyDone", &TestRunnerBindings::DisableNotifyDone)
491 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history 499 // webHistoryItemCount is used by tests in LayoutTests\http\tests\history
492 .SetProperty("webHistoryItemCount", 500 .SetProperty("webHistoryItemCount",
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 void TestRunnerBindings::SetPluginsEnabled(bool enabled) { 941 void TestRunnerBindings::SetPluginsEnabled(bool enabled) {
934 if (runner_) 942 if (runner_)
935 runner_->SetPluginsEnabled(enabled); 943 runner_->SetPluginsEnabled(enabled);
936 } 944 }
937 945
938 void TestRunnerBindings::DumpEditingCallbacks() { 946 void TestRunnerBindings::DumpEditingCallbacks() {
939 if (runner_) 947 if (runner_)
940 runner_->DumpEditingCallbacks(); 948 runner_->DumpEditingCallbacks();
941 } 949 }
942 950
951 void TestRunnerBindings::DumpAsMarkup() {
952 if (runner_)
953 runner_->DumpAsMarkup();
954 }
955
943 void TestRunnerBindings::DumpAsText() { 956 void TestRunnerBindings::DumpAsText() {
944 if (runner_) 957 if (runner_)
945 runner_->DumpAsText(); 958 runner_->DumpAsText();
946 } 959 }
947 960
948 void TestRunnerBindings::DumpAsTextWithPixelResults() { 961 void TestRunnerBindings::DumpAsTextWithPixelResults() {
949 if (runner_) 962 if (runner_)
950 runner_->DumpAsTextWithPixelResults(); 963 runner_->DumpAsTextWithPixelResults();
951 } 964 }
952 965
953 void TestRunnerBindings::DumpChildFrameScrollPositions() { 966 void TestRunnerBindings::DumpChildFrameScrollPositions() {
954 if (runner_) 967 if (runner_)
955 runner_->DumpChildFrameScrollPositions(); 968 runner_->DumpChildFrameScrollPositions();
956 } 969 }
957 970
958 void TestRunnerBindings::DumpChildFramesAsText() { 971 void TestRunnerBindings::DumpChildFramesAsText() {
959 if (runner_) 972 if (runner_)
960 runner_->DumpChildFramesAsText(); 973 runner_->DumpChildFramesAsText();
961 } 974 }
962 975
976 void TestRunnerBindings::DumpChildFramesAsMarkup() {
977 if (runner_)
978 runner_->DumpChildFramesAsMarkup();
979 }
980
963 void TestRunnerBindings::DumpIconChanges() { 981 void TestRunnerBindings::DumpIconChanges() {
964 if (runner_) 982 if (runner_)
965 runner_->DumpIconChanges(); 983 runner_->DumpIconChanges();
966 } 984 }
967 985
968 void TestRunnerBindings::SetAudioData(const gin::ArrayBufferView& view) { 986 void TestRunnerBindings::SetAudioData(const gin::ArrayBufferView& view) {
969 if (runner_) 987 if (runner_)
970 runner_->SetAudioData(view); 988 runner_->SetAudioData(view);
971 } 989 }
972 990
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
1239 1257
1240 void TestRunnerBindings::DisplayAsyncThen(v8::Handle<v8::Function> callback) { 1258 void TestRunnerBindings::DisplayAsyncThen(v8::Handle<v8::Function> callback) {
1241 if (runner_) 1259 if (runner_)
1242 runner_->DisplayAsyncThen(callback); 1260 runner_->DisplayAsyncThen(callback);
1243 } 1261 }
1244 1262
1245 void TestRunnerBindings::SetCustomTextOutput(std::string output) { 1263 void TestRunnerBindings::SetCustomTextOutput(std::string output) {
1246 runner_->setCustomTextOutput(output); 1264 runner_->setCustomTextOutput(output);
1247 } 1265 }
1248 1266
1267 void TestRunnerBindings::SetViewSourceForFrame(const std::string& name,
1268 bool enabled) {
1269 if (runner_ && runner_->web_view_) {
1270 WebFrame* target_frame =
1271 runner_->web_view_->findFrameByName(WebString::fromUTF8(name));
1272 if (target_frame)
1273 target_frame->enableViewSourceMode(enabled);
1274 }
1275 }
1276
1249 bool TestRunnerBindings::GlobalFlag() { 1277 bool TestRunnerBindings::GlobalFlag() {
1250 if (runner_) 1278 if (runner_)
1251 return runner_->global_flag_; 1279 return runner_->global_flag_;
1252 return false; 1280 return false;
1253 } 1281 }
1254 1282
1255 void TestRunnerBindings::SetGlobalFlag(bool value) { 1283 void TestRunnerBindings::SetGlobalFlag(bool value) {
1256 if (runner_) 1284 if (runner_)
1257 runner_->global_flag_ = value; 1285 runner_->global_flag_ = value;
1258 } 1286 }
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1447 delegate_->disableAutoResizeMode(WebSize()); 1475 delegate_->disableAutoResizeMode(WebSize());
1448 delegate_->deleteAllCookies(); 1476 delegate_->deleteAllCookies();
1449 delegate_->resetScreenOrientation(); 1477 delegate_->resetScreenOrientation();
1450 } 1478 }
1451 1479
1452 dump_editting_callbacks_ = false; 1480 dump_editting_callbacks_ = false;
1453 dump_as_text_ = false; 1481 dump_as_text_ = false;
1454 dump_as_markup_ = false; 1482 dump_as_markup_ = false;
1455 generate_pixel_results_ = true; 1483 generate_pixel_results_ = true;
1456 dump_child_frame_scroll_positions_ = false; 1484 dump_child_frame_scroll_positions_ = false;
1485 dump_child_frames_as_markup_ = false;
1457 dump_child_frames_as_text_ = false; 1486 dump_child_frames_as_text_ = false;
1458 dump_icon_changes_ = false; 1487 dump_icon_changes_ = false;
1459 dump_as_audio_ = false; 1488 dump_as_audio_ = false;
1460 dump_frame_load_callbacks_ = false; 1489 dump_frame_load_callbacks_ = false;
1461 dump_ping_loader_callbacks_ = false; 1490 dump_ping_loader_callbacks_ = false;
1462 dump_user_gesture_in_frame_load_callbacks_ = false; 1491 dump_user_gesture_in_frame_load_callbacks_ = false;
1463 dump_title_changes_ = false; 1492 dump_title_changes_ = false;
1464 dump_create_view_ = false; 1493 dump_create_view_ = false;
1465 can_open_windows_ = false; 1494 can_open_windows_ = false;
1466 dump_resource_load_callbacks_ = false; 1495 dump_resource_load_callbacks_ = false;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 } 1582 }
1554 1583
1555 void TestRunner::setShouldGeneratePixelResults(bool value) { 1584 void TestRunner::setShouldGeneratePixelResults(bool value) {
1556 generate_pixel_results_ = value; 1585 generate_pixel_results_ = value;
1557 } 1586 }
1558 1587
1559 bool TestRunner::shouldDumpChildFrameScrollPositions() const { 1588 bool TestRunner::shouldDumpChildFrameScrollPositions() const {
1560 return dump_child_frame_scroll_positions_; 1589 return dump_child_frame_scroll_positions_;
1561 } 1590 }
1562 1591
1592 bool TestRunner::shouldDumpChildFramesAsMarkup() const {
1593 return dump_child_frames_as_markup_;
1594 }
1595
1563 bool TestRunner::shouldDumpChildFramesAsText() const { 1596 bool TestRunner::shouldDumpChildFramesAsText() const {
1564 return dump_child_frames_as_text_; 1597 return dump_child_frames_as_text_;
1565 } 1598 }
1566 1599
1567 bool TestRunner::ShouldDumpAsAudio() const { 1600 bool TestRunner::ShouldDumpAsAudio() const {
1568 return dump_as_audio_; 1601 return dump_as_audio_;
1569 } 1602 }
1570 1603
1571 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const { 1604 void TestRunner::GetAudioData(std::vector<unsigned char>* buffer_view) const {
1572 *buffer_view = audio_data_; 1605 *buffer_view = audio_data_;
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 2371
2339 void TestRunner::SetPluginsEnabled(bool enabled) { 2372 void TestRunner::SetPluginsEnabled(bool enabled) {
2340 delegate_->preferences()->plugins_enabled = enabled; 2373 delegate_->preferences()->plugins_enabled = enabled;
2341 delegate_->applyPreferences(); 2374 delegate_->applyPreferences();
2342 } 2375 }
2343 2376
2344 void TestRunner::DumpEditingCallbacks() { 2377 void TestRunner::DumpEditingCallbacks() {
2345 dump_editting_callbacks_ = true; 2378 dump_editting_callbacks_ = true;
2346 } 2379 }
2347 2380
2381 void TestRunner::DumpAsMarkup() {
2382 dump_as_markup_ = true;
2383 generate_pixel_results_ = false;
2384 }
2385
2348 void TestRunner::DumpAsText() { 2386 void TestRunner::DumpAsText() {
2349 dump_as_text_ = true; 2387 dump_as_text_ = true;
2350 generate_pixel_results_ = false; 2388 generate_pixel_results_ = false;
2351 } 2389 }
2352 2390
2353 void TestRunner::DumpAsTextWithPixelResults() { 2391 void TestRunner::DumpAsTextWithPixelResults() {
2354 dump_as_text_ = true; 2392 dump_as_text_ = true;
2355 generate_pixel_results_ = true; 2393 generate_pixel_results_ = true;
2356 } 2394 }
2357 2395
2358 void TestRunner::DumpChildFrameScrollPositions() { 2396 void TestRunner::DumpChildFrameScrollPositions() {
2359 dump_child_frame_scroll_positions_ = true; 2397 dump_child_frame_scroll_positions_ = true;
2360 } 2398 }
2361 2399
2400 void TestRunner::DumpChildFramesAsMarkup() {
2401 dump_child_frames_as_markup_ = true;
2402 }
2403
2362 void TestRunner::DumpChildFramesAsText() { 2404 void TestRunner::DumpChildFramesAsText() {
2363 dump_child_frames_as_text_ = true; 2405 dump_child_frames_as_text_ = true;
2364 } 2406 }
2365 2407
2366 void TestRunner::DumpIconChanges() { 2408 void TestRunner::DumpIconChanges() {
2367 dump_icon_changes_ = true; 2409 dump_icon_changes_ = true;
2368 } 2410 }
2369 2411
2370 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) { 2412 void TestRunner::SetAudioData(const gin::ArrayBufferView& view) {
2371 unsigned char* bytes = static_cast<unsigned char*>(view.bytes()); 2413 unsigned char* bytes = static_cast<unsigned char*>(view.bytes());
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
2647 } 2689 }
2648 2690
2649 void TestRunner::DidLosePointerLockInternal() { 2691 void TestRunner::DidLosePointerLockInternal() {
2650 bool was_locked = pointer_locked_; 2692 bool was_locked = pointer_locked_;
2651 pointer_locked_ = false; 2693 pointer_locked_ = false;
2652 if (was_locked) 2694 if (was_locked)
2653 web_view_->didLosePointerLock(); 2695 web_view_->didLosePointerLock();
2654 } 2696 }
2655 2697
2656 } // namespace content 2698 } // namespace content
OLDNEW
« no previous file with comments | « content/shell/renderer/test_runner/test_runner.h ('k') | content/shell/renderer/test_runner/web_test_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698