diff --git a/DEPS b/DEPS index febb099..b43a6bbd 100644 --- a/DEPS +++ b/DEPS
@@ -71,7 +71,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling ANGLE # and whatever else without interference from each other. - 'angle_revision': '9088557fe47e0ce1487b248b60acbc740acd7801', + 'angle_revision': '722bfb51d59188ee086839b69e00296b2d5d2da3', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling build tools # and whatever else without interference from each other. @@ -115,7 +115,7 @@ # Three lines of non-changing comments so that # the commit queue can handle CLs rolling catapult # and whatever else without interference from each other. - 'catapult_revision': '6fd9f08dcb0bd39f70bdac8d73aa4e87b789d6e5', + 'catapult_revision': 'd62be5b8d84501b0af45ea0b1014bcf88bc448f1', # Three lines of non-changing comments so that # the commit queue can handle CLs rolling libFuzzer # and whatever else without interference from each other.
diff --git a/chrome/chrome_watcher/chrome_watcher_main.cc b/chrome/chrome_watcher/chrome_watcher_main.cc index da878d96..ab319d2 100644 --- a/chrome/chrome_watcher/chrome_watcher_main.cc +++ b/chrome/chrome_watcher/chrome_watcher_main.cc
@@ -193,9 +193,15 @@ return; } - // Default to showing error dialogs. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNoErrorDialogs)) + // We call running in unattended mode "headless", and allow headless mode to + // be configured either by the Environment Variable or by the Command Line + // Switch. This is for automated test purposes. + std::unique_ptr<base::Environment> env(base::Environment::Create()); + const bool is_headless = env->HasVar(env_vars::kHeadless) || + command_line.HasSwitch(switches::kNoErrorDialogs); + + // Show fatal log messages in a dialog in debug builds when not headless. + if (!is_headless) SetShowErrorDialogs(true); // we want process and thread IDs because we have a lot of things running @@ -204,13 +210,8 @@ true, // enable_timestamp false); // enable_tickcount - // We call running in unattended mode "headless", and allow - // headless mode to be configured either by the Environment - // Variable or by the Command Line Switch. This is for - // automated test purposes. - std::unique_ptr<base::Environment> env(base::Environment::Create()); - if (env->HasVar(env_vars::kHeadless) || - command_line.HasSwitch(switches::kNoErrorDialogs)) + // Suppress system error dialogs when headless. + if (is_headless) SuppressDialogs(); // Use a minimum log level if the command line asks for one. Ignore this
diff --git a/chrome/common/logging_chrome.cc b/chrome/common/logging_chrome.cc index af1889b..e05e316 100644 --- a/chrome/common/logging_chrome.cc +++ b/chrome/common/logging_chrome.cc
@@ -319,9 +319,15 @@ } #endif - // Default to showing error dialogs. - if (!base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kNoErrorDialogs)) + // We call running in unattended mode "headless", and allow headless mode to + // be configured either by the Environment Variable or by the Command Line + // Switch. This is for automated test purposes. + std::unique_ptr<base::Environment> env(base::Environment::Create()); + const bool is_headless = env->HasVar(env_vars::kHeadless) || + command_line.HasSwitch(switches::kNoErrorDialogs); + + // Show fatal log messages in a dialog in debug builds when not headless. + if (!is_headless) SetShowErrorDialogs(true); // we want process and thread IDs because we have a lot of things running @@ -330,13 +336,8 @@ true, // enable_timestamp false); // enable_tickcount - // We call running in unattended mode "headless", and allow - // headless mode to be configured either by the Environment - // Variable or by the Command Line Switch. This is for - // automated test purposes. - std::unique_ptr<base::Environment> env(base::Environment::Create()); - if (env->HasVar(env_vars::kHeadless) || - command_line.HasSwitch(switches::kNoErrorDialogs)) + // Suppress system error dialogs when headless. + if (is_headless) SuppressDialogs(); // Use a minimum log level if the command line asks for one. Ignore this
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc index fd86463..f6b57a31 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -95,7 +95,6 @@ #include "content/common/renderer.mojom.h" #include "content/common/site_isolation_policy.h" #include "content/common/swapped_out_messages.h" -#include "content/common/url_loader_factory_bundle.mojom.h" #include "content/common/widget.mojom.h" #include "content/network/restricted_cookie_manager_impl.h" #include "content/public/browser/ax_event_notification_details.h" @@ -155,7 +154,6 @@ #include "ui/gfx/geometry/quad_f.h" #include "url/gurl.h" #include "url/origin.h" -#include "url/url_constants.h" #if defined(OS_ANDROID) #include "content/browser/android/java_interfaces_impl.h" @@ -3397,7 +3395,7 @@ GetNavigationControl()->CommitNavigation( ResourceResponseHead(), GURL(), common_params, request_params, mojo::ScopedDataPipeConsumerHandle(), - /*subresource_loader_factories=*/base::nullopt); + /*default_subresource_url_loader_factory=*/nullptr); return; } @@ -3417,49 +3415,17 @@ const GURL body_url = body.get() ? body->GetURL() : GURL(); const ResourceResponseHead head = response ? response->head : ResourceResponseHead(); - const bool is_same_document = - FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type); - - // TODO(scottmg): Pass a factory for SW, etc. once we have one. - base::Optional<URLLoaderFactoryBundle> subresource_loader_factories; - if (base::FeatureList::IsEnabled(features::kNetworkService) && - !is_same_document) { - // NOTE: On Network Service navigations, we want to ensure that a frame is - // given everything it will need to load any accessible subresources. We - // however only do this for cross-document navigations, because the - // alternative would be redundant effort. - mojom::URLLoaderFactoryPtr default_factory; - StoragePartitionImpl* storage_partition = - static_cast<StoragePartitionImpl*>(BrowserContext::GetStoragePartition( - GetSiteInstance()->GetBrowserContext(), GetSiteInstance())); + mojom::URLLoaderFactoryPtr default_subresource_url_loader_factory; + if (base::FeatureList::IsEnabled(features::kNetworkService)) { if (subresource_loader_params && subresource_loader_params->loader_factory_info.is_valid()) { - // If the caller has supplied a default URLLoaderFactory override (for - // e.g. appcache, Service Worker, etc.), use that. - default_factory.Bind( + default_subresource_url_loader_factory.Bind( std::move(subresource_loader_params->loader_factory_info)); - } else { - // Otherwise default to a Network Service-backed loader from the - // appropriate NetworkContext. - storage_partition->GetNetworkContext()->CreateURLLoaderFactory( - mojo::MakeRequest(&default_factory), GetProcess()->GetID()); } - - DCHECK(default_factory.is_bound()); - subresource_loader_factories.emplace(); - subresource_loader_factories->SetDefaultFactory(std::move(default_factory)); - - // Everyone gets a blob loader. - mojom::URLLoaderFactoryPtr blob_factory; - storage_partition->GetBlobURLLoaderFactory()->HandleRequest( - mojo::MakeRequest(&blob_factory)); - subresource_loader_factories->RegisterFactory(url::kBlobScheme, - std::move(blob_factory)); } - GetNavigationControl()->CommitNavigation( head, body_url, common_params, request_params, std::move(handle), - std::move(subresource_loader_factories)); + std::move(default_subresource_url_loader_factory)); // If a network request was made, update the Previews state. if (IsURLHandledByNetworkStack(common_params.url) && @@ -3473,7 +3439,7 @@ // same-document navigation would not load any new ones for replacement. // The user would finish with a half loaded document. // See https://crbug.com/769645. - if (!is_same_document) { + if (!FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type)) { // Released in OnStreamHandleConsumed(). stream_handle_ = std::move(body); }
diff --git a/content/browser/loader/mime_sniffing_resource_handler.cc b/content/browser/loader/mime_sniffing_resource_handler.cc index 0780096..5f391ff 100644 --- a/content/browser/loader/mime_sniffing_resource_handler.cc +++ b/content/browser/loader/mime_sniffing_resource_handler.cc
@@ -45,14 +45,6 @@ namespace { -const char kAcceptHeader[] = "Accept"; -const char kFrameAcceptHeader[] = - "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp," - "image/apng,*/*;q=0.8"; -const char kStylesheetAcceptHeader[] = "text/css,*/*;q=0.1"; -const char kImageAcceptHeader[] = "image/webp,image/apng,image/*,*/*;q=0.8"; -const char kDefaultAcceptHeader[] = "*/*"; - // Used to write into an existing IOBuffer at a given offset. This is // very similar to DependentIOBufferForRedirectToFile and // DependentIOBufferForAsyncLoading but not identical. @@ -139,42 +131,7 @@ std::unique_ptr<ResourceController> controller) { DCHECK(!has_controller()); - const char* accept_value = nullptr; - switch (GetRequestInfo()->GetResourceType()) { - case RESOURCE_TYPE_MAIN_FRAME: - case RESOURCE_TYPE_SUB_FRAME: - accept_value = kFrameAcceptHeader; - break; - case RESOURCE_TYPE_STYLESHEET: - accept_value = kStylesheetAcceptHeader; - break; - case RESOURCE_TYPE_FAVICON: - case RESOURCE_TYPE_IMAGE: - accept_value = kImageAcceptHeader; - break; - case RESOURCE_TYPE_SCRIPT: - case RESOURCE_TYPE_FONT_RESOURCE: - case RESOURCE_TYPE_SUB_RESOURCE: - case RESOURCE_TYPE_OBJECT: - case RESOURCE_TYPE_MEDIA: - case RESOURCE_TYPE_WORKER: - case RESOURCE_TYPE_SHARED_WORKER: - case RESOURCE_TYPE_PREFETCH: - case RESOURCE_TYPE_XHR: - case RESOURCE_TYPE_PING: - case RESOURCE_TYPE_SERVICE_WORKER: - case RESOURCE_TYPE_CSP_REPORT: - case RESOURCE_TYPE_PLUGIN_RESOURCE: - accept_value = kDefaultAcceptHeader; - break; - case RESOURCE_TYPE_LAST_TYPE: - NOTREACHED(); - break; - } - - // The false parameter prevents overwriting an existing accept header value, - // which is needed because JS can manually set an accept header on an XHR. - request()->SetExtraRequestHeaderByName(kAcceptHeader, accept_value, false); + AttachAcceptHeader(GetRequestInfo()->GetResourceType(), request()); next_handler_->OnWillStart(url, std::move(controller)); }
diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn index eee8cf8..ceba883 100644 --- a/content/common/BUILD.gn +++ b/content/common/BUILD.gn
@@ -317,8 +317,6 @@ "throttling_url_loader.h", "unique_name_helper.cc", "unique_name_helper.h", - "url_loader_factory_bundle.cc", - "url_loader_factory_bundle.h", "url_request_struct_traits.cc", "url_request_struct_traits.h", "url_schemes.cc", @@ -616,7 +614,6 @@ "shared_worker/shared_worker_host.mojom", "shared_worker/shared_worker_info.mojom", "storage_partition_service.mojom", - "url_loader_factory_bundle.mojom", "video_capture.mojom", "widget.mojom", ]
diff --git a/content/common/frame.mojom b/content/common/frame.mojom index cde8296e..820b00e 100644 --- a/content/common/frame.mojom +++ b/content/common/frame.mojom
@@ -4,8 +4,8 @@ module content.mojom; -import "content/common/url_loader_factory_bundle.mojom"; import "content/public/common/url_loader.mojom"; +import "content/public/common/url_loader_factory.mojom"; import "content/public/common/window_container_type.mojom"; import "mojo/common/unguessable_token.mojom"; import "services/service_manager/public/interfaces/interface_provider.mojom"; @@ -38,15 +38,14 @@ // should request |body_url| to get access to the stream containing the body // of the response. When the Network Service is enabled, |body_url| is not // used and instead the data is passed to the renderer via |body_data|. In - // that case |subresource_loader_factories| may also be provided by the - // browser as a a means for the renderer to load subresources where - // applicable. + // that case |default_subresource_url_loader_factory| may also be provided by + // the browser as a means for the renderer to load subresources. CommitNavigation(URLResponseHead head, url.mojom.Url body_url, CommonNavigationParams common_params, RequestNavigationParams request_params, handle<data_pipe_consumer>? body_data, - URLLoaderFactoryBundle? subresource_loader_factories); + URLLoaderFactory? default_subresource_url_loader_factory); }; // Implemented by the frame (e.g. renderer processes).
diff --git a/content/common/loader_util.cc b/content/common/loader_util.cc index 0886c2b..e2babdc 100644 --- a/content/common/loader_util.cc +++ b/content/common/loader_util.cc
@@ -16,6 +16,16 @@ namespace content { +namespace { +constexpr char kAcceptHeader[] = "Accept"; +constexpr char kFrameAcceptHeader[] = + "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp," + "image/apng,*/*;q=0.8"; +constexpr char kStylesheetAcceptHeader[] = "text/css,*/*;q=0.1"; +constexpr char kImageAcceptHeader[] = "image/webp,image/apng,image/*,*/*;q=0.8"; +constexpr char kDefaultAcceptHeader[] = "*/*"; +} // namespace + bool ShouldSniffContent(net::URLRequest* url_request, ResourceResponse* response) { const std::string& mime_type = response->head.mime_type; @@ -87,4 +97,42 @@ return info; } +void AttachAcceptHeader(ResourceType type, net::URLRequest* request) { + const char* accept_value = nullptr; + switch (type) { + case RESOURCE_TYPE_MAIN_FRAME: + case RESOURCE_TYPE_SUB_FRAME: + accept_value = kFrameAcceptHeader; + break; + case RESOURCE_TYPE_STYLESHEET: + accept_value = kStylesheetAcceptHeader; + break; + case RESOURCE_TYPE_FAVICON: + case RESOURCE_TYPE_IMAGE: + accept_value = kImageAcceptHeader; + break; + case RESOURCE_TYPE_SCRIPT: + case RESOURCE_TYPE_FONT_RESOURCE: + case RESOURCE_TYPE_SUB_RESOURCE: + case RESOURCE_TYPE_OBJECT: + case RESOURCE_TYPE_MEDIA: + case RESOURCE_TYPE_WORKER: + case RESOURCE_TYPE_SHARED_WORKER: + case RESOURCE_TYPE_PREFETCH: + case RESOURCE_TYPE_XHR: + case RESOURCE_TYPE_PING: + case RESOURCE_TYPE_SERVICE_WORKER: + case RESOURCE_TYPE_CSP_REPORT: + case RESOURCE_TYPE_PLUGIN_RESOURCE: + accept_value = kDefaultAcceptHeader; + break; + case RESOURCE_TYPE_LAST_TYPE: + NOTREACHED(); + break; + } + // The false parameter prevents overwriting an existing accept header value, + // which is needed because JS can manually set an accept header on an XHR. + request->SetExtraRequestHeaderByName(kAcceptHeader, accept_value, false); +} + } // namespace content
diff --git a/content/common/loader_util.h b/content/common/loader_util.h index 8f232c3..b132bd03 100644 --- a/content/common/loader_util.h +++ b/content/common/loader_util.h
@@ -6,6 +6,7 @@ #define CONTENT_COMMON_LOADER_UTIL_H_ #include "base/memory/ref_counted.h" +#include "content/public/common/resource_type.h" namespace net { class HttpRawRequestHeaders; @@ -31,6 +32,8 @@ const net::HttpRawRequestHeaders& raw_request_headers, const net::HttpResponseHeaders* raw_response_headers); +void AttachAcceptHeader(ResourceType type, net::URLRequest* request); + } // namespace content #endif // CONTENT_COMMON_LOADER_UTIL_H_
diff --git a/content/common/typemaps.gni b/content/common/typemaps.gni index ab0d08b3..3daaa86 100644 --- a/content/common/typemaps.gni +++ b/content/common/typemaps.gni
@@ -15,7 +15,6 @@ "//content/common/service_worker/service_worker_fetch_request.typemap", "//content/common/service_worker/service_worker_provider.typemap", "//content/common/service_worker/service_worker_types.typemap", - "//content/common/url_loader_factory_bundle.typemap", "//content/common/web_preferences.typemap", "//content/common/media/media_session.typemap", ]
diff --git a/content/common/url_loader_factory_bundle.cc b/content/common/url_loader_factory_bundle.cc deleted file mode 100644 index a0128c84..0000000 --- a/content/common/url_loader_factory_bundle.cc +++ /dev/null
@@ -1,94 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/url_loader_factory_bundle.h" - -#include <map> -#include <string> - -#include "base/macros.h" -#include "content/public/common/url_loader_factory.mojom.h" -#include "url/gurl.h" - -class GURL; - -namespace content { - -URLLoaderFactoryBundleInfo::URLLoaderFactoryBundleInfo( - URLLoaderFactoryBundleInfo&&) = default; - -URLLoaderFactoryBundleInfo::URLLoaderFactoryBundleInfo( - mojom::URLLoaderFactoryPtrInfo default_factory_info, - std::map<std::string, mojom::URLLoaderFactoryPtrInfo> factories_info) - : default_factory_info(std::move(default_factory_info)), - factories_info(std::move(factories_info)) {} - -URLLoaderFactoryBundleInfo::~URLLoaderFactoryBundleInfo() = default; - -URLLoaderFactoryBundle::URLLoaderFactoryBundle() = default; - -URLLoaderFactoryBundle::URLLoaderFactoryBundle(URLLoaderFactoryBundle&&) = - default; - -URLLoaderFactoryBundle::URLLoaderFactoryBundle( - URLLoaderFactoryBundleInfo info) { - default_factory_.Bind(std::move(info.default_factory_info)); - for (auto& factory_info : info.factories_info) - factories_[factory_info.first].Bind(std::move(factory_info.second)); -} - -URLLoaderFactoryBundle::~URLLoaderFactoryBundle() = default; - -URLLoaderFactoryBundle& URLLoaderFactoryBundle::operator=( - URLLoaderFactoryBundle&&) = default; - -void URLLoaderFactoryBundle::SetDefaultFactory( - mojom::URLLoaderFactoryPtr factory) { - default_factory_ = std::move(factory); -} - -void URLLoaderFactoryBundle::RegisterFactory( - const base::StringPiece& scheme, - mojom::URLLoaderFactoryPtr factory) { - DCHECK(factory.is_bound()); - auto result = factories_.emplace(std::string(scheme), std::move(factory)); - DCHECK(result.second); -} - -mojom::URLLoaderFactory* URLLoaderFactoryBundle::GetFactoryForRequest( - const GURL& url) { - auto it = factories_.find(url.scheme()); - if (it == factories_.end()) { - DCHECK(default_factory_.is_bound()); - return default_factory_.get(); - } - return it->second.get(); -} - -URLLoaderFactoryBundleInfo URLLoaderFactoryBundle::PassInfo() { - std::map<std::string, mojom::URLLoaderFactoryPtrInfo> factories_info; - for (auto& factory : factories_) - factories_info.emplace(factory.first, factory.second.PassInterface()); - DCHECK(default_factory_.is_bound()); - return URLLoaderFactoryBundleInfo(default_factory_.PassInterface(), - std::move(factories_info)); -} - -URLLoaderFactoryBundle URLLoaderFactoryBundle::Clone() { - DCHECK(default_factory_.is_bound()); - mojom::URLLoaderFactoryPtr cloned_default_factory; - default_factory_->Clone(mojo::MakeRequest(&cloned_default_factory)); - - URLLoaderFactoryBundle new_bundle; - new_bundle.SetDefaultFactory(std::move(cloned_default_factory)); - for (auto& factory : factories_) { - mojom::URLLoaderFactoryPtr cloned_factory; - factory.second->Clone(mojo::MakeRequest(&cloned_factory)); - new_bundle.RegisterFactory(factory.first, std::move(cloned_factory)); - } - - return new_bundle; -} - -} // namespace content
diff --git a/content/common/url_loader_factory_bundle.h b/content/common/url_loader_factory_bundle.h deleted file mode 100644 index 0147254..0000000 --- a/content/common/url_loader_factory_bundle.h +++ /dev/null
@@ -1,87 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_H_ -#define CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_H_ - -#include <map> -#include <string> - -#include "base/macros.h" -#include "content/common/content_export.h" -#include "content/public/common/url_loader_factory.mojom.h" - -class GURL; - -namespace mojo { -template <typename, typename> -struct StructTraits; -} - -namespace content { - -namespace mojom { -class URLLoaderFactoryBundleDataView; -} - -// Holds the internal state of a URLLoaderFactoryBundle in a form that is safe -// to pass across sequences. -struct CONTENT_EXPORT URLLoaderFactoryBundleInfo { - URLLoaderFactoryBundleInfo(URLLoaderFactoryBundleInfo&&); - URLLoaderFactoryBundleInfo( - mojom::URLLoaderFactoryPtrInfo default_factory_info, - std::map<std::string, mojom::URLLoaderFactoryPtrInfo> factories_info); - ~URLLoaderFactoryBundleInfo(); - - mojom::URLLoaderFactoryPtrInfo default_factory_info; - std::map<std::string, mojom::URLLoaderFactoryPtrInfo> factories_info; -}; - -// Encapsulates a collection of URLLoaderFactoryPtrs which can be usd to acquire -// loaders for various types of resource requests. -class CONTENT_EXPORT URLLoaderFactoryBundle { - public: - URLLoaderFactoryBundle(); - URLLoaderFactoryBundle(URLLoaderFactoryBundle&&); - explicit URLLoaderFactoryBundle(URLLoaderFactoryBundleInfo info); - ~URLLoaderFactoryBundle(); - - URLLoaderFactoryBundle& operator=(URLLoaderFactoryBundle&&); - - // Sets the default factory to use when no registered factories match a given - // |url|. - void SetDefaultFactory(mojom::URLLoaderFactoryPtr factory); - - // Registers a new factory to handle requests matching scheme |scheme|. - void RegisterFactory(const base::StringPiece& scheme, - mojom::URLLoaderFactoryPtr factory); - - // Returns a factory which can be used to acquire a loader for |url|. If no - // registered factory matches |url|'s scheme, the default factory is used. It - // is undefined behavior to call this when no default factory is set. - mojom::URLLoaderFactory* GetFactoryForRequest(const GURL& url); - - // Passes out a structure which captures the internal state of this bundle in - // a form that is safe to pass across sequences. Effectively resets |this| - // to have no registered factories. - URLLoaderFactoryBundleInfo PassInfo(); - - // Creates a clone of this bundle which can be passed to and owned by another - // consumer. The clone operates identically to but independent from the - // original (this) bundle. - URLLoaderFactoryBundle Clone(); - - private: - friend struct mojo::StructTraits<mojom::URLLoaderFactoryBundleDataView, - URLLoaderFactoryBundle>; - - mojom::URLLoaderFactoryPtr default_factory_; - std::map<std::string, mojom::URLLoaderFactoryPtr> factories_; - - DISALLOW_COPY_AND_ASSIGN(URLLoaderFactoryBundle); -}; - -} // namespace content - -#endif // CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_H_
diff --git a/content/common/url_loader_factory_bundle.mojom b/content/common/url_loader_factory_bundle.mojom deleted file mode 100644 index 1f0f9e2b..0000000 --- a/content/common/url_loader_factory_bundle.mojom +++ /dev/null
@@ -1,16 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -module content.mojom; - -import "content/public/common/url_loader_factory.mojom"; - -// Serializes a collection of URLLoaderFactory interfaces. -struct URLLoaderFactoryBundle { - // The default factory to be used when no others apply. - URLLoaderFactory default_factory; - - // A mapping from URL scheme to factory interface. - map<string, URLLoaderFactory> factories; -};
diff --git a/content/common/url_loader_factory_bundle.typemap b/content/common/url_loader_factory_bundle.typemap deleted file mode 100644 index 066c04c..0000000 --- a/content/common/url_loader_factory_bundle.typemap +++ /dev/null
@@ -1,13 +0,0 @@ -# Copyright 2017 The Chromium Authors. All rights reserved. -# Use of this source code is governed by a BSD-style license that can be -# found in the LICENSE file. - -mojom = "//content/common/url_loader_factory_bundle.mojom" -public_headers = [ "//content/common/url_loader_factory_bundle.h" ] -traits_headers = - [ "//content/common/url_loader_factory_bundle_struct_traits.h" ] -sources = [ - "//content/common/url_loader_factory_bundle_struct_traits.cc", -] - -type_mappings = [ "content.mojom.URLLoaderFactoryBundle=content::URLLoaderFactoryBundle[move_only]" ]
diff --git a/content/common/url_loader_factory_bundle_struct_traits.cc b/content/common/url_loader_factory_bundle_struct_traits.cc deleted file mode 100644 index 917d12a..0000000 --- a/content/common/url_loader_factory_bundle_struct_traits.cc +++ /dev/null
@@ -1,34 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/common/url_loader_factory_bundle_struct_traits.h" - -namespace mojo { - -using Traits = StructTraits<content::mojom::URLLoaderFactoryBundleDataView, - content::URLLoaderFactoryBundle>; - -// static -content::mojom::URLLoaderFactoryPtr Traits::default_factory( - content::URLLoaderFactoryBundle& bundle) { - return std::move(bundle.default_factory_); -} - -// static -std::map<std::string, content::mojom::URLLoaderFactoryPtr> Traits::factories( - content::URLLoaderFactoryBundle& bundle) { - return std::move(bundle.factories_); -} - -// static -bool Traits::Read(content::mojom::URLLoaderFactoryBundleDataView data, - content::URLLoaderFactoryBundle* out_bundle) { - out_bundle->SetDefaultFactory( - data.TakeDefaultFactory<content::mojom::URLLoaderFactoryPtr>()); - if (!data.ReadFactories(&out_bundle->factories_)) - return false; - return true; -} - -} // namespace mojo
diff --git a/content/common/url_loader_factory_bundle_struct_traits.h b/content/common/url_loader_factory_bundle_struct_traits.h deleted file mode 100644 index f263049..0000000 --- a/content/common/url_loader_factory_bundle_struct_traits.h +++ /dev/null
@@ -1,29 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_STRUCT_TRAITS_H_ -#define CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_STRUCT_TRAITS_H_ - -#include "content/common/url_loader_factory_bundle.h" -#include "content/common/url_loader_factory_bundle.mojom-shared.h" -#include "mojo/public/cpp/bindings/struct_traits.h" - -namespace mojo { - -template <> -struct StructTraits<content::mojom::URLLoaderFactoryBundleDataView, - content::URLLoaderFactoryBundle> { - static content::mojom::URLLoaderFactoryPtr default_factory( - content::URLLoaderFactoryBundle& bundle); - - static std::map<std::string, content::mojom::URLLoaderFactoryPtr> factories( - content::URLLoaderFactoryBundle& bundle); - - static bool Read(content::mojom::URLLoaderFactoryBundleDataView data, - content::URLLoaderFactoryBundle* out_bundle); -}; - -} // namespace mojo - -#endif // CONTENT_COMMON_URL_LOADER_FACTORY_BUNDLE_STRUCT_TRAITS_H_
diff --git a/content/network/url_loader_impl.cc b/content/network/url_loader_impl.cc index acabd23..012cfdf 100644 --- a/content/network/url_loader_impl.cc +++ b/content/network/url_loader_impl.cc
@@ -322,6 +322,9 @@ url_request_->SetResponseHeadersCallback(base::Bind( &URLLoaderImpl::SetRawResponseHeaders, base::Unretained(this))); } + + AttachAcceptHeader(request.resource_type, url_request_.get()); + url_request_->Start(); }
diff --git a/content/network/url_loader_unittest.cc b/content/network/url_loader_unittest.cc index 40e8f9b..ab590cd 100644 --- a/content/network/url_loader_unittest.cc +++ b/content/network/url_loader_unittest.cc
@@ -162,6 +162,9 @@ void SetUp() override { test_server_.AddDefaultHandlers( base::FilePath(FILE_PATH_LITERAL("content/test/data"))); + // This Unretained is safe because test_server_ is owned by |this|. + test_server_.RegisterRequestMonitor( + base::Bind(&URLLoaderImplTest::Monitor, base::Unretained(this))); ASSERT_TRUE(test_server_.Start()); } @@ -174,13 +177,14 @@ DCHECK(!ran_); mojom::URLLoaderPtr loader; - ResourceRequest request = - CreateResourceRequest("GET", RESOURCE_TYPE_MAIN_FRAME, url); + ResourceRequest request = CreateResourceRequest("GET", resource_type_, url); uint32_t options = mojom::kURLLoadOptionNone; if (send_ssl_) options |= mojom::kURLLoadOptionSendSSLInfo; if (sniff_) options |= mojom::kURLLoadOptionSniffMimeType; + if (add_custom_accept_header_) + request.headers.SetHeader("accept", "custom/*"); URLLoaderImpl loader_impl(context(), mojo::MakeRequest(&loader), options, request, false, client_.CreateInterfacePtr(), @@ -281,6 +285,14 @@ DCHECK(!ran_); send_ssl_ = true; } + void set_add_custom_accept_header() { + DCHECK(!ran_); + add_custom_accept_header_ = true; + } + void set_resource_type(ResourceType type) { + DCHECK(!ran_); + resource_type_ = type; + } // Convenience methods after calling Load(); std::string mime_type() const { @@ -354,15 +366,26 @@ return std::string(buffer.data(), buffer.size()); } + const net::test_server::HttpRequest& sent_request() const { + return sent_request_; + } + private: + void Monitor(const net::test_server::HttpRequest& request) { + sent_request_ = request; + } + base::test::ScopedTaskEnvironment scoped_task_environment_; net::EmbeddedTestServer test_server_; std::unique_ptr<NetworkContext> context_; bool sniff_ = false; bool send_ssl_ = false; + bool add_custom_accept_header_ = false; + ResourceType resource_type_ = RESOURCE_TYPE_MAIN_FRAME; // Used to ensure that methods are called either before or after a request is // made, since the test fixture is meant to be used only once. bool ran_ = false; + net::test_server::HttpRequest sent_request_; TestURLLoaderClient client_; }; @@ -853,4 +876,35 @@ ReadBody()); } +TEST_F(URLLoaderImplTest, AttachAcceptHeaderForStyleSheet) { + set_resource_type(RESOURCE_TYPE_STYLESHEET); + EXPECT_EQ(net::OK, + Load(test_server()->GetURL("/content-sniffer-test0.html"))); + + auto it = sent_request().headers.find("accept"); + ASSERT_NE(it, sent_request().headers.end()); + EXPECT_EQ(it->second, "text/css,*/*;q=0.1"); +} + +TEST_F(URLLoaderImplTest, AttachAcceptHeaderForXHR) { + set_resource_type(RESOURCE_TYPE_XHR); + EXPECT_EQ(net::OK, + Load(test_server()->GetURL("/content-sniffer-test0.html"))); + + auto it = sent_request().headers.find("accept"); + ASSERT_NE(it, sent_request().headers.end()); + EXPECT_EQ(it->second, "*/*"); +} + +TEST_F(URLLoaderImplTest, DoNotOverrideAcceptHeader) { + set_resource_type(RESOURCE_TYPE_XHR); + set_add_custom_accept_header(); + EXPECT_EQ(net::OK, + Load(test_server()->GetURL("/content-sniffer-test0.html"))); + + auto it = sent_request().headers.find("accept"); + ASSERT_NE(it, sent_request().headers.end()); + EXPECT_EQ(it->second, "custom/*"); +} + } // namespace content
diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 0c5e05c..8a3113d 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc
@@ -743,14 +743,9 @@ DCHECK(frame_); frame_->UpdatePeakMemoryStats(); - mojom::URLLoaderFactory* factory; - if (base::FeatureList::IsEnabled(features::kNetworkService)) { - factory = frame_->GetSubresourceLoaderFactories().GetFactoryForRequest( - request.Url()); - } else { - factory = frame_->GetDefaultURLLoaderFactoryGetter()->GetFactoryForURL( - request.Url(), frame_->custom_url_loader_factory()); - } + mojom::URLLoaderFactory* factory = + frame_->GetDefaultURLLoaderFactoryGetter()->GetFactoryForURL( + request.Url(), frame_->custom_url_loader_factory()); DCHECK(factory); mojom::KeepAliveHandlePtr keep_alive_handle; @@ -1821,8 +1816,7 @@ TRACE_EVENT2("navigation,rail", "RenderFrameImpl::OnNavigate", "id", routing_id_, "url", common_params.url.possibly_invalid_spec()); NavigateInternal(common_params, start_params, request_params, - std::unique_ptr<StreamOverrideParameters>(), - /*subresource_loader_factories=*/base::nullopt); + std::unique_ptr<StreamOverrideParameters>()); } void RenderFrameImpl::BindEngagement( @@ -3017,7 +3011,7 @@ const CommonNavigationParams& common_params, const RequestNavigationParams& request_params, mojo::ScopedDataPipeConsumerHandle body_data, - base::Optional<URLLoaderFactoryBundle> subresource_loader_factories) { + mojom::URLLoaderFactoryPtr default_subresource_url_loader_factory) { CHECK(IsBrowserSideNavigationEnabled()); // If this was a renderer-initiated navigation (nav_entry_id == 0) from this // frame, but it was aborted, then ignore it. @@ -3052,6 +3046,8 @@ }, weak_factory_.GetWeakPtr()); + SetCustomURLLoaderFactory(std::move(default_subresource_url_loader_factory)); + // If the request was initiated in the context of a user gesture then make // sure that the navigation also executes in the context of a user gesture. std::unique_ptr<blink::WebScopedUserGesture> gesture( @@ -3062,8 +3058,7 @@ browser_side_navigation_pending_url_ = GURL(); NavigateInternal(common_params, StartNavigationParams(), request_params, - std::move(stream_override), - std::move(subresource_loader_factories)); + std::move(stream_override)); // Don't add code after this since NavigateInternal may have destroyed this // RenderFrameImpl. @@ -6174,8 +6169,7 @@ const CommonNavigationParams& common_params, const StartNavigationParams& start_params, const RequestNavigationParams& request_params, - std::unique_ptr<StreamOverrideParameters> stream_params, - base::Optional<URLLoaderFactoryBundle> subresource_loader_factories) { + std::unique_ptr<StreamOverrideParameters> stream_params) { bool browser_side_navigation = IsBrowserSideNavigationEnabled(); // PlzNavigate @@ -6239,15 +6233,6 @@ IsBrowserSideNavigationEnabled() && FrameMsg_Navigate_Type::IsSameDocument(common_params.navigation_type); - // The browser only provides new subresource loader factories on - // cross-document navigations. In other cases we are free to keep reusing the - // ones we have. - if (!is_same_document && - base::FeatureList::IsEnabled(features::kNetworkService)) { - DCHECK(subresource_loader_factories); - subresource_loader_factories_ = std::move(subresource_loader_factories); - } - WebURLRequest request = CreateURLRequestForNavigation( common_params, request_params, std::move(stream_params), frame_->IsViewSourceModeEnabled(), is_same_document); @@ -6454,18 +6439,6 @@ } } -URLLoaderFactoryBundle& RenderFrameImpl::GetSubresourceLoaderFactories() { - DCHECK(base::FeatureList::IsEnabled(features::kNetworkService)); - if (!subresource_loader_factories_) { - RenderFrameImpl* creator = RenderFrameImpl::FromWebFrame( - frame_->Parent() ? frame_->Parent() : frame_->Opener()); - DCHECK(creator); - subresource_loader_factories_ = - creator->GetSubresourceLoaderFactories().Clone(); - } - return *subresource_loader_factories_; -} - void RenderFrameImpl::UpdateEncoding(WebFrame* frame, const std::string& encoding_name) { // Only update main frame's encoding_name. @@ -6534,14 +6507,7 @@ void RenderFrameImpl::SetCustomURLLoaderFactory( mojom::URLLoaderFactoryPtr factory) { - if (base::FeatureList::IsEnabled(features::kNetworkService)) { - // When the network service is enabled, all subresource loads go through - // a factory from |subresource_loader_factories|. In this case we simply - // replace the existing default factory within the bundle. - GetSubresourceLoaderFactories().SetDefaultFactory(std::move(factory)); - } else { - custom_url_loader_factory_ = std::move(factory); - } + custom_url_loader_factory_ = std::move(factory); } void RenderFrameImpl::InitializeUserMediaClient() {
diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 640d8026..9bc0b9b 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h
@@ -38,7 +38,6 @@ #include "content/common/possibly_associated_interface_ptr.h" #include "content/common/renderer.mojom.h" #include "content/common/unique_name_helper.h" -#include "content/common/url_loader_factory_bundle.h" #include "content/common/widget.mojom.h" #include "content/public/common/console_message_level.h" #include "content/public/common/javascript_dialog_type.h" @@ -518,14 +517,14 @@ // mojom::FrameBindingsControl implementation: void AllowBindings(int32_t enabled_bindings_flags) override; - // mojom::FrameNavigationControl implementation: - void CommitNavigation( - const ResourceResponseHead& head, - const GURL& body_url, - const CommonNavigationParams& common_params, - const RequestNavigationParams& request_params, - mojo::ScopedDataPipeConsumerHandle body_data, - base::Optional<URLLoaderFactoryBundle> subresource_loaders) override; + // mojom::FrameNavigationControl implemenentation: + void CommitNavigation(const ResourceResponseHead& head, + const GURL& body_url, + const CommonNavigationParams& common_params, + const RequestNavigationParams& request_params, + mojo::ScopedDataPipeConsumerHandle body_data, + mojom::URLLoaderFactoryPtr + default_subresource_url_loader_factory) override; // mojom::HostZoom implementation: void SetHostZoomLevel(const GURL& url, double zoom_level) override; @@ -1086,16 +1085,7 @@ const CommonNavigationParams& common_params, const StartNavigationParams& start_params, const RequestNavigationParams& request_params, - std::unique_ptr<StreamOverrideParameters> stream_params, - base::Optional<URLLoaderFactoryBundle> subresource_loader_factories); - - // Returns a URLLoaderFactoryBundle which can be used to request subresources - // for this frame. Only valid to call when the Network Service is enabled. - // For frames with committed navigations, this bundle is provided by the - // browser at navigation time. For any other frames (i.e. frames on the - // initial about:blank Document), the bundle returned here is lazily cloned - // from the parent or opener's own bundle. - URLLoaderFactoryBundle& GetSubresourceLoaderFactories(); + std::unique_ptr<StreamOverrideParameters> stream_params); // Update current main frame's encoding and send it to browser window. // Since we want to let users see the right encoding info from menu @@ -1546,10 +1536,6 @@ scoped_refptr<ChildURLLoaderFactoryGetter> url_loader_factory_getter_; - // URLLoaderFactory instances used for subresource loading when the Network - // Service is enabled. - base::Optional<URLLoaderFactoryBundle> subresource_loader_factories_; - // AndroidOverlay routing token from the browser, if we have one yet. base::Optional<base::UnguessableToken> overlay_routing_token_;
diff --git a/content/renderer/render_frame_impl_browsertest.cc b/content/renderer/render_frame_impl_browsertest.cc index f206d66..7d4c2e39 100644 --- a/content/renderer/render_frame_impl_browsertest.cc +++ b/content/renderer/render_frame_impl_browsertest.cc
@@ -361,7 +361,7 @@ GetMainRenderFrame()->SetHostZoomLevel(common_params.url, kMinZoomLevel); GetMainRenderFrame()->NavigateInternal( common_params, StartNavigationParams(), RequestNavigationParams(), - std::unique_ptr<StreamOverrideParameters>(), base::nullopt); + std::unique_ptr<StreamOverrideParameters>()); base::RunLoop().RunUntilIdle(); EXPECT_DOUBLE_EQ(kMinZoomLevel, view_->GetWebView()->ZoomLevel()); @@ -372,7 +372,7 @@ GetMainRenderFrame()->SetHostZoomLevel(common_params.url, kMaxZoomLevel); GetMainRenderFrame()->NavigateInternal( common_params, StartNavigationParams(), RequestNavigationParams(), - std::unique_ptr<StreamOverrideParameters>(), base::nullopt); + std::unique_ptr<StreamOverrideParameters>()); base::RunLoop().RunUntilIdle(); EXPECT_DOUBLE_EQ(kMaxZoomLevel, view_->GetWebView()->ZoomLevel()); }
diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index 95001684..27b81e4 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc
@@ -79,7 +79,7 @@ if (IsBrowserSideNavigationEnabled()) { CommitNavigation(ResourceResponseHead(), GURL(), common_params, request_params, mojo::ScopedDataPipeConsumerHandle(), - base::nullopt); + nullptr); } else { OnNavigate(common_params, start_params, request_params); }
diff --git a/content/test/test_render_frame_host.cc b/content/test/test_render_frame_host.cc index a26889e..2dfdae69 100644 --- a/content/test/test_render_frame_host.cc +++ b/content/test/test_render_frame_host.cc
@@ -61,12 +61,12 @@ const CommonNavigationParams& common_params, const RequestNavigationParams& request_params, mojo::ScopedDataPipeConsumerHandle body_data, - base::Optional<URLLoaderFactoryBundle> - subresource_loader_factories) override { + mojom::URLLoaderFactoryPtr + default_subresource_url_loader_factory) override { frame_host_->GetProcess()->set_did_frame_commit_navigation(true); frame_host_->GetInternalNavigationControl()->CommitNavigation( head, body_url, common_params, request_params, std::move(body_data), - std::move(subresource_loader_factories)); + std::move(default_subresource_url_loader_factory)); } private:
diff --git a/gpu/command_buffer/service/context_group.cc b/gpu/command_buffer/service/context_group.cc index 7453d71..e510684 100644 --- a/gpu/command_buffer/service/context_group.cc +++ b/gpu/command_buffer/service/context_group.cc
@@ -582,7 +582,9 @@ } if (texture_manager_ != NULL) { - texture_manager_->Destroy(have_context); + if (!have_context) + texture_manager_->MarkContextLost(); + texture_manager_->Destroy(); texture_manager_.reset(); ReportProgress(); }
diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc index 6a96d4c..01551f9 100644 --- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc +++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
@@ -55,7 +55,8 @@ } ~FramebufferManagerTest() override { manager_.Destroy(false); - texture_manager_->Destroy(false); + texture_manager_->MarkContextLost(); + texture_manager_->Destroy(); renderbuffer_manager_->Destroy(false); } @@ -133,7 +134,8 @@ } ~FramebufferInfoTestBase() override { manager_.Destroy(false); - texture_manager_->Destroy(false); + texture_manager_->MarkContextLost(); + texture_manager_->Destroy(); renderbuffer_manager_->Destroy(false); }
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 24d17fc..166da82 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -4952,6 +4952,9 @@ for (auto& fence : deschedule_until_finished_fences_) { fence->Invalidate(); } + + if (group_ && group_->texture_manager()) + group_->texture_manager()->MarkContextLost(); } deschedule_until_finished_fences_.clear();
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_lost.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_lost.cc index 2b882079..de10d51c 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_lost.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_context_lost.cc
@@ -190,6 +190,44 @@ ClearCurrentDecoderError(); } +TEST_P(GLES2DecoderLostContextTest, TextureDestroyAfterLostFromMakeCurrent) { + Init(true); + // Create a texture and framebuffer, and attach the texture to the + // framebuffer. + const GLuint kClientTextureId = 4100; + const GLuint kServiceTextureId = 4101; + EXPECT_CALL(*gl_, GenTextures(_, _)) + .WillOnce(SetArgPointee<1>(kServiceTextureId)) + .RetiresOnSaturation(); + GenHelper<GenTexturesImmediate>(kClientTextureId); + DoBindTexture(GL_TEXTURE_2D, kClientTextureId, kServiceTextureId); + DoTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 5, 6, 0, GL_RGBA, GL_UNSIGNED_BYTE, + shared_memory_id_, kSharedMemoryOffset); + DoBindFramebuffer(GL_FRAMEBUFFER, client_framebuffer_id_, + kServiceFramebufferId); + DoFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + kClientTextureId, kServiceTextureId, 0, GL_NO_ERROR); + + // The texture should never be deleted at the GL level. + EXPECT_CALL(*gl_, DeleteTextures(1, Pointee(kServiceTextureId))) + .Times(0) + .RetiresOnSaturation(); + + DoBindFramebuffer(GL_FRAMEBUFFER, 0, 0); + EXPECT_CALL(*gl_, BindTexture(_, 0)).Times(testing::AnyNumber()); + GenHelper<cmds::DeleteTexturesImmediate>(kClientTextureId); + + // Force context lost for MakeCurrent(). + EXPECT_CALL(*context_, MakeCurrent(surface_.get())).WillOnce(Return(false)); + // Expect the group to be lost. + EXPECT_CALL(*mock_decoder_, MarkContextLost(error::kUnknown)).Times(1); + + decoder_->MakeCurrent(); + EXPECT_TRUE(decoder_->WasContextLost()); + EXPECT_EQ(error::kMakeCurrentFailed, GetContextLostReason()); + ClearCurrentDecoderError(); +} + TEST_P(GLES2DecoderLostContextTest, LostFromResetAfterMakeCurrent) { Init(true); // with robustness InSequence seq;
diff --git a/gpu/command_buffer/service/texture_manager.cc b/gpu/command_buffer/service/texture_manager.cc index c1b4475..b5f8ae4 100644 --- a/gpu/command_buffer/service/texture_manager.cc +++ b/gpu/command_buffer/service/texture_manager.cc
@@ -443,9 +443,11 @@ this); } -void TextureManager::Destroy(bool have_context) { - have_context_ = have_context; +void TextureManager::MarkContextLost() { + have_context_ = false; +} +void TextureManager::Destroy() { // Retreive any outstanding unlocked textures from the discardable manager so // we can clean them up here. discardable_manager_->OnTextureManagerDestruction(this); @@ -461,7 +463,7 @@ progress_reporter_->ReportProgress(); } - if (have_context) { + if (have_context_) { glDeleteTextures(arraysize(black_texture_ids_), black_texture_ids_); }
diff --git a/gpu/command_buffer/service/texture_manager.h b/gpu/command_buffer/service/texture_manager.h index 776d528..574b32e 100644 --- a/gpu/command_buffer/service/texture_manager.h +++ b/gpu/command_buffer/service/texture_manager.h
@@ -773,8 +773,10 @@ // Init the texture manager. void Initialize(); + void MarkContextLost(); + // Must call before destruction. - void Destroy(bool have_context); + void Destroy(); // Returns the maximum number of levels. GLint MaxLevelsForTarget(GLenum target) const {
diff --git a/gpu/command_buffer/service/texture_manager_unittest.cc b/gpu/command_buffer/service/texture_manager_unittest.cc index 90fc64e..6e4157c 100644 --- a/gpu/command_buffer/service/texture_manager_unittest.cc +++ b/gpu/command_buffer/service/texture_manager_unittest.cc
@@ -92,7 +92,8 @@ } void TearDown() override { - manager_->Destroy(false); + manager_->MarkContextLost(); + manager_->Destroy(); manager_.reset(); GpuServiceTest::TearDown(); } @@ -263,7 +264,8 @@ // TODO(vmiura): Test GL_TEXTURE_EXTERNAL_OES & GL_TEXTURE_RECTANGLE_ARB. - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, UseDefaultTexturesFalse) { @@ -282,7 +284,8 @@ // TODO(vmiura): Test GL_TEXTURE_EXTERNAL_OES & GL_TEXTURE_RECTANGLE_ARB. - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, UseDefaultTexturesTrueES3) { @@ -299,7 +302,8 @@ EXPECT_TRUE(manager.GetDefaultTextureInfo(GL_TEXTURE_3D) != NULL); EXPECT_TRUE(manager.GetDefaultTextureInfo(GL_TEXTURE_2D_ARRAY) != NULL); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, UseDefaultTexturesFalseES3) { @@ -316,7 +320,8 @@ EXPECT_TRUE(manager.GetDefaultTextureInfo(GL_TEXTURE_3D) == NULL); EXPECT_TRUE(manager.GetDefaultTextureInfo(GL_TEXTURE_2D_ARRAY) == NULL); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, TextureUsageExt) { @@ -340,7 +345,8 @@ GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE, GL_NO_ERROR); EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_ATTACHMENT_ANGLE), texture_ref->texture()->usage()); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, Destroy) { @@ -363,7 +369,7 @@ .RetiresOnSaturation(); TestHelper::SetupTextureManagerDestructionExpectations( gl_.get(), false, false, {}, kUseDefaultTextures); - manager.Destroy(true); + manager.Destroy(); // Check that resources got freed. texture = manager.GetTexture(kClient1Id); ASSERT_TRUE(texture == NULL); @@ -515,7 +521,8 @@ EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 5, 2, 1)); // Check NPOT height on level 1 EXPECT_TRUE(manager.ValidForTarget(GL_TEXTURE_2D, 1, 2, 5, 1)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureManagerTest, AlphaLuminanceCompatibilityProfile) { @@ -707,7 +714,8 @@ } texture_ref_ = NULL; } - manager_->Destroy(false); + manager_->MarkContextLost(); + manager_->Destroy(); manager_.reset(); GpuServiceTest::TearDown(); } @@ -1037,7 +1045,8 @@ manager.MarkMipmapsGenerated(texture_ref); EXPECT_TRUE(TextureTestHelper::IsTextureComplete(texture)); EXPECT_TRUE(manager.CanRender(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, POTCubeMap) { @@ -1335,7 +1344,8 @@ gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); EXPECT_TRUE(manager.CanRender(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, FloatLinear) { @@ -1356,7 +1366,8 @@ manager.SetLevelInfo(texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_FLOAT, gfx::Rect(1, 1)); EXPECT_TRUE(manager.CanRender(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, HalfFloatNotLinear) { @@ -1385,7 +1396,8 @@ gl_.get(), error_state_.get(), &manager, texture_ref, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST, GL_NO_ERROR); EXPECT_TRUE(manager.CanRender(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, HalfFloatLinear) { @@ -1406,7 +1418,8 @@ manager.SetLevelInfo(texture_ref, GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 1, 0, GL_RGBA, GL_HALF_FLOAT_OES, gfx::Rect(1, 1)); EXPECT_TRUE(manager.CanRender(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, EGLImageExternal) { @@ -1425,7 +1438,8 @@ Texture* texture = texture_ref->texture(); EXPECT_EQ(static_cast<GLenum>(GL_TEXTURE_EXTERNAL_OES), texture->target()); EXPECT_FALSE(manager.CanGenerateMipmaps(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, DepthTexture) { @@ -1444,7 +1458,8 @@ manager.SetLevelInfo(texture_ref, GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 4, 4, 1, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, gfx::Rect()); EXPECT_FALSE(manager.CanGenerateMipmaps(texture_ref)); - manager.Destroy(false); + manager.MarkContextLost(); + manager.Destroy(); } TEST_F(TextureTest, SafeUnsafe) { @@ -2232,9 +2247,11 @@ } void TearDown() override { - texture_manager2_->Destroy(false); + texture_manager2_->MarkContextLost(); + texture_manager2_->Destroy(); texture_manager2_.reset(); - texture_manager1_->Destroy(false); + texture_manager1_->MarkContextLost(); + texture_manager1_->Destroy(); texture_manager1_.reset(); GpuServiceTest::TearDown(); }
diff --git a/third_party/WebKit/LayoutTests/FlagExpectations/enable-features=NetworkService b/third_party/WebKit/LayoutTests/FlagExpectations/enable-features=NetworkService index f9ab41c..9202452 100644 --- a/third_party/WebKit/LayoutTests/FlagExpectations/enable-features=NetworkService +++ b/third_party/WebKit/LayoutTests/FlagExpectations/enable-features=NetworkService
@@ -9,7 +9,6 @@ Bug(none) external/wpt/clear-site-data/storage.https.html [ Failure ] Bug(none) external/wpt/XMLHttpRequest/overridemimetype-blob.html [ Failure ] -Bug(none) external/wpt/XMLHttpRequest/send-accept.htm [ Failure ] Bug(none) external/wpt/beacon/headers/header-content-type.html [ Timeout ] Bug(none) external/wpt/clear-site-data/navigation.https.html [ Timeout ] Bug(none) external/wpt/content-security-policy/generic/filesystem-urls-match-filesystem.sub.html [ Failure ] @@ -18,8 +17,6 @@ Bug(none) external/wpt/cookies/secure/set-from-wss.https.sub.html [ Failure ] Bug(none) external/wpt/cssom-view/scrolling-quirks-vs-nonquirks.html [ Failure Timeout Crash ] Bug(none) external/wpt/cssom-view/scrollingElement.html [ Failure Timeout Crash ] -Bug(none) external/wpt/fetch/api/basic/accept-header.any.html [ Failure ] -Bug(none) external/wpt/fetch/api/basic/accept-header.any.worker.html [ Failure ] Bug(none) external/wpt/fetch/api/cors/cors-cookies.any.html [ Failure Pass ] Bug(none) external/wpt/html/browsers/history/the-location-interface/location-protocol-setter-non-broken-weird.html [ Failure Timeout Failure ] Bug(none) external/wpt/html/browsers/offline/appcache/workers/appcache-worker.html [ Timeout ] @@ -126,7 +123,6 @@ Bug(none) http/tests/local/serviceworker/fetch-request-body-file.html [ Crash Timeout ] Bug(none) http/tests/media/video-buffered.html [ Timeout ] Bug(none) http/tests/misc/embed-image-load-outlives-gc-without-crashing.html [ Failure Pass ] -Bug(none) http/tests/misc/image-checks-for-accept.html [ Failure Pass ] Bug(none) http/tests/misc/image-input-type-outlives-gc-without-crashing.html [ Failure Pass ] Bug(none) http/tests/misc/image-load-outlives-gc-without-crashing.html [ Failure Pass ] Bug(none) http/tests/misc/redirect-to-about-blank.html [ Timeout ]
diff --git a/third_party/WebKit/LayoutTests/TestExpectations b/third_party/WebKit/LayoutTests/TestExpectations index 8dfe3cf..a30b35a 100644 --- a/third_party/WebKit/LayoutTests/TestExpectations +++ b/third_party/WebKit/LayoutTests/TestExpectations
@@ -571,6 +571,36 @@ # ====== DevTools test migration failures until here ====== +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.3arg.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.5arg.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.9arg.basic.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.9arg.destpos.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.9arg.destsize.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcepos.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.9arg.sourcesize.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.alpha.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.animated.poster.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.broken.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.canvas.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.clip.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.composite.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.floatsource.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.negativedest.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.negativedir.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.negativesource.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.nonfinite.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.nowrap.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.null.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.path.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.self.1.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.self.2.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.svg.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.transform.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.wrongtype.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerocanvas.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerosource.image.worker.html [ Pass Timeout ] +crbug.com/779956 [ Linux ] external/wpt/offscreen-canvas/drawing-images-to-the-canvas/2d.drawImage.zerosource.worker.html [ Pass Timeout ] + crbug.com/778391 http/tests/devtools/elements/styles-3/styles-add-new-rule-tab.js [ Pass Failure ] crbug.com/778391 http/tests/devtools/elements/styles-3/styles-disable-inherited.js [ Pass Failure ] crbug.com/778391 virtual/mojo-loading/http/tests/devtools/elements/styles-3/styles-add-new-rule.js [ Pass Failure ]
diff --git a/third_party/WebKit/LayoutTests/fast/dom/Window/window-open-subresource-loading.html b/third_party/WebKit/LayoutTests/fast/dom/Window/window-open-subresource-loading.html deleted file mode 100644 index 9ec02c9..0000000 --- a/third_party/WebKit/LayoutTests/fast/dom/Window/window-open-subresource-loading.html +++ /dev/null
@@ -1,32 +0,0 @@ -<!doctype html> -<title>window.open: subresource loading</title> -<script src="../../../resources/testharness.js"></script> -<script src="../../../resources/testharnessreport.js"></script> -<script> -promise_test(() => { - const readAndReportBlobContents = () => { - const xhr = new XMLHttpRequest; - xhr.open('GET', self.blobUrl, true); - xhr.responseType = 'blob'; - xhr.onload = e => { - const reader = new FileReader; - reader.onloadend = e => { self.reportBlobContents(reader.result); }; - reader.readAsText(xhr.response); - }; - xhr.send(); - }; - - const kBlobText = 'hello i am blob'; - const target = self.open(); - const blob = new Blob([kBlobText], {type: 'text/plain'}); - const blobUrl = URL.createObjectURL(blob); - return new Promise((resolve, reject) => { - target.blobUrl = blobUrl; - target.reportBlobContents = resolve; - target.document.write('<script>(' + readAndReportBlobContents + ')();</' + - 'script>\n'); - }).then(readBlobText => { - assert_equals(readBlobText, kBlobText); - }); -}, 'Check that new blank windows can load subresources.'); -</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/document-preferredStylesheetSet-use-counter.html b/third_party/WebKit/LayoutTests/fast/dom/document-preferredStylesheetSet-use-counter.html new file mode 100644 index 0000000..dad9b77 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/document-preferredStylesheetSet-use-counter.html
@@ -0,0 +1,14 @@ +<!DOCTYPE html> +<title>document preferredStylesheetSet UseCounter</title> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<style> +</style> +<script> +test(function() { + const DocumentGetPreferredStylesheetSet = 2211; // From enums.xml + assert_false(internals.isUseCounted(document, DocumentGetPreferredStylesheetSet)); + document.preferredStylesheetSet; + assert_true(internals.isUseCounted(document, DocumentGetPreferredStylesheetSet)); +}, 'document.preferredStylesheetSet is use counted'); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-001.html b/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-001.html new file mode 100644 index 0000000..e6dd725 --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-001.html
@@ -0,0 +1,16 @@ +<!DOCTYPE html> +<title>document selectedStylesheetSet UseCounters</title> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<style> +</style> +<script> +test(function() { + const DocumentGetSelectedStylesheetSet = 2212; // From enums.xml + const DocumentSetSelectedStylesheetSet = 2213; // From enums.xml + assert_false(internals.isUseCounted(document, DocumentGetSelectedStylesheetSet)); + document.selectedStylesheetSet; + assert_true(internals.isUseCounted(document, DocumentGetSelectedStylesheetSet)); + assert_false(internals.isUseCounted(document, DocumentSetSelectedStylesheetSet)); +}, 'document get selectedStylesheetSet is use counted'); +</script>
diff --git a/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-002.html b/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-002.html new file mode 100644 index 0000000..e6ef8ad --- /dev/null +++ b/third_party/WebKit/LayoutTests/fast/dom/document-selectedStylesheetSet-use-counter-002.html
@@ -0,0 +1,16 @@ +<!DOCTYPE html> +<title>document preferredStylesheetSet UseCounter</title> +<script src="../../resources/testharness.js"></script> +<script src="../../resources/testharnessreport.js"></script> +<style> +</style> +<script> +test(function() { + const DocumentGetSelectedStylesheetSet = 2212; // From enums.xml + const DocumentSetSelectedStylesheetSet = 2213; // From enums.xml + assert_false(internals.isUseCounted(document, DocumentSetSelectedStylesheetSet)); + document.selectedStylesheetSet = ''; + assert_true(internals.isUseCounted(document, DocumentSetSelectedStylesheetSet)); + assert_false(internals.isUseCounted(document, DocumentGetSelectedStylesheetSet)); +}, 'document set selectedStylesheetSet is use counted'); +</script>
diff --git a/third_party/WebKit/Source/core/BUILD.gn b/third_party/WebKit/Source/core/BUILD.gn index d5867dc..57ee773 100644 --- a/third_party/WebKit/Source/core/BUILD.gn +++ b/third_party/WebKit/Source/core/BUILD.gn
@@ -1626,6 +1626,7 @@ "layout/ng/ng_column_layout_algorithm_test.cc", "layout/ng/ng_constraint_space_builder_test.cc", "layout/ng/ng_constraint_space_test.cc", + "layout/ng/ng_layout_test.h", "layout/ng/ng_length_utils_test.cc", "layout/ng/ng_out_of_flow_layout_part_test.cc", "layout/ng/ng_relative_utils_test.cc",
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp index b53451c0..6324572 100644 --- a/third_party/WebKit/Source/core/dom/Document.cpp +++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -4332,10 +4332,12 @@ } String Document::selectedStylesheetSet() const { + UseCounter::Count(*this, WebFeature::kDocumentGetSelectedStylesheetSet); return style_engine_->SelectedStylesheetSetName(); } void Document::setSelectedStylesheetSet(const String& a_string) { + UseCounter::Count(*this, WebFeature::kDocumentSetSelectedStylesheetSet); GetStyleEngine().SetSelectedStylesheetSetName(a_string); }
diff --git a/third_party/WebKit/Source/core/dom/Document.idl b/third_party/WebKit/Source/core/dom/Document.idl index cb91d39..0d66f0c 100644 --- a/third_party/WebKit/Source/core/dom/Document.idl +++ b/third_party/WebKit/Source/core/dom/Document.idl
@@ -163,7 +163,7 @@ // CSS Object Model (CSSOM) // https://drafts.csswg.org/cssom/#extensions-to-the-document-interface attribute DOMString? selectedStylesheetSet; - readonly attribute DOMString? preferredStylesheetSet; + [MeasureAs=DocumentGetPreferredStylesheetSet] readonly attribute DOMString? preferredStylesheetSet; readonly attribute Element? scrollingElement;
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node_test.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node_test.cc index f0a75a5..9bcbbd71 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_inline_node_test.cc
@@ -4,7 +4,6 @@ #include "core/layout/ng/inline/ng_inline_node.h" -#include "core/layout/LayoutTestHelper.h" #include "core/layout/ng/inline/ng_inline_layout_algorithm.h" #include "core/layout/ng/inline/ng_physical_line_box_fragment.h" #include "core/layout/ng/inline/ng_physical_text_fragment.h" @@ -12,6 +11,7 @@ #include "core/layout/ng/ng_constraint_space.h" #include "core/layout/ng/ng_constraint_space_builder.h" #include "core/layout/ng/ng_layout_result.h" +#include "core/layout/ng/ng_layout_test.h" #include "core/layout/ng/ng_physical_box_fragment.h" #include "core/style/ComputedStyle.h" #include "testing/gtest/include/gtest/gtest.h" @@ -67,20 +67,14 @@ void ShapeText() { NGInlineNode::ShapeText(MutableData()); } }; -class NGInlineNodeTest : public RenderingTest { +class NGInlineNodeTest : public NGLayoutTest { protected: void SetUp() override { - RenderingTest::SetUp(); - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); + NGLayoutTest::SetUp(); style_ = ComputedStyle::Create(); style_->GetFont().Update(nullptr); } - void TearDown() override { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - RenderingTest::TearDown(); - } - void SetupHtml(const char* id, String html) { SetBodyInnerHTML(html); layout_block_flow_ = ToLayoutNGBlockFlow(GetLayoutObjectByElementId(id));
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_test.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_test.cc index de00c266..4fde841f 100644 --- a/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_offset_mapping_test.cc
@@ -6,29 +6,23 @@ #include "core/dom/FirstLetterPseudoElement.h" #include "core/editing/Position.h" -#include "core/layout/LayoutTestHelper.h" #include "core/layout/LayoutTextFragment.h" #include "core/layout/ng/inline/ng_inline_node.h" #include "core/layout/ng/layout_ng_block_flow.h" +#include "core/layout/ng/ng_layout_test.h" #include "core/style/ComputedStyle.h" #include "testing/gtest/include/gtest/gtest.h" namespace blink { -class NGOffsetMappingTest : public RenderingTest { +class NGOffsetMappingTest : public NGLayoutTest { protected: void SetUp() override { - RenderingTest::SetUp(); - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); + NGLayoutTest::SetUp(); style_ = ComputedStyle::Create(); style_->GetFont().Update(nullptr); } - void TearDown() override { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - RenderingTest::TearDown(); - } - void SetupHtml(const char* id, String html) { SetBodyInnerHTML(html); layout_block_flow_ = ToLayoutNGBlockFlow(GetLayoutObjectByElementId(id));
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.cc index c9e86b9..d6f8d673 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.cc
@@ -14,16 +14,8 @@ namespace blink { -NGBaseLayoutAlgorithmTest::NGBaseLayoutAlgorithmTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); -} - -NGBaseLayoutAlgorithmTest::~NGBaseLayoutAlgorithmTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); -} - void NGBaseLayoutAlgorithmTest::SetUp() { - RenderingTest::SetUp(); + NGLayoutTest::SetUp(); EnableCompositing(); }
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.h b/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.h index 833d42b..a4f965e5 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.h +++ b/third_party/WebKit/Source/core/layout/ng/ng_base_layout_algorithm_test.h
@@ -10,6 +10,7 @@ #include "core/layout/ng/geometry/ng_logical_size.h" #include "core/layout/ng/layout_ng_block_flow.h" #include "core/layout/ng/ng_constraint_space.h" +#include "core/layout/ng/ng_layout_test.h" #include "core/layout/ng/ng_physical_box_fragment.h" #include "core/layout/ng/ng_writing_mode.h" #include "platform/text/TextDirection.h" @@ -24,11 +25,7 @@ typedef bool TestParamLayoutNG; class NGBaseLayoutAlgorithmTest : public ::testing::WithParamInterface<TestParamLayoutNG>, - public RenderingTest { - public: - NGBaseLayoutAlgorithmTest(); - ~NGBaseLayoutAlgorithmTest(); - + public NGLayoutTest { protected: void SetUp() override;
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator_test.cc index 1fd65574..70fcad4 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_child_iterator_test.cc
@@ -4,24 +4,16 @@ #include "core/layout/ng/ng_block_child_iterator.h" -#include "core/layout/LayoutTestHelper.h" #include "core/layout/ng/ng_block_break_token.h" #include "core/layout/ng/ng_block_node.h" +#include "core/layout/ng/ng_layout_test.h" #include "platform/runtime_enabled_features.h" #include "testing/gtest/include/gtest/gtest.h" namespace blink { namespace { -class NGBlockChildIteratorTest : public RenderingTest { - public: - NGBlockChildIteratorTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); - } - ~NGBlockChildIteratorTest() override { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - } -}; +using NGBlockChildIteratorTest = NGLayoutTest; TEST_F(NGBlockChildIteratorTest, NullFirstChild) { NGBlockChildIterator iterator(nullptr, nullptr);
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_node_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_node_test.cc index 362bff08..4d0315d 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_block_node_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_node_test.cc
@@ -4,18 +4,13 @@ #include "core/layout/ng/ng_block_node.h" -#include "core/layout/LayoutTestHelper.h" #include "core/layout/MinMaxSize.h" +#include "core/layout/ng/ng_layout_test.h" namespace blink { namespace { -class NGBlockNodeForTest : public RenderingTest { - public: - NGBlockNodeForTest() { RuntimeEnabledFeatures::SetLayoutNGEnabled(true); } - ~NGBlockNodeForTest() override { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - }; -}; + +using NGBlockNodeForTest = NGLayoutTest; TEST_F(NGBlockNodeForTest, ChildInlineAndBlock) { SetBodyInnerHTML(R"HTML(
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_builder_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_builder_test.cc index 65b6dc3..2b2af46e 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_builder_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_constraint_space_builder_test.cc
@@ -4,20 +4,12 @@ #include "core/layout/ng/ng_constraint_space_builder.h" -#include "core/layout/LayoutTestHelper.h" +#include "core/layout/ng/ng_layout_test.h" namespace blink { namespace { -class NGConstraintSpaceBuilderTest { - public: - NGConstraintSpaceBuilderTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); - }; - ~NGConstraintSpaceBuilderTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - }; -}; +using NGConstraintSpaceBuilderTest = NGLayoutTest; // Asserts that indefinite inline length becomes initial containing // block width for horizontal-tb inside vertical document.
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h b/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h new file mode 100644 index 0000000..1ae7e381 --- /dev/null +++ b/third_party/WebKit/Source/core/layout/ng/ng_layout_test.h
@@ -0,0 +1,22 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef NGLayoutTest_h +#define NGLayoutTest_h + +#include "core/frame/LocalFrameClient.h" +#include "core/layout/LayoutTestHelper.h" +#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" + +namespace blink { + +class NGLayoutTest : public RenderingTest, private ScopedLayoutNGForTest { + public: + NGLayoutTest(LocalFrameClient* local_frame_client = nullptr) + : RenderingTest(local_frame_client), ScopedLayoutNGForTest(true) {} +}; + +} // namespace blink + +#endif // NGLayoutTest_h
diff --git a/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc b/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc index 5d57ab4..39b97a1b 100644 --- a/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc +++ b/third_party/WebKit/Source/core/layout/ng/ng_out_of_flow_layout_part_test.cc
@@ -4,24 +4,14 @@ #include "core/layout/ng/ng_out_of_flow_layout_part.h" -#include "core/layout/LayoutTestHelper.h" #include "core/layout/ng/layout_ng_block_flow.h" #include "core/layout/ng/ng_layout_result.h" +#include "core/layout/ng/ng_layout_test.h" namespace blink { namespace { -class NGOutOfFlowLayoutPartTest : public RenderingTest { - public: - NGOutOfFlowLayoutPartTest() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); - RuntimeEnabledFeatures::SetLayoutNGFragmentCachingEnabled(true); - }; - ~NGOutOfFlowLayoutPartTest() override { - RuntimeEnabledFeatures::SetLayoutNGEnabled(false); - RuntimeEnabledFeatures::SetLayoutNGFragmentCachingEnabled(false); - }; -}; +using NGOutOfFlowLayoutPartTest = NGLayoutTest; // Fixed blocks inside absolute blocks trigger otherwise unused while loop // inside NGOutOfFlowLayoutPart::Run.
diff --git a/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc b/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc index fee4906..f214577f 100644 --- a/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc +++ b/third_party/WebKit/Source/core/paint/ng/ng_text_fragment_painter_test.cc
@@ -20,7 +20,14 @@ namespace blink { -using NGTextFragmentPainterTest = PaintControllerPaintTest; +class NGTextFragmentPainterTest : public PaintControllerPaintTest, + private ScopedLayoutNGForTest { + public: + NGTextFragmentPainterTest(LocalFrameClient* local_frame_client = nullptr) + : PaintControllerPaintTest(local_frame_client), + ScopedLayoutNGForTest(true) {} +}; + INSTANTIATE_TEST_CASE_P(All, NGTextFragmentPainterTest, ::testing::Values(0, kRootLayerScrolling)); @@ -28,18 +35,14 @@ class EnableLayoutNGForScope { public: EnableLayoutNGForScope() { - layout_ng_ = RuntimeEnabledFeatures::LayoutNGEnabled(); paint_fragments_ = RuntimeEnabledFeatures::LayoutNGPaintFragmentsEnabled(); - RuntimeEnabledFeatures::SetLayoutNGEnabled(true); RuntimeEnabledFeatures::SetLayoutNGPaintFragmentsEnabled(true); } ~EnableLayoutNGForScope() { - RuntimeEnabledFeatures::SetLayoutNGEnabled(layout_ng_); RuntimeEnabledFeatures::SetLayoutNGPaintFragmentsEnabled(paint_fragments_); } private: - bool layout_ng_; bool paint_fragments_; };
diff --git a/third_party/WebKit/public/platform/web_feature.mojom b/third_party/WebKit/public/platform/web_feature.mojom index 45474c8..7f5b754 100644 --- a/third_party/WebKit/public/platform/web_feature.mojom +++ b/third_party/WebKit/public/platform/web_feature.mojom
@@ -1740,6 +1740,9 @@ kMicrophoneDisabledByFeaturePolicyEstimate = 2208, kCameraDisabledByFeaturePolicyEstimate = 2209, kMidiDisabledByFeaturePolicy = 2210, + kDocumentGetPreferredStylesheetSet = 2211, + kDocumentGetSelectedStylesheetSet = 2212, + kDocumentSetSelectedStylesheetSet = 2213, // Add new features immediately above this line. Don't change assigned // numbers of any item, and don't reuse removed slots.
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index db575a8..d488a700 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml
@@ -16855,6 +16855,9 @@ <int value="2208" label="MicrophoneDisabledByFeaturePolicyEstimate"/> <int value="2209" label="CameraDisabledByFeaturePolicyEstimate"/> <int value="2210" label="MidiDisabledByFeaturePolicy"/> + <int value="2211" label="DocumentGetPreferredStylesheetSet"/> + <int value="2212" label="DocumentGetSelectedStylesheetSet"/> + <int value="2213" label="DocumentSetSelectedStylesheetSet"/> </enum> <enum name="FeedbackSource">
diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn index d082bf9..131bd3e 100644 --- a/ui/gl/BUILD.gn +++ b/ui/gl/BUILD.gn
@@ -442,6 +442,12 @@ data_deps = [ "//third_party/mesa:osmesa", ] + + if (use_x11) { + sources += [ "gl_context_glx_unittest.cc" ] + deps += [ "//ui/gfx/x" ] + configs += [ "//build/config/linux:x11" ] + } } # We can't run this test on real Chrome OS hardware for Ozone, so new target.
diff --git a/ui/gl/gl_context.h b/ui/gl/gl_context.h index aa1b2f0..79756a26 100644 --- a/ui/gl/gl_context.h +++ b/ui/gl/gl_context.h
@@ -159,15 +159,6 @@ GLShareGroup* share_group(); - // Create a GL context that is compatible with the given surface. - // |share_group|, if non-NULL, is a group of contexts which the - // internally created OpenGL context shares textures and other resources. - // DEPRECATED(kylechar): Use gl::init::CreateGLContext from gl_factory.h. - static scoped_refptr<GLContext> CreateGLContext( - GLShareGroup* share_group, - GLSurface* compatible_surface, - GpuPreference gpu_preference); - static bool LosesAllContextsOnContextLost(); // Returns the last GLContext made current, virtual or real.
diff --git a/ui/gl/gl_context_glx.cc b/ui/gl/gl_context_glx.cc index d66d3119..b185b2c 100644 --- a/ui/gl/gl_context_glx.cc +++ b/ui/gl/gl_context_glx.cc
@@ -230,7 +230,6 @@ reinterpret_cast<GLXDrawable>(surface->GetHandle()), static_cast<GLXContext>(context_))) { LOG(ERROR) << "Couldn't make context current with X drawable."; - Destroy(); return false; } @@ -242,7 +241,6 @@ if (!surface->OnMakeCurrent(this)) { LOG(ERROR) << "Could not make current."; - Destroy(); return false; }
diff --git a/ui/gl/gl_context_glx_unittest.cc b/ui/gl/gl_context_glx_unittest.cc new file mode 100644 index 0000000..5b0a4276 --- /dev/null +++ b/ui/gl/gl_context_glx_unittest.cc
@@ -0,0 +1,64 @@ +// Copyright 2017 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/gl/gl_context_glx.h" + +#include "base/memory/scoped_refptr.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "ui/gfx/x/x11_error_tracker.h" +#include "ui/gfx/x/x11_types.h" +#include "ui/gl/gl_surface_glx_x11.h" +#include "ui/gl/init/gl_factory.h" +#include "ui/gl/test/gl_image_test_support.h" + +#include <X11/Xlib.h> + +namespace gl { + +TEST(GLContextGLXTest, DoNotDesrtroyOnFailedMakeCurrent) { + auto* xdisplay = gfx::GetXDisplay(); + ASSERT_TRUE(xdisplay); + + gfx::X11ErrorTracker error_tracker; + + // Turn on sync behaviour, and create the window. + XSynchronize(xdisplay, True); + XSetWindowAttributes swa; + memset(&swa, 0, sizeof(swa)); + swa.background_pixmap = 0; + swa.override_redirect = True; + auto xwindow = XCreateWindow(xdisplay, DefaultRootWindow(xdisplay), 0, 0, 10, + 10, // x, y, width, height + 0, // border width + CopyFromParent, // depth + InputOutput, + CopyFromParent, // visual + CWBackPixmap | CWOverrideRedirect, &swa); + XMapWindow(xdisplay, xwindow); + + GLImageTestSupport::InitializeGL(); + auto surface = + gl::InitializeGLSurface(base::MakeRefCounted<GLSurfaceGLXX11>(xwindow)); + scoped_refptr<GLContext> context = + gl::init::CreateGLContext(nullptr, surface.get(), GLContextAttribs()); + // Verify that MakeCurrent() is successful. + ASSERT_TRUE(context->GetHandle()); + ASSERT_TRUE(context->MakeCurrent(surface.get())); + EXPECT_TRUE(context->GetHandle()); + + // Destroy the window, and turn off sync behaviour. We should get no x11 + // errors so far. + context->ReleaseCurrent(surface.get()); + XDestroyWindow(xdisplay, xwindow); + XSynchronize(xdisplay, False); + ASSERT_FALSE(error_tracker.FoundNewError()); + + // Now that the window is gone, MakeCurrent() should fail. But the context + // shouldn't be destroyed, and there should be some x11 errors captured. + EXPECT_FALSE(context->MakeCurrent(surface.get())); + ASSERT_TRUE(context->GetHandle()); + EXPECT_TRUE(error_tracker.FoundNewError()); +} + +} // namespace gl