OLD | NEW |
---|---|
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 "components/test_runner/test_runner.h" | 5 #include "components/test_runner/test_runner.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
17 #include "components/test_runner/app_banner_client.h" | 17 #include "components/test_runner/app_banner_client.h" |
18 #include "components/test_runner/layout_and_paint_async_then.h" | 18 #include "components/test_runner/layout_and_paint_async_then.h" |
19 #include "components/test_runner/layout_dump.h" | 19 #include "components/test_runner/layout_dump.h" |
20 #include "components/test_runner/mock_content_settings_client.h" | 20 #include "components/test_runner/mock_content_settings_client.h" |
21 #include "components/test_runner/mock_credential_manager_client.h" | 21 #include "components/test_runner/mock_credential_manager_client.h" |
22 #include "components/test_runner/mock_screen_orientation_client.h" | 22 #include "components/test_runner/mock_screen_orientation_client.h" |
23 #include "components/test_runner/mock_web_document_subresource_filter.h" | |
23 #include "components/test_runner/mock_web_speech_recognizer.h" | 24 #include "components/test_runner/mock_web_speech_recognizer.h" |
24 #include "components/test_runner/mock_web_user_media_client.h" | 25 #include "components/test_runner/mock_web_user_media_client.h" |
25 #include "components/test_runner/pixel_dump.h" | 26 #include "components/test_runner/pixel_dump.h" |
26 #include "components/test_runner/spell_check_client.h" | 27 #include "components/test_runner/spell_check_client.h" |
27 #include "components/test_runner/test_common.h" | 28 #include "components/test_runner/test_common.h" |
28 #include "components/test_runner/test_interfaces.h" | 29 #include "components/test_runner/test_interfaces.h" |
29 #include "components/test_runner/test_preferences.h" | 30 #include "components/test_runner/test_preferences.h" |
30 #include "components/test_runner/test_runner_for_specific_view.h" | 31 #include "components/test_runner/test_runner_for_specific_view.h" |
31 #include "components/test_runner/web_task.h" | 32 #include "components/test_runner/web_task.h" |
32 #include "components/test_runner/web_test_delegate.h" | 33 #include "components/test_runner/web_test_delegate.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 void SetBluetoothFakeAdapter(const std::string& adapter_name, | 204 void SetBluetoothFakeAdapter(const std::string& adapter_name, |
204 v8::Local<v8::Function> callback); | 205 v8::Local<v8::Function> callback); |
205 void SetBluetoothManualChooser(bool enable); | 206 void SetBluetoothManualChooser(bool enable); |
206 void SetCanOpenWindows(); | 207 void SetCanOpenWindows(); |
207 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); | 208 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); |
208 void SetColorProfile(const std::string& name, | 209 void SetColorProfile(const std::string& name, |
209 v8::Local<v8::Function> callback); | 210 v8::Local<v8::Function> callback); |
210 void SetCustomPolicyDelegate(gin::Arguments* args); | 211 void SetCustomPolicyDelegate(gin::Arguments* args); |
211 void SetCustomTextOutput(const std::string& output); | 212 void SetCustomTextOutput(const std::string& output); |
212 void SetDatabaseQuota(int quota); | 213 void SetDatabaseQuota(int quota); |
214 void SetDisallowedSubresourcePathSuffixes( | |
215 const std::vector<std::string>& suffixes); | |
213 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | 216 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
214 const std::string& scheme); | 217 const std::string& scheme); |
215 void SetGeofencingMockPosition(double latitude, double longitude); | 218 void SetGeofencingMockPosition(double latitude, double longitude); |
216 void SetGeofencingMockProvider(bool service_available); | 219 void SetGeofencingMockProvider(bool service_available); |
217 void SetImagesAllowed(bool allowed); | 220 void SetImagesAllowed(bool allowed); |
218 void SetInterceptPostMessage(bool value); | 221 void SetInterceptPostMessage(bool value); |
219 void SetIsolatedWorldContentSecurityPolicy(int world_id, | 222 void SetIsolatedWorldContentSecurityPolicy(int world_id, |
220 const std::string& policy); | 223 const std::string& policy); |
221 void SetIsolatedWorldSecurityOrigin(int world_id, | 224 void SetIsolatedWorldSecurityOrigin(int world_id, |
222 v8::Local<v8::Value> origin); | 225 v8::Local<v8::Value> origin); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) | 366 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) |
364 .SetMethod("didAcquirePointerLock", | 367 .SetMethod("didAcquirePointerLock", |
365 &TestRunnerBindings::DidAcquirePointerLock) | 368 &TestRunnerBindings::DidAcquirePointerLock) |
366 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) | 369 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
367 .SetMethod("didNotAcquirePointerLock", | 370 .SetMethod("didNotAcquirePointerLock", |
368 &TestRunnerBindings::DidNotAcquirePointerLock) | 371 &TestRunnerBindings::DidNotAcquirePointerLock) |
369 .SetMethod("disableAutoResizeMode", | 372 .SetMethod("disableAutoResizeMode", |
370 &TestRunnerBindings::DisableAutoResizeMode) | 373 &TestRunnerBindings::DisableAutoResizeMode) |
371 .SetMethod("disableMockScreenOrientation", | 374 .SetMethod("disableMockScreenOrientation", |
372 &TestRunnerBindings::DisableMockScreenOrientation) | 375 &TestRunnerBindings::DisableMockScreenOrientation) |
376 .SetMethod("setDisallowedSubresourcePathSuffixes", | |
377 &TestRunnerBindings::SetDisallowedSubresourcePathSuffixes) | |
373 .SetMethod("dispatchBeforeInstallPromptEvent", | 378 .SetMethod("dispatchBeforeInstallPromptEvent", |
374 &TestRunnerBindings::DispatchBeforeInstallPromptEvent) | 379 &TestRunnerBindings::DispatchBeforeInstallPromptEvent) |
375 .SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup) | 380 .SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup) |
376 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) | 381 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) |
377 .SetMethod("dumpAsTextWithPixelResults", | 382 .SetMethod("dumpAsTextWithPixelResults", |
378 &TestRunnerBindings::DumpAsTextWithPixelResults) | 383 &TestRunnerBindings::DumpAsTextWithPixelResults) |
379 .SetMethod("dumpBackForwardList", | 384 .SetMethod("dumpBackForwardList", |
380 &TestRunnerBindings::DumpBackForwardList) | 385 &TestRunnerBindings::DumpBackForwardList) |
381 .SetMethod("dumpChildFrameScrollPositions", | 386 .SetMethod("dumpChildFrameScrollPositions", |
382 &TestRunnerBindings::DumpChildFrameScrollPositions) | 387 &TestRunnerBindings::DumpChildFrameScrollPositions) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
473 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) | 478 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) |
474 .SetMethod("removeOriginAccessWhitelistEntry", | 479 .SetMethod("removeOriginAccessWhitelistEntry", |
475 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) | 480 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) |
476 .SetMethod("removeWebPageOverlay", | 481 .SetMethod("removeWebPageOverlay", |
477 &TestRunnerBindings::RemoveWebPageOverlay) | 482 &TestRunnerBindings::RemoveWebPageOverlay) |
478 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) | 483 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) |
479 .SetMethod("resetTestHelperControllers", | 484 .SetMethod("resetTestHelperControllers", |
480 &TestRunnerBindings::ResetTestHelperControllers) | 485 &TestRunnerBindings::ResetTestHelperControllers) |
481 .SetMethod("resolveBeforeInstallPromptPromise", | 486 .SetMethod("resolveBeforeInstallPromptPromise", |
482 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) | 487 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) |
483 .SetMethod("runIdleTasks", | 488 .SetMethod("runIdleTasks", &TestRunnerBindings::RunIdleTasks) |
484 &TestRunnerBindings::RunIdleTasks) | |
485 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) | 489 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) |
486 | 490 |
487 // The Bluetooth functions are specified at | 491 // The Bluetooth functions are specified at |
488 // https://webbluetoothcg.github.io/web-bluetooth/tests/. | 492 // https://webbluetoothcg.github.io/web-bluetooth/tests/. |
489 .SetMethod("sendBluetoothManualChooserEvent", | 493 .SetMethod("sendBluetoothManualChooserEvent", |
490 &TestRunnerBindings::SendBluetoothManualChooserEvent) | 494 &TestRunnerBindings::SendBluetoothManualChooserEvent) |
491 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages) | 495 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages) |
492 .SetMethod("setAllowDisplayOfInsecureContent", | 496 .SetMethod("setAllowDisplayOfInsecureContent", |
493 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) | 497 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) |
494 .SetMethod("setAllowFileAccessFromFileURLs", | 498 .SetMethod("setAllowFileAccessFromFileURLs", |
495 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) | 499 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) |
496 .SetMethod("setAllowRunningOfInsecureContent", | 500 .SetMethod("setAllowRunningOfInsecureContent", |
497 &TestRunnerBindings::SetAllowRunningOfInsecureContent) | 501 &TestRunnerBindings::SetAllowRunningOfInsecureContent) |
498 .SetMethod("setAutoplayAllowed", | 502 .SetMethod("setAutoplayAllowed", &TestRunnerBindings::SetAutoplayAllowed) |
499 &TestRunnerBindings::SetAutoplayAllowed) | |
500 .SetMethod("setAllowUniversalAccessFromFileURLs", | 503 .SetMethod("setAllowUniversalAccessFromFileURLs", |
501 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) | 504 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) |
502 .SetMethod("setAlwaysAcceptCookies", | 505 .SetMethod("setAlwaysAcceptCookies", |
503 &TestRunnerBindings::SetAlwaysAcceptCookies) | 506 &TestRunnerBindings::SetAlwaysAcceptCookies) |
504 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) | 507 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) |
505 .SetMethod("setBackingScaleFactor", | 508 .SetMethod("setBackingScaleFactor", |
506 &TestRunnerBindings::SetBackingScaleFactor) | 509 &TestRunnerBindings::SetBackingScaleFactor) |
507 // The Bluetooth functions are specified at | 510 // The Bluetooth functions are specified at |
508 // https://webbluetoothcg.github.io/web-bluetooth/tests/. | 511 // https://webbluetoothcg.github.io/web-bluetooth/tests/. |
509 .SetMethod("setBluetoothFakeAdapter", | 512 .SetMethod("setBluetoothFakeAdapter", |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
938 return; | 941 return; |
939 | 942 |
940 runner_->SetMockScreenOrientation(orientation); | 943 runner_->SetMockScreenOrientation(orientation); |
941 } | 944 } |
942 | 945 |
943 void TestRunnerBindings::DisableMockScreenOrientation() { | 946 void TestRunnerBindings::DisableMockScreenOrientation() { |
944 if (runner_) | 947 if (runner_) |
945 runner_->DisableMockScreenOrientation(); | 948 runner_->DisableMockScreenOrientation(); |
946 } | 949 } |
947 | 950 |
951 void TestRunnerBindings::SetDisallowedSubresourcePathSuffixes( | |
952 const std::vector<std::string>& suffixes) { | |
953 if (runner_) | |
954 runner_->SetDisallowedSubresourcePathSuffixes(suffixes); | |
955 } | |
956 | |
948 void TestRunnerBindings::DidAcquirePointerLock() { | 957 void TestRunnerBindings::DidAcquirePointerLock() { |
949 if (view_runner_) | 958 if (view_runner_) |
950 view_runner_->DidAcquirePointerLock(); | 959 view_runner_->DidAcquirePointerLock(); |
951 } | 960 } |
952 | 961 |
953 void TestRunnerBindings::DidNotAcquirePointerLock() { | 962 void TestRunnerBindings::DidNotAcquirePointerLock() { |
954 if (view_runner_) | 963 if (view_runner_) |
955 view_runner_->DidNotAcquirePointerLock(); | 964 view_runner_->DidNotAcquirePointerLock(); |
956 } | 965 } |
957 | 966 |
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2537 layout_test_runtime_flags_.set_autoplay_allowed(allowed); | 2546 layout_test_runtime_flags_.set_autoplay_allowed(allowed); |
2538 OnLayoutTestRuntimeFlagsChanged(); | 2547 OnLayoutTestRuntimeFlagsChanged(); |
2539 } | 2548 } |
2540 | 2549 |
2541 void TestRunner::DumpPermissionClientCallbacks() { | 2550 void TestRunner::DumpPermissionClientCallbacks() { |
2542 layout_test_runtime_flags_.set_dump_web_content_settings_client_callbacks( | 2551 layout_test_runtime_flags_.set_dump_web_content_settings_client_callbacks( |
2543 true); | 2552 true); |
2544 OnLayoutTestRuntimeFlagsChanged(); | 2553 OnLayoutTestRuntimeFlagsChanged(); |
2545 } | 2554 } |
2546 | 2555 |
2556 void TestRunner::SetDisallowedSubresourcePathSuffixes( | |
2557 const std::vector<std::string>& suffixes) { | |
2558 DCHECK(main_view_); | |
2559 WebDataSource* data_source = main_view_->mainFrame()->dataSource(); | |
2560 data_source->setSubresourceFilter( | |
Mike West
2016/06/01 13:43:17
Nit: You don't really need |data_source| here.
engedy
2016/06/02 23:07:19
Done.
| |
2561 new MockWebDocumentSubresourceFilter(suffixes)); | |
2562 } | |
2563 | |
2547 void TestRunner::DumpWindowStatusChanges() { | 2564 void TestRunner::DumpWindowStatusChanges() { |
2548 dump_window_status_changes_ = true; | 2565 dump_window_status_changes_ = true; |
2549 } | 2566 } |
2550 | 2567 |
2551 void TestRunner::DumpSpellCheckCallbacks() { | 2568 void TestRunner::DumpSpellCheckCallbacks() { |
2552 dump_spell_check_callbacks_ = true; | 2569 dump_spell_check_callbacks_ = true; |
2553 } | 2570 } |
2554 | 2571 |
2555 void TestRunner::DumpBackForwardList() { | 2572 void TestRunner::DumpBackForwardList() { |
2556 dump_back_forward_list_ = true; | 2573 dump_back_forward_list_ = true; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2778 | 2795 |
2779 void TestRunner::CompleteNotifyDone() { | 2796 void TestRunner::CompleteNotifyDone() { |
2780 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2797 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
2781 work_queue_.is_empty()) | 2798 work_queue_.is_empty()) |
2782 delegate_->TestFinished(); | 2799 delegate_->TestFinished(); |
2783 layout_test_runtime_flags_.set_wait_until_done(false); | 2800 layout_test_runtime_flags_.set_wait_until_done(false); |
2784 OnLayoutTestRuntimeFlagsChanged(); | 2801 OnLayoutTestRuntimeFlagsChanged(); |
2785 } | 2802 } |
2786 | 2803 |
2787 } // namespace test_runner | 2804 } // namespace test_runner |
OLD | NEW |