Commit 4dffa36f authored by danakj's avatar danakj Committed by Commit Bot

Make testRunner.setDisallowedSubresourcePathSuffixes work in any frame.

Currently it can only be called from the main frame, but it just wants
to set something on the frame's document loader.

R=avi@chromium.org

Bug: 1069111
Change-Id: I635fe2c0a23a9af1ae2842a477507218518d286f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2292998
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#787382}
parent 72c8e81f
...@@ -528,6 +528,13 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder( ...@@ -528,6 +528,13 @@ gin::ObjectTemplateBuilder TestRunnerBindings::GetObjectTemplateBuilder(
&TestRunnerBindings::DisableAutoResizeMode) &TestRunnerBindings::DisableAutoResizeMode)
.SetMethod("disableMockScreenOrientation", .SetMethod("disableMockScreenOrientation",
&TestRunnerBindings::DisableMockScreenOrientation) &TestRunnerBindings::DisableMockScreenOrientation)
// Sets up a mock DocumentSubresourceFilter to disallow subsequent
// subresource loads within the current document with the given path
// |suffixes|. The filter is created and injected even if |suffixes| is
// empty. If |suffixes| contains the empty string, all subresource loads
// will be disallowed. If |block_subresources| is false, matching
// resources will not be blocked but instead marked as matching a
// disallowed resource.
.SetMethod("setDisallowedSubresourcePathSuffixes", .SetMethod("setDisallowedSubresourcePathSuffixes",
&TestRunnerBindings::SetDisallowedSubresourcePathSuffixes) &TestRunnerBindings::SetDisallowedSubresourcePathSuffixes)
// Causes the beforeinstallprompt event to be sent to the renderer. // Causes the beforeinstallprompt event to be sent to the renderer.
...@@ -1268,7 +1275,8 @@ void TestRunnerBindings::SetDisallowedSubresourcePathSuffixes( ...@@ -1268,7 +1275,8 @@ void TestRunnerBindings::SetDisallowedSubresourcePathSuffixes(
bool block_subresources) { bool block_subresources) {
if (invalid_) if (invalid_)
return; return;
runner_->SetDisallowedSubresourcePathSuffixes(suffixes, block_subresources); GetWebFrame()->GetDocumentLoader()->SetSubresourceFilter(
new MockWebDocumentSubresourceFilter(suffixes, block_subresources));
} }
void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) { void TestRunnerBindings::SetPopupBlockingEnabled(bool block_popups) {
...@@ -2961,18 +2969,6 @@ void TestRunner::DumpPermissionClientCallbacks() { ...@@ -2961,18 +2969,6 @@ void TestRunner::DumpPermissionClientCallbacks() {
OnWebTestRuntimeFlagsChanged(); OnWebTestRuntimeFlagsChanged();
} }
void TestRunner::SetDisallowedSubresourcePathSuffixes(
const std::vector<std::string>& suffixes,
bool block_subresources) {
WebFrameTestProxy* main_frame = FindInProcessMainWindowMainFrame();
// TODO(danakj): This may only be used in tests from same renderer process
// (aka from the same site under site-isolation) as the test's main frame.
if (!main_frame)
return;
main_frame->GetWebFrame()->GetDocumentLoader()->SetSubresourceFilter(
new MockWebDocumentSubresourceFilter(suffixes, block_subresources));
}
void TestRunner::DumpBackForwardList() { void TestRunner::DumpBackForwardList() {
dump_back_forward_list_ = true; dump_back_forward_list_ = true;
} }
......
...@@ -447,16 +447,6 @@ class TestRunner { ...@@ -447,16 +447,6 @@ class TestRunner {
void SetAllowRunningOfInsecureContent(bool allowed); void SetAllowRunningOfInsecureContent(bool allowed);
void DumpPermissionClientCallbacks(); void DumpPermissionClientCallbacks();
// Sets up a mock DocumentSubresourceFilter to disallow subsequent subresource
// loads within the current document with the given path |suffixes|. The
// filter is created and injected even if |suffixes| is empty. If |suffixes|
// contains the empty string, all subresource loads will be disallowed. If
// |block_subresources| is false, matching resources will not be blocked but
// instead marked as matching a disallowed resource.
void SetDisallowedSubresourcePathSuffixes(
const std::vector<std::string>& suffixes,
bool block_subresources);
// This function sets a flag that tells the test runner to print out a text // This function sets a flag that tells the test runner to print out a text
// representation of the back/forward list. It ignores all arguments. // representation of the back/forward list. It ignores all arguments.
void DumpBackForwardList(); void DumpBackForwardList();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment