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

Unified Diff: components/test_runner/test_runner.cc

Issue 2022783002: Skeleton of the Safe Browsing Subresource Filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/test_runner/test_runner.cc
diff --git a/components/test_runner/test_runner.cc b/components/test_runner/test_runner.cc
index 72cbe6df6a8b433745921be0ef16ee682393abb5..ed1bbb98919ebfd737438335baea5e7f3258834c 100644
--- a/components/test_runner/test_runner.cc
+++ b/components/test_runner/test_runner.cc
@@ -20,6 +20,7 @@
#include "components/test_runner/mock_content_settings_client.h"
#include "components/test_runner/mock_credential_manager_client.h"
#include "components/test_runner/mock_screen_orientation_client.h"
+#include "components/test_runner/mock_web_document_subresource_filter.h"
#include "components/test_runner/mock_web_speech_recognizer.h"
#include "components/test_runner/mock_web_user_media_client.h"
#include "components/test_runner/pixel_dump.h"
@@ -210,6 +211,8 @@ class TestRunnerBindings : public gin::Wrappable<TestRunnerBindings> {
void SetCustomPolicyDelegate(gin::Arguments* args);
void SetCustomTextOutput(const std::string& output);
void SetDatabaseQuota(int quota);
+ void SetDisallowedSubresourcePathSuffixes(
+ const std::vector<std::string>& suffixes);
void SetDomainRelaxationForbiddenForURLScheme(bool forbidden,
const std::string& scheme);
void SetGeofencingMockPosition(double latitude, double longitude);
@@ -370,6 +373,8 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::DisableAutoResizeMode)
.SetMethod("disableMockScreenOrientation",
&TestRunnerBindings::DisableMockScreenOrientation)
+ .SetMethod("setDisallowedSubresourcePathSuffixes",
+ &TestRunnerBindings::SetDisallowedSubresourcePathSuffixes)
.SetMethod("dispatchBeforeInstallPromptEvent",
&TestRunnerBindings::DispatchBeforeInstallPromptEvent)
.SetMethod("dumpAsMarkup", &TestRunnerBindings::DumpAsMarkup)
@@ -480,8 +485,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::ResetTestHelperControllers)
.SetMethod("resolveBeforeInstallPromptPromise",
&TestRunnerBindings::ResolveBeforeInstallPromptPromise)
- .SetMethod("runIdleTasks",
- &TestRunnerBindings::RunIdleTasks)
+ .SetMethod("runIdleTasks", &TestRunnerBindings::RunIdleTasks)
.SetMethod("selectionAsMarkup", &TestRunnerBindings::SelectionAsMarkup)
// The Bluetooth functions are specified at
@@ -495,8 +499,7 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::SetAllowFileAccessFromFileURLs)
.SetMethod("setAllowRunningOfInsecureContent",
&TestRunnerBindings::SetAllowRunningOfInsecureContent)
- .SetMethod("setAutoplayAllowed",
- &TestRunnerBindings::SetAutoplayAllowed)
+ .SetMethod("setAutoplayAllowed", &TestRunnerBindings::SetAutoplayAllowed)
.SetMethod("setAllowUniversalAccessFromFileURLs",
&TestRunnerBindings::SetAllowUniversalAccessFromFileURLs)
.SetMethod("setAlwaysAcceptCookies",
@@ -945,6 +948,12 @@ void TestRunnerBindings::DisableMockScreenOrientation() {
runner_->DisableMockScreenOrientation();
}
+void TestRunnerBindings::SetDisallowedSubresourcePathSuffixes(
+ const std::vector<std::string>& suffixes) {
+ if (runner_)
+ runner_->SetDisallowedSubresourcePathSuffixes(suffixes);
+}
+
void TestRunnerBindings::DidAcquirePointerLock() {
if (view_runner_)
view_runner_->DidAcquirePointerLock();
@@ -2544,6 +2553,14 @@ void TestRunner::DumpPermissionClientCallbacks() {
OnLayoutTestRuntimeFlagsChanged();
}
+void TestRunner::SetDisallowedSubresourcePathSuffixes(
+ const std::vector<std::string>& suffixes) {
+ DCHECK(main_view_);
+ WebDataSource* data_source = main_view_->mainFrame()->dataSource();
+ data_source->setSubresourceFilter(
+ new MockWebDocumentSubresourceFilter(suffixes));
+}
+
void TestRunner::DumpWindowStatusChanges() {
dump_window_status_changes_ = true;
}

Powered by Google App Engine
This is Rietveld 408576698