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 @@ ...@@ -8,6 +8,7 @@
#include "base/files/scoped_temp_dir.h" #include "base/files/scoped_temp_dir.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/test/bind_test_util.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_service.h"
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
#include "components/sync/protocol/sync.pb.h" #include "components/sync/protocol/sync.pb.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/test/test_utils.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_dialog_auto_confirm.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
...@@ -229,19 +231,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, ...@@ -229,19 +231,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
// Install extension v1. // Install extension v1.
InstallIncreasingPermissionExtensionV1(); InstallIncreasingPermissionExtensionV1();
// Note: This interceptor gets requests on the IO thread. content::URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
net::LocalHostTestURLRequestInterceptor interceptor( [&](content::URLLoaderInterceptor::RequestParams* params) {
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), std::string path = params->url_request.url.path();
base::CreateTaskRunnerWithTraits( if (path == "/autoupdate/updates.xml") {
{base::MayBlock(), base::TaskPriority::BEST_EFFORT, content::URLLoaderInterceptor::WriteResponse(
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); test_data_dir_.AppendASCII("permissions_increase")
interceptor.SetResponseIgnoreQuery( .AppendASCII("updates.xml"),
GURL("http://localhost/autoupdate/updates.xml"), params->client.get());
test_data_dir_.AppendASCII("permissions_increase") return true;
.AppendASCII("updates.xml")); } else if (path == "/autoupdate/v2.crx") {
interceptor.SetResponseIgnoreQuery( content::URLLoaderInterceptor::WriteResponse(
GURL("http://localhost/autoupdate/v2.crx"), scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"),
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx")); params->client.get());
return true;
}
return false;
}));
sync_service->MergeDataAndStartSyncing( sync_service->MergeDataAndStartSyncing(
syncer::EXTENSIONS, syncer::SyncDataList(), syncer::EXTENSIONS, syncer::SyncDataList(),
...@@ -270,19 +276,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, ...@@ -270,19 +276,23 @@ IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest,
IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) { IN_PROC_BROWSER_TEST_F(ExtensionDisabledGlobalErrorTest, RemoteInstall) {
static const char extension_id[] = "pgdpcfcocojkjfbgpiianjngphoopgmo"; static const char extension_id[] = "pgdpcfcocojkjfbgpiianjngphoopgmo";
// Note: This interceptor gets requests on the IO thread. content::URLLoaderInterceptor interceptor(base::BindLambdaForTesting(
net::LocalHostTestURLRequestInterceptor interceptor( [&](content::URLLoaderInterceptor::RequestParams* params) {
BrowserThread::GetTaskRunnerForThread(BrowserThread::IO), std::string path = params->url_request.url.path();
base::CreateTaskRunnerWithTraits( if (path == "/autoupdate/updates.xml") {
{base::MayBlock(), base::TaskPriority::BEST_EFFORT, content::URLLoaderInterceptor::WriteResponse(
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})); test_data_dir_.AppendASCII("permissions_increase")
interceptor.SetResponseIgnoreQuery( .AppendASCII("updates.xml"),
GURL("http://localhost/autoupdate/updates.xml"), params->client.get());
test_data_dir_.AppendASCII("permissions_increase") return true;
.AppendASCII("updates.xml")); } else if (path == "/autoupdate/v2.crx") {
interceptor.SetResponseIgnoreQuery( content::URLLoaderInterceptor::WriteResponse(
GURL("http://localhost/autoupdate/v2.crx"), scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx"),
scoped_temp_dir_.GetPath().AppendASCII("permissions2.crx")); params->client.get());
return true;
}
return false;
}));
sync_pb::EntitySpecifics specifics; sync_pb::EntitySpecifics specifics;
specifics.mutable_extension()->set_id(extension_id); specifics.mutable_extension()->set_id(extension_id);
......
...@@ -6,8 +6,6 @@ ...@@ -6,8 +6,6 @@
# See https://crbug.com/769401 # See https://crbug.com/769401
# Uncategorized timeouts or test failures. # Uncategorized timeouts or test failures.
-ExtensionDisabledGlobalErrorTest.HigherPermissionsFromSync
-ExtensionDisabledGlobalErrorTest.RemoteInstall
-ExtensionUnloadBrowserTest.UnloadWithContentScripts -ExtensionUnloadBrowserTest.UnloadWithContentScripts
-ProxySettingsApiTest.ProxyEventsInvalidProxy -ProxySettingsApiTest.ProxyEventsInvalidProxy
-RegisterProtocolHandlerBrowserTest.CustomHandler -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