Commit f1897a16 authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Fix broken ExtensionDisabledGlobalErrorTest.* with network service

These were using a URLRequestInterceptor, which doesn't work with the
network service. Switched to using content::URLLoaderInterceptor.

Bug: 769401
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: I5032eaccac335a060d0d3dedd83d8d723c471d34
Reviewed-on: https://chromium-review.googlesource.com/1173012Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583038}
parent 7f358b83
......@@ -8,6 +8,7 @@
#include "base/files/scoped_temp_dir.h"
#include "base/memory/ptr_util.h"
#include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h"
......@@ -29,6 +30,7 @@
#include "components/sync/protocol/sync.pb.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "extensions/browser/extension_dialog_auto_confirm.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
......@@ -229,19 +231,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
// Install extension v1.
InstallIncreasingPermissionExtensionV1();
// Note: This interceptor gets requests on the IO thread.
net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
base::CreateTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}));
interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/updates.xml"),
content::URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
[&](content::URLLoaderInterceptor::RequestParams* params) {
std::string path = params->url_request.url.path();
if (path == "/autoupdate/updates.xml") {
content::URLLoaderInterceptor::WriteResponse(
test_data_dir_.AppendASCII("permissions_increase")
.AppendASCII("updates.xml"));
interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/v2.crx"),
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"));
.AppendASCII("updates.xml"),
params->client.get());
return true;
} else if (path == "/autoupdate/v2.crx") {
content::URLLoaderInterceptor::WriteResponse(
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"),
params->client.get());
return true;
}
return false;
}));
sync_service->MergeDataAndStartSyncing(
syncer::EXTENSIONS, syncer::SyncDataList(),
......@@ -270,19 +276,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) {
static const char extension_id[] = "pgdpcfcocojkjfbgpiianjngphoopgmo";
// Note: This interceptor gets requests on the IO thread.
net::LocalHostTestURLRequestInterceptor interceptor(
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO),
base::CreateTaskRunnerWithTraits(
{base::MayBlock(), base::TaskPriority::BEST_EFFORT,
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}));
interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/updates.xml"),
content::URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
[&](content::URLLoaderInterceptor::RequestParams* params) {
std::string path = params->url_request.url.path();
if (path == "/autoupdate/updates.xml") {
content::URLLoaderInterceptor::WriteResponse(
test_data_dir_.AppendASCII("permissions_increase")
.AppendASCII("updates.xml"));
interceptor.SetResponseIgnoreQuery(
GURL("http://localhost/autoupdate/v2.crx"),
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"));
.AppendASCII("updates.xml"),
params->client.get());
return true;
} else if (path == "/autoupdate/v2.crx") {
content::URLLoaderInterceptor::WriteResponse(
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"),
params->client.get());
return true;
}
return false;
}));
sync_pb::EntitySpecifics specifics;
specifics.mutable_extension()->set_id(extension_id);
......
......@@ -6,8 +6,6 @@
# See https://crbug.com/769401
# Uncategorized timeouts or test failures.
-ExtensionDisabledGlobalErrorTest.HigherPermissionsFromSync
-ExtensionDisabledGlobalErrorTest.RemoteInstall
-ExtensionUnloadBrowserTest.UnloadWithContentScripts
-ProxySettingsApiTest.ProxyEventsInvalidProxy
-RegisterProtocolHandlerBrowserTest.CustomHandler
......
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