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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void SetBluetoothFakeAdapter(const std::string& adapter_name, | 203 void SetBluetoothFakeAdapter(const std::string& adapter_name, |
203 v8::Local<v8::Function> callback); | 204 v8::Local<v8::Function> callback); |
204 void SetBluetoothManualChooser(bool enable); | 205 void SetBluetoothManualChooser(bool enable); |
205 void SetCanOpenWindows(); | 206 void SetCanOpenWindows(); |
206 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); | 207 void SetCloseRemainingWindowsWhenComplete(gin::Arguments* args); |
207 void SetColorProfile(const std::string& name, | 208 void SetColorProfile(const std::string& name, |
208 v8::Local<v8::Function> callback); | 209 v8::Local<v8::Function> callback); |
209 void SetCustomPolicyDelegate(gin::Arguments* args); | 210 void SetCustomPolicyDelegate(gin::Arguments* args); |
210 void SetCustomTextOutput(const std::string& output); | 211 void SetCustomTextOutput(const std::string& output); |
211 void SetDatabaseQuota(int quota); | 212 void SetDatabaseQuota(int quota); |
| 213 void SetDisallowedSubresourcePathSuffixes( |
| 214 const std::vector<std::string>& suffixes); |
212 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, | 215 void SetDomainRelaxationForbiddenForURLScheme(bool forbidden, |
213 const std::string& scheme); | 216 const std::string& scheme); |
214 void SetDumpConsoleMessages(bool value); | 217 void SetDumpConsoleMessages(bool value); |
215 void SetImagesAllowed(bool allowed); | 218 void SetImagesAllowed(bool allowed); |
216 void SetIsolatedWorldContentSecurityPolicy(int world_id, | 219 void SetIsolatedWorldContentSecurityPolicy(int world_id, |
217 const std::string& policy); | 220 const std::string& policy); |
218 void SetIsolatedWorldSecurityOrigin(int world_id, | 221 void SetIsolatedWorldSecurityOrigin(int world_id, |
219 v8::Local<v8::Value> origin); | 222 v8::Local<v8::Value> origin); |
220 void SetJavaScriptCanAccessClipboard(bool can_access); | 223 void SetJavaScriptCanAccessClipboard(bool can_access); |
221 void SetMIDIAccessorResult(bool result); | 224 void SetMIDIAccessorResult(bool result); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) | 359 &TestRunnerBindings::CopyImageAtAndCapturePixelsAsyncThen) |
357 .SetMethod("didAcquirePointerLock", | 360 .SetMethod("didAcquirePointerLock", |
358 &TestRunnerBindings::DidAcquirePointerLock) | 361 &TestRunnerBindings::DidAcquirePointerLock) |
359 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) | 362 .SetMethod("didLosePointerLock", &TestRunnerBindings::DidLosePointerLock) |
360 .SetMethod("didNotAcquirePointerLock", | 363 .SetMethod("didNotAcquirePointerLock", |
361 &TestRunnerBindings::DidNotAcquirePointerLock) | 364 &TestRunnerBindings::DidNotAcquirePointerLock) |
362 .SetMethod("disableAutoResizeMode", | 365 .SetMethod("disableAutoResizeMode", |
363 &TestRunnerBindings::DisableAutoResizeMode) | 366 &TestRunnerBindings::DisableAutoResizeMode) |
364 .SetMethod("disableMockScreenOrientation", | 367 .SetMethod("disableMockScreenOrientation", |
365 &TestRunnerBindings::DisableMockScreenOrientation) | 368 &TestRunnerBindings::DisableMockScreenOrientation) |
| 369 .SetMethod("setDisallowedSubresourcePathSuffixes", |
| 370 &TestRunnerBindings::SetDisallowedSubresourcePathSuffixes) |
366 .SetMethod("dispatchBeforeInstallPromptEvent", | 371 .SetMethod("dispatchBeforeInstallPromptEvent", |
367 &TestRunnerBindings::DispatchBeforeInstallPromptEvent) | 372 &TestRunnerBindings::DispatchBeforeInstallPromptEvent) |
368 .SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup) | 373 .SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup) |
369 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) | 374 .SetMethod("dumpAsText", &TestRunnerBindings::DumpAsText) |
370 .SetMethod("dumpAsTextWithPixelResults", | 375 .SetMethod("dumpAsTextWithPixelResults", |
371 &TestRunnerBindings::DumpAsTextWithPixelResults) | 376 &TestRunnerBindings::DumpAsTextWithPixelResults) |
372 .SetMethod("dumpBackForwardList", | 377 .SetMethod("dumpBackForwardList", |
373 &TestRunnerBindings::DumpBackForwardList) | 378 &TestRunnerBindings::DumpBackForwardList) |
374 .SetMethod("dumpChildFrameScrollPositions", | 379 .SetMethod("dumpChildFrameScrollPositions", |
375 &TestRunnerBindings::DumpChildFrameScrollPositions) | 380 &TestRunnerBindings::DumpChildFrameScrollPositions) |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) | 468 .SetMethod("queueReload", &TestRunnerBindings::QueueReload) |
464 .SetMethod("removeOriginAccessWhitelistEntry", | 469 .SetMethod("removeOriginAccessWhitelistEntry", |
465 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) | 470 &TestRunnerBindings::RemoveOriginAccessWhitelistEntry) |
466 .SetMethod("removeWebPageOverlay", | 471 .SetMethod("removeWebPageOverlay", |
467 &TestRunnerBindings::RemoveWebPageOverlay) | 472 &TestRunnerBindings::RemoveWebPageOverlay) |
468 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) | 473 .SetMethod("resetDeviceLight", &TestRunnerBindings::ResetDeviceLight) |
469 .SetMethod("resetTestHelperControllers", | 474 .SetMethod("resetTestHelperControllers", |
470 &TestRunnerBindings::ResetTestHelperControllers) | 475 &TestRunnerBindings::ResetTestHelperControllers) |
471 .SetMethod("resolveBeforeInstallPromptPromise", | 476 .SetMethod("resolveBeforeInstallPromptPromise", |
472 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) | 477 &TestRunnerBindings::ResolveBeforeInstallPromptPromise) |
473 .SetMethod("runIdleTasks", | 478 .SetMethod("runIdleTasks", &TestRunnerBindings::RunIdleTasks) |
474 &TestRunnerBindings::RunIdleTasks) | |
475 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) | 479 .SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup) |
476 | 480 |
477 // The Bluetooth functions are specified at | 481 // The Bluetooth functions are specified at |
478 // https://webbluetoothcg.github.io/web-bluetooth/tests/. | 482 // https://webbluetoothcg.github.io/web-bluetooth/tests/. |
479 .SetMethod("sendBluetoothManualChooserEvent", | 483 .SetMethod("sendBluetoothManualChooserEvent", |
480 &TestRunnerBindings::SendBluetoothManualChooserEvent) | 484 &TestRunnerBindings::SendBluetoothManualChooserEvent) |
481 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages) | 485 .SetMethod("setAcceptLanguages", &TestRunnerBindings::SetAcceptLanguages) |
482 .SetMethod("setAllowDisplayOfInsecureContent", | 486 .SetMethod("setAllowDisplayOfInsecureContent", |
483 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) | 487 &TestRunnerBindings::SetAllowDisplayOfInsecureContent) |
484 .SetMethod("setAllowFileAccessFromFileURLs", | 488 .SetMethod("setAllowFileAccessFromFileURLs", |
485 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) | 489 &TestRunnerBindings::SetAllowFileAccessFromFileURLs) |
486 .SetMethod("setAllowRunningOfInsecureContent", | 490 .SetMethod("setAllowRunningOfInsecureContent", |
487 &TestRunnerBindings::SetAllowRunningOfInsecureContent) | 491 &TestRunnerBindings::SetAllowRunningOfInsecureContent) |
488 .SetMethod("setAutoplayAllowed", | 492 .SetMethod("setAutoplayAllowed", &TestRunnerBindings::SetAutoplayAllowed) |
489 &TestRunnerBindings::SetAutoplayAllowed) | |
490 .SetMethod("setAllowUniversalAccessFromFileURLs", | 493 .SetMethod("setAllowUniversalAccessFromFileURLs", |
491 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) | 494 &TestRunnerBindings::SetAllowUniversalAccessFromFileURLs) |
492 .SetMethod("setAlwaysAcceptCookies", | 495 .SetMethod("setAlwaysAcceptCookies", |
493 &TestRunnerBindings::SetAlwaysAcceptCookies) | 496 &TestRunnerBindings::SetAlwaysAcceptCookies) |
494 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) | 497 .SetMethod("setAudioData", &TestRunnerBindings::SetAudioData) |
495 .SetMethod("setBackingScaleFactor", | 498 .SetMethod("setBackingScaleFactor", |
496 &TestRunnerBindings::SetBackingScaleFactor) | 499 &TestRunnerBindings::SetBackingScaleFactor) |
497 // The Bluetooth functions are specified at | 500 // The Bluetooth functions are specified at |
498 // https://webbluetoothcg.github.io/web-bluetooth/tests/. | 501 // https://webbluetoothcg.github.io/web-bluetooth/tests/. |
499 .SetMethod("setBluetoothFakeAdapter", | 502 .SetMethod("setBluetoothFakeAdapter", |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 return; | 933 return; |
931 | 934 |
932 runner_->SetMockScreenOrientation(orientation); | 935 runner_->SetMockScreenOrientation(orientation); |
933 } | 936 } |
934 | 937 |
935 void TestRunnerBindings::DisableMockScreenOrientation() { | 938 void TestRunnerBindings::DisableMockScreenOrientation() { |
936 if (runner_) | 939 if (runner_) |
937 runner_->DisableMockScreenOrientation(); | 940 runner_->DisableMockScreenOrientation(); |
938 } | 941 } |
939 | 942 |
| 943 void TestRunnerBindings::SetDisallowedSubresourcePathSuffixes( |
| 944 const std::vector<std::string>& suffixes) { |
| 945 if (runner_) |
| 946 runner_->SetDisallowedSubresourcePathSuffixes(suffixes); |
| 947 } |
| 948 |
940 void TestRunnerBindings::DidAcquirePointerLock() { | 949 void TestRunnerBindings::DidAcquirePointerLock() { |
941 if (view_runner_) | 950 if (view_runner_) |
942 view_runner_->DidAcquirePointerLock(); | 951 view_runner_->DidAcquirePointerLock(); |
943 } | 952 } |
944 | 953 |
945 void TestRunnerBindings::DidNotAcquirePointerLock() { | 954 void TestRunnerBindings::DidNotAcquirePointerLock() { |
946 if (view_runner_) | 955 if (view_runner_) |
947 view_runner_->DidNotAcquirePointerLock(); | 956 view_runner_->DidNotAcquirePointerLock(); |
948 } | 957 } |
949 | 958 |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 layout_test_runtime_flags_.set_autoplay_allowed(allowed); | 2489 layout_test_runtime_flags_.set_autoplay_allowed(allowed); |
2481 OnLayoutTestRuntimeFlagsChanged(); | 2490 OnLayoutTestRuntimeFlagsChanged(); |
2482 } | 2491 } |
2483 | 2492 |
2484 void TestRunner::DumpPermissionClientCallbacks() { | 2493 void TestRunner::DumpPermissionClientCallbacks() { |
2485 layout_test_runtime_flags_.set_dump_web_content_settings_client_callbacks( | 2494 layout_test_runtime_flags_.set_dump_web_content_settings_client_callbacks( |
2486 true); | 2495 true); |
2487 OnLayoutTestRuntimeFlagsChanged(); | 2496 OnLayoutTestRuntimeFlagsChanged(); |
2488 } | 2497 } |
2489 | 2498 |
| 2499 void TestRunner::SetDisallowedSubresourcePathSuffixes( |
| 2500 const std::vector<std::string>& suffixes) { |
| 2501 DCHECK(main_view_); |
| 2502 main_view_->mainFrame()->dataSource()->setSubresourceFilter( |
| 2503 new MockWebDocumentSubresourceFilter(suffixes)); |
| 2504 } |
| 2505 |
2490 void TestRunner::DumpWindowStatusChanges() { | 2506 void TestRunner::DumpWindowStatusChanges() { |
2491 layout_test_runtime_flags_.set_dump_window_status_changes(true); | 2507 layout_test_runtime_flags_.set_dump_window_status_changes(true); |
2492 OnLayoutTestRuntimeFlagsChanged(); | 2508 OnLayoutTestRuntimeFlagsChanged(); |
2493 } | 2509 } |
2494 | 2510 |
2495 void TestRunner::DumpSpellCheckCallbacks() { | 2511 void TestRunner::DumpSpellCheckCallbacks() { |
2496 layout_test_runtime_flags_.set_dump_spell_check_callbacks(true); | 2512 layout_test_runtime_flags_.set_dump_spell_check_callbacks(true); |
2497 OnLayoutTestRuntimeFlagsChanged(); | 2513 OnLayoutTestRuntimeFlagsChanged(); |
2498 } | 2514 } |
2499 | 2515 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2720 | 2736 |
2721 void TestRunner::NotifyDone() { | 2737 void TestRunner::NotifyDone() { |
2722 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && | 2738 if (layout_test_runtime_flags_.wait_until_done() && !topLoadingFrame() && |
2723 work_queue_.is_empty()) | 2739 work_queue_.is_empty()) |
2724 delegate_->TestFinished(); | 2740 delegate_->TestFinished(); |
2725 layout_test_runtime_flags_.set_wait_until_done(false); | 2741 layout_test_runtime_flags_.set_wait_until_done(false); |
2726 OnLayoutTestRuntimeFlagsChanged(); | 2742 OnLayoutTestRuntimeFlagsChanged(); |
2727 } | 2743 } |
2728 | 2744 |
2729 } // namespace test_runner | 2745 } // namespace test_runner |
OLD | NEW |