NativeFileSystem was renamed to FileSystemAccess.

Also, NativeFileSystem origin trial was removed.

Chromium changes:

https://source.chromium.org/chromium/chromium/src/+/07ecb97fd6498002303f162d9e6cc5f248599eff

commit 07ecb97fd6498002303f162d9e6cc5f248599eff
Author: Austin Sullivan <asully@chromium.org>
Date:   Fri Jan 8 15:16:17 2021 +0000

    Rename native_file_system -> file_system_access part 3/x.

    This finishes renaming in blink, with the exception of web platform
    tests.

    Renames "NativeFileSystem" to FileSystemAccess or FileSystem.
    Generally, NativeFileSystem is renamed to FileSystemAccess.
    In cases where IDL exposes something as "FileSystem", NativeFileSystem
    is renamed to "FileSystem".

    Bug: 1110509

https://source.chromium.org/chromium/chromium/src/+/9926254ea8d51ce3845d468262eb5cfa5020754f

commit 9926254ea8d51ce3845d468262eb5cfa5020754f
Author: Austin Sullivan <asully@chromium.org>
Date:   Fri Jan 8 16:48:02 2021 +0000

    [FSA] Remove NativeFileSystem2 origin trial

    The origin trial is no longer needed, since the feature has already
    shipped.

    This change was originally proposed in this refactor [1], but was split
    into another CL.

    [1] https://crrev.com/c/2601576

    Bug: 1110509
This commit is contained in:
mkarolin
2021-02-04 23:52:53 -05:00
parent 08ae20ee59
commit 21aefaac5b
5 changed files with 67 additions and 167 deletions
@@ -22,7 +22,6 @@ bool IsTrialDisabledInBrave(const StringView& trial_name) {
// When updating also update the array in the overload below.
static const char* const kBraveDisabledTrialNames[] = {
"DigitalGoods",
"NativeFileSystem2",
"SignedExchangeSubresourcePrefetch",
"SubresourceWebBundles",
};
@@ -39,9 +38,8 @@ bool IsTrialDisabledInBrave(const StringView& trial_name) {
bool IsTrialDisabledInBrave(OriginTrialFeature feature) {
// When updating also update the array in the overload above.
static const std::array<OriginTrialFeature, 4> kBraveDisabledTrialFeatures = {
static const std::array<OriginTrialFeature, 3> kBraveDisabledTrialFeatures = {
OriginTrialFeature::kDigitalGoods,
OriginTrialFeature::kNativeFileSystem,
OriginTrialFeature::kSignedExchangeSubresourcePrefetch,
OriginTrialFeature::kSubresourceWebBundles,
};
+3 -1
View File
@@ -21,7 +21,9 @@ SetRuntimeFeaturesDefaultsBeforeBlinkInitialization() {
// These features don't have dedicated WebRuntimeFeatures wrappers.
blink::WebRuntimeFeatures::EnableFeatureFromString("DigitalGoods", false);
blink::WebRuntimeFeatures::EnableFeatureFromString("NativeFileSystem", false);
blink::WebRuntimeFeatures::EnableFeatureFromString("FileSystemAccess", false);
blink::WebRuntimeFeatures::EnableFeatureFromString(
"FileSystemAccessAPIExperimental", false);
}
BraveContentRendererClient::~BraveContentRendererClient() = default;
+1 -1
View File
@@ -10,7 +10,7 @@ source_set("browser_tests") {
sources = [
"digital_goods_api_browsertest.cc",
"native_file_system_api_browsertest.cc",
"file_system_access_browsertest.cc",
"subresource_web_bundles_browsertest.cc",
]
@@ -0,0 +1,62 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/path_service.h"
#include "base/strings/string_util.h"
#include "brave/common/brave_paths.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
class FileSystemAccessBrowserTest : public InProcessBrowserTest {
public:
FileSystemAccessBrowserTest()
: https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {
brave::RegisterPathProvider();
base::FilePath test_data_dir;
base::PathService::Get(brave::DIR_TEST_DATA, &test_data_dir);
https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_.ServeFilesFromDirectory(test_data_dir);
}
~FileSystemAccessBrowserTest() override = default;
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
EXPECT_TRUE(https_server_.Start());
// Map all hosts to localhost.
host_resolver()->AddRule("*", "127.0.0.1");
}
content::WebContents* web_contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
content::RenderFrameHost* main_frame() {
return web_contents()->GetMainFrame();
}
protected:
net::EmbeddedTestServer https_server_;
};
IN_PROC_BROWSER_TEST_F(FileSystemAccessBrowserTest, FilePicker) {
const GURL url = https_server_.GetURL("/simple.html");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
auto result = content::EvalJs(main_frame(), "self.showOpenFilePicker()");
EXPECT_TRUE(result.error.find("self.showOpenFilePicker is not a function") !=
std::string::npos)
<< result.error;
}
@@ -1,162 +0,0 @@
/* Copyright (c) 2020 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "base/path_service.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "brave/common/brave_paths.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/embedder_support/switches.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/url_loader_interceptor.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "url/gurl.h"
class NativeFileSystemAPIBrowserTest : public InProcessBrowserTest {
public:
NativeFileSystemAPIBrowserTest()
: https_server_(net::EmbeddedTestServer::TYPE_HTTPS) {
brave::RegisterPathProvider();
base::FilePath test_data_dir;
base::PathService::Get(brave::DIR_TEST_DATA, &test_data_dir);
https_server_.SetSSLConfig(net::EmbeddedTestServer::CERT_OK);
https_server_.ServeFilesFromDirectory(test_data_dir);
}
~NativeFileSystemAPIBrowserTest() override = default;
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
EXPECT_TRUE(https_server_.Start());
// Map all hosts to localhost.
host_resolver()->AddRule("*", "127.0.0.1");
}
content::WebContents* web_contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
content::RenderFrameHost* main_frame() {
return web_contents()->GetMainFrame();
}
protected:
net::EmbeddedTestServer https_server_;
};
IN_PROC_BROWSER_TEST_F(NativeFileSystemAPIBrowserTest, FilePicker) {
const GURL url = https_server_.GetURL("/simple.html");
ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), url));
auto result = content::EvalJs(main_frame(), "self.showOpenFilePicker()");
EXPECT_TRUE(result.error.find("self.showOpenFilePicker is not a function") !=
std::string::npos)
<< result.error;
}
namespace {
constexpr char kOriginTrialTestPublicKey[] =
"dRCs+TocuKkocNKa0AtZ4awrt9XKH2SQCI6o4FY6BNA=";
const char kTestHeaders[] = "HTTP/1.1 200 OK\nContent-type: text/html\n\n";
constexpr char kOriginTrialTestHostname[] = "https://localhost";
constexpr char kOriginTrialPage[] = "page.html";
// tools/origin_trials/generate_token.py \
// --expire-days 3650 https://localhost NativeFileSystem2
constexpr char kOriginTrialToken[] =
"AzOJFCOVN9n5+fKf7X2W8DpbQzs54hnLqPxDGPpm/XyfBZTgOybwDGNWhKMUVPf1qn3t7LTZA3"
"LlRBlFPbMn9AIAAABZeyJvcmlnaW4iOiAiaHR0cHM6Ly9sb2NhbGhvc3Q6NDQzIiwgImZlYXR1"
"cmUiOiAiTmF0aXZlRmlsZVN5c3RlbTIiLCAiZXhwaXJ5IjogMTkyMDkyMzIxOX0=";
constexpr char kOriginTrialTestResponseTemplate[] = R"(
<html>
<head>
<title>Native File System Origin Trial Test</title>
META_TAG
</head>
</html>
)";
std::string GetContentForURL(const std::string& url) {
if (!base::EndsWith(url, kOriginTrialPage, base::CompareCase::SENSITIVE))
return std::string();
std::string response = kOriginTrialTestResponseTemplate;
std::string meta_tag =
base::StrCat({R"(<meta http-equiv="origin-trial" content=")",
kOriginTrialToken, R"(">)"});
base::ReplaceFirstSubstringAfterOffset(&response, 0, "META_TAG", meta_tag);
return response;
}
bool URLLoaderInterceptorCallback(
content::URLLoaderInterceptor::RequestParams* params) {
content::URLLoaderInterceptor::WriteResponse(
kTestHeaders, GetContentForURL(params->url_request.url.path()),
params->client.get());
return true;
}
} // namespace
class NativeFileSystemOriginTrialBrowserTest : public InProcessBrowserTest {
public:
NativeFileSystemOriginTrialBrowserTest() = default;
~NativeFileSystemOriginTrialBrowserTest() override = default;
void SetUpDefaultCommandLine(base::CommandLine* command_line) override {
InProcessBrowserTest::SetUpDefaultCommandLine(command_line);
command_line->AppendSwitchASCII(embedder_support::kOriginTrialPublicKey,
kOriginTrialTestPublicKey);
}
void SetUpOnMainThread() override {
InProcessBrowserTest::SetUpOnMainThread();
// We use a URLLoaderInterceptor, rather than the EmbeddedTestServer, since
// the origin trial token in the response is associated with a fixed
// origin, whereas EmbeddedTestServer serves content on a random port.
url_loader_interceptor_ = std::make_unique<content::URLLoaderInterceptor>(
base::BindRepeating(&URLLoaderInterceptorCallback));
}
void TearDownOnMainThread() override {
url_loader_interceptor_.reset();
InProcessBrowserTest::TearDownOnMainThread();
}
content::WebContents* web_contents() {
return browser()->tab_strip_model()->GetActiveWebContents();
}
content::RenderFrameHost* main_frame() {
return web_contents()->GetMainFrame();
}
protected:
std::unique_ptr<content::URLLoaderInterceptor> url_loader_interceptor_;
};
IN_PROC_BROWSER_TEST_F(NativeFileSystemOriginTrialBrowserTest, OriginTrial) {
ASSERT_TRUE(ui_test_utils::NavigateToURL(
browser(), GURL(base::JoinString(
{kOriginTrialTestHostname, kOriginTrialPage}, "/"))));
auto result = content::EvalJs(main_frame(), "self.showOpenFilePicker()");
EXPECT_TRUE(result.error.find("self.showOpenFilePicker is not a function") !=
std::string::npos)
<< result.error;
}