Disable the DownloadToFile API in PPAPI.
The use counter is showing pretty much zero usage of this API, so as a first step towards removing the implementation of DownloadToFile, this changes the exposed API to always fail when attempting to use it. Bug: 823522 Change-Id: Ic82280d3d203684467fa4845b255cff9a02e1e12 Reviewed-on: https://chromium-review.googlesource.com/1062705 Reviewed-by: John Abd-El-Malek <jam@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Reviewed-by: Mark Seaborn <mseaborn@chromium.org> Reviewed-by: Raymes Khoury <raymes@chromium.org> Commit-Queue: Marijn Kruisselbrink <mek@chromium.org> Cr-Commit-Position: refs/heads/master@{#561682}
This commit is contained in:

committed by
Commit Bot

parent
bbab87c12d
commit
23efe422cf
chrome/test/ppapi
components/nacl/browser
content/renderer/pepper
ppapi
api
c
cpp
nacl_irt
proxy
shared_impl
tests
@ -36,6 +36,7 @@
|
||||
#include "net/base/filename_util.h"
|
||||
#include "net/test/spawned_test_server/spawned_test_server.h"
|
||||
#include "net/test/test_data_directory.h"
|
||||
#include "ppapi/shared_impl/ppapi_features.h"
|
||||
#include "ppapi/shared_impl/ppapi_switches.h"
|
||||
#include "ui/gl/gl_switches.h"
|
||||
|
||||
@ -134,6 +135,13 @@ PPAPITestBase::PPAPITestBase() {
|
||||
}
|
||||
|
||||
void PPAPITestBase::SetUp() {
|
||||
// TODO(mek): Migrate the FileRef tests to no longer depend on StreamToFile.
|
||||
if (base::StartsWith(
|
||||
::testing::UnitTest::GetInstance()->current_test_info()->name(),
|
||||
"FileRef", base::CompareCase::SENSITIVE)) {
|
||||
scoped_feature_list_.InitAndEnableFeature(ppapi::features::kStreamToFile);
|
||||
}
|
||||
|
||||
EnablePixelOutput();
|
||||
InProcessBrowserTest::SetUp();
|
||||
}
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "base/compiler_specific.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/scoped_observer.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chrome/test/base/in_process_browser_test.h"
|
||||
#include "components/infobars/core/infobar_manager.h"
|
||||
#include "content/public/test/javascript_test_observer.h"
|
||||
@ -89,6 +90,8 @@ class PPAPITestBase : public InProcessBrowserTest {
|
||||
GURL GetTestURL(const net::EmbeddedTestServer& http_server,
|
||||
const std::string& test_case,
|
||||
const std::string& extra_params);
|
||||
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
};
|
||||
|
||||
// In-process plugin test runner. See OutOfProcessPPAPITest below for the
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "base/base_switches.h"
|
||||
#include "base/bind.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/location.h"
|
||||
#include "base/macros.h"
|
||||
@ -935,6 +936,19 @@ bool NaClProcessHost::StartPPAPIProxy(
|
||||
}
|
||||
}
|
||||
|
||||
std::string enabled_features;
|
||||
std::string disabled_features;
|
||||
base::FeatureList::GetInstance()->GetFeatureOverrides(&enabled_features,
|
||||
&disabled_features);
|
||||
if (!enabled_features.empty()) {
|
||||
args.switch_names.push_back(switches::kEnableFeatures);
|
||||
args.switch_values.push_back(enabled_features);
|
||||
}
|
||||
if (!disabled_features.empty()) {
|
||||
args.switch_names.push_back(switches::kDisableFeatures);
|
||||
args.switch_values.push_back(disabled_features);
|
||||
}
|
||||
|
||||
ppapi_host_->GetPpapiHost()->AddHostFactoryFilter(
|
||||
std::unique_ptr<ppapi::host::HostFactory>(
|
||||
NaClBrowser::GetDelegate()->CreatePpapiHostFactory(
|
||||
|
@ -131,10 +131,10 @@ TEST_F(URLRequestInfoTest, StreamToFile) {
|
||||
|
||||
EXPECT_FALSE(GetDownloadToFile());
|
||||
|
||||
EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, true));
|
||||
EXPECT_TRUE(GetDownloadToFile());
|
||||
EXPECT_FALSE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, true));
|
||||
EXPECT_FALSE(GetDownloadToFile());
|
||||
|
||||
EXPECT_TRUE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, false));
|
||||
EXPECT_FALSE(SetBooleanProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, false));
|
||||
EXPECT_FALSE(GetDownloadToFile());
|
||||
}
|
||||
|
||||
|
@ -42,9 +42,8 @@ enum PP_URLRequestProperty {
|
||||
/**
|
||||
* This corresponds to a <code>PP_Bool</code> (<code>PP_VARTYPE_BOOL</code>;
|
||||
* default=<code>PP_FALSE</code>).
|
||||
* Set this value to <code>PP_TRUE</code> if you want to download the data
|
||||
* to a file. Use PPB_URLLoader.FinishStreamingToFile() to complete the
|
||||
* download.
|
||||
* This property is no longer supported, so attempting to set it will always
|
||||
* fail.
|
||||
*/
|
||||
PP_URLREQUESTPROPERTY_STREAMTOFILE = 3,
|
||||
|
||||
|
@ -112,19 +112,14 @@ interface PPB_URLResponseInfo {
|
||||
[in] PP_URLResponseProperty property);
|
||||
|
||||
/**
|
||||
* GetBodyAsFileRef() returns a FileRef pointing to the file containing the
|
||||
* response body. This is only valid if
|
||||
* <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the
|
||||
* <code>URLRequestInfo</code> used to produce this response. This file
|
||||
* remains valid until the <code>URLLoader</code> associated with this
|
||||
* <code>URLResponseInfo</code> is closed or destroyed.
|
||||
* GetBodyAsFileRef() always returns 0, because
|
||||
* <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> is no longer supported.
|
||||
*
|
||||
* @param[in] request A <code>PP_Resource</code> corresponding to a
|
||||
* <code>URLResponseInfo</code>.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> corresponding to a <code>FileRef</code>
|
||||
* if successful, 0 if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was
|
||||
* not requested or if the <code>URLLoader</code> has not been opened yet.
|
||||
* @return 0, because <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> is no
|
||||
* longer supported.
|
||||
*/
|
||||
PP_Resource GetBodyAsFileRef(
|
||||
[in] PP_Resource response);
|
||||
|
@ -3,7 +3,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* From ppb_url_request_info.idl modified Thu Mar 28 10:19:35 2013. */
|
||||
/* From ppb_url_request_info.idl modified Thu May 17 11:28:52 2018. */
|
||||
|
||||
#ifndef PPAPI_C_PPB_URL_REQUEST_INFO_H_
|
||||
#define PPAPI_C_PPB_URL_REQUEST_INFO_H_
|
||||
@ -54,9 +54,8 @@ typedef enum {
|
||||
/**
|
||||
* This corresponds to a <code>PP_Bool</code> (<code>PP_VARTYPE_BOOL</code>;
|
||||
* default=<code>PP_FALSE</code>).
|
||||
* Set this value to <code>PP_TRUE</code> if you want to download the data
|
||||
* to a file. Use PPB_URLLoader.FinishStreamingToFile() to complete the
|
||||
* download.
|
||||
* This property is no longer supported, so attempting to set it will always
|
||||
* fail.
|
||||
*/
|
||||
PP_URLREQUESTPROPERTY_STREAMTOFILE = 3,
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/* From ppb_url_response_info.idl modified Mon Nov 14 10:36:01 2011. */
|
||||
/* From ppb_url_response_info.idl modified Thu May 17 11:28:03 2018. */
|
||||
|
||||
#ifndef PPAPI_C_PPB_URL_RESPONSE_INFO_H_
|
||||
#define PPAPI_C_PPB_URL_RESPONSE_INFO_H_
|
||||
@ -123,19 +123,14 @@ struct PPB_URLResponseInfo_1_0 {
|
||||
struct PP_Var (*GetProperty)(PP_Resource response,
|
||||
PP_URLResponseProperty property);
|
||||
/**
|
||||
* GetBodyAsFileRef() returns a FileRef pointing to the file containing the
|
||||
* response body. This is only valid if
|
||||
* <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set on the
|
||||
* <code>URLRequestInfo</code> used to produce this response. This file
|
||||
* remains valid until the <code>URLLoader</code> associated with this
|
||||
* <code>URLResponseInfo</code> is closed or destroyed.
|
||||
* GetBodyAsFileRef() always returns 0, because
|
||||
* <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> is no longer supported.
|
||||
*
|
||||
* @param[in] request A <code>PP_Resource</code> corresponding to a
|
||||
* <code>URLResponseInfo</code>.
|
||||
*
|
||||
* @return A <code>PP_Resource</code> corresponding to a <code>FileRef</code>
|
||||
* if successful, 0 if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was
|
||||
* not requested or if the <code>URLLoader</code> has not been opened yet.
|
||||
* @return 0, because <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> is no
|
||||
* longer supported.
|
||||
*/
|
||||
PP_Resource (*GetBodyAsFileRef)(PP_Resource response);
|
||||
};
|
||||
|
@ -144,14 +144,12 @@ class URLRequestInfo : public Resource {
|
||||
|
||||
/// SetStreamToFile() sets the
|
||||
/// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> (corresponding
|
||||
/// to a bool of type <code>PP_VARTYPE_BOOL</code>). The default of the
|
||||
/// property is false. Set this value to true if you want to download the
|
||||
/// data to a file. Use URL_Loader::FinishStreamingToFile() to complete
|
||||
/// the download.
|
||||
/// to a bool of type <code>PP_VARTYPE_BOOL</code>). The property is no longer
|
||||
/// supported, so this always returns false.
|
||||
///
|
||||
/// @param[in] enable A <code>bool</code> containing the property value.
|
||||
///
|
||||
/// @return true if successful, false if the parameter is invalid.
|
||||
/// @return false.
|
||||
bool SetStreamToFile(bool enable) {
|
||||
return SetProperty(PP_URLREQUESTPROPERTY_STREAMTOFILE, enable);
|
||||
}
|
||||
|
@ -44,17 +44,11 @@ class URLResponseInfo : public Resource {
|
||||
/// invalid.
|
||||
Var GetProperty(PP_URLResponseProperty property) const;
|
||||
|
||||
/// This function returns a <code>FileRef</code>
|
||||
/// pointing to the file containing the response body. This
|
||||
/// is only valid if <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was set
|
||||
/// on the <code>URLRequestInfo</code> used to produce this response. This
|
||||
/// file remains valid until the <code>URLLoader</code> associated with this
|
||||
/// This function returns an <code>is_null</code> object, as the
|
||||
/// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> is no longer supported.
|
||||
/// <code>URLResponseInfo</code> is closed or destroyed.
|
||||
///
|
||||
/// @return A <code>FileRef</code> corresponding to a
|
||||
/// <code>FileRef</code> if successful, an <code>is_null</code> object if
|
||||
/// <code>PP_URLREQUESTPROPERTY_STREAMTOFILE</code> was not requested or if
|
||||
/// the <code>URLLoader</code> has not been opened yet.
|
||||
/// @return An <code>is_null</code> object.
|
||||
FileRef GetBodyAsFileRef() const;
|
||||
|
||||
/// This function gets the <code>PP_URLRESPONSEPROPERTY_URL</code>
|
||||
|
@ -9,7 +9,9 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/waitable_event.h"
|
||||
@ -166,6 +168,12 @@ void PpapiDispatcher::OnMsgInitializeNaClDispatcher(
|
||||
settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG;
|
||||
logging::InitLogging(settings);
|
||||
|
||||
base::FeatureList::InitializeInstance(
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
||||
switches::kEnableFeatures),
|
||||
base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
||||
switches::kDisableFeatures));
|
||||
|
||||
// Tell the process-global GetInterface which interfaces it can return to the
|
||||
// plugin.
|
||||
proxy::InterfaceList::SetProcessGlobalPermissions(args.permissions);
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "ppapi/proxy/ppapi_messages.h"
|
||||
#include "ppapi/proxy/url_request_info_resource.h"
|
||||
#include "ppapi/proxy/url_response_info_resource.h"
|
||||
#include "ppapi/shared_impl/ppapi_features.h"
|
||||
#include "ppapi/shared_impl/ppapi_globals.h"
|
||||
#include "ppapi/shared_impl/url_response_info_data.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
@ -186,6 +187,9 @@ int32_t URLLoaderResource::ReadResponseBody(
|
||||
|
||||
int32_t URLLoaderResource::FinishStreamingToFile(
|
||||
scoped_refptr<TrackedCallback> callback) {
|
||||
if (!base::FeatureList::IsEnabled(features::kStreamToFile))
|
||||
return PP_ERROR_NOTSUPPORTED;
|
||||
|
||||
int32_t rv = ValidateCallback(callback);
|
||||
if (rv != PP_OK)
|
||||
return rv;
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "ppapi/proxy/url_request_info_resource.h"
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "ppapi/shared_impl/ppapi_features.h"
|
||||
#include "ppapi/shared_impl/var.h"
|
||||
#include "ppapi/thunk/enter.h"
|
||||
#include "ppapi/thunk/ppb_file_ref_api.h"
|
||||
@ -147,6 +148,8 @@ bool URLRequestInfoResource::SetBooleanProperty(
|
||||
// SetProperty() above for why.
|
||||
switch (property) {
|
||||
case PP_URLREQUESTPROPERTY_STREAMTOFILE:
|
||||
if (!base::FeatureList::IsEnabled(features::kStreamToFile))
|
||||
return false;
|
||||
data_.stream_to_file = value;
|
||||
return true;
|
||||
case PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS:
|
||||
|
@ -46,6 +46,8 @@ component("shared_impl") {
|
||||
"platform_file.cc",
|
||||
"platform_file.h",
|
||||
"ppapi_constants.h",
|
||||
"ppapi_features.cc",
|
||||
"ppapi_features.h",
|
||||
"ppapi_globals.cc",
|
||||
"ppapi_globals.h",
|
||||
"ppapi_nacl_plugin_args.cc",
|
||||
|
17
ppapi/shared_impl/ppapi_features.cc
Normal file
17
ppapi/shared_impl/ppapi_features.cc
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright 2018 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 "ppapi/shared_impl/ppapi_features.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace features {
|
||||
|
||||
// With this feature you can turn back on the deprecated StreamToFile API (which
|
||||
// lets you stream a URL request directly to a file).
|
||||
// TODO(https://crbug.com/823522): Remove the feature and flag entirely.
|
||||
const base::Feature kStreamToFile{"PPAPIStreamToFile",
|
||||
base::FEATURE_DISABLED_BY_DEFAULT};
|
||||
|
||||
} // namespace features
|
||||
} // namespace ppapi
|
19
ppapi/shared_impl/ppapi_features.h
Normal file
19
ppapi/shared_impl/ppapi_features.h
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2018 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 PPAPI_SHARED_IMPL_PPAPI_FEATURES_H_
|
||||
#define PPAPI_SHARED_IMPL_PPAPI_FEATURES_H_
|
||||
|
||||
#include "base/feature_list.h"
|
||||
#include "ppapi/shared_impl/ppapi_shared_export.h"
|
||||
|
||||
namespace ppapi {
|
||||
namespace features {
|
||||
|
||||
PPAPI_SHARED_EXPORT extern const base::Feature kStreamToFile;
|
||||
|
||||
} // namespace features
|
||||
} // namespace ppapi
|
||||
|
||||
#endif // PPAPI_SHARED_IMPL_PPAPI_FEATURES_H_
|
@ -194,22 +194,10 @@ std::string TestFileRef::TestGetName() {
|
||||
if (name != "/")
|
||||
return ReportMismatch("FileRef::GetName", name, "/");
|
||||
|
||||
pp::URLRequestInfo request(instance_);
|
||||
request.SetURL("test_url_loader_data/hello.txt");
|
||||
request.SetStreamToFile(true);
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
|
||||
pp::URLLoader loader(instance_);
|
||||
callback.WaitForResult(loader.Open(request, callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
pp::URLResponseInfo response_info(loader.GetResponseInfo());
|
||||
ASSERT_FALSE(response_info.is_null());
|
||||
ASSERT_EQ(200, response_info.GetStatusCode());
|
||||
|
||||
pp::FileRef file_ref_ext(response_info.GetBodyAsFileRef());
|
||||
pp::FileRef file_ref_ext;
|
||||
std::string result = MakeExternalFileRef(&file_ref_ext);
|
||||
if (!result.empty())
|
||||
return result;
|
||||
name = file_ref_ext.GetName().AsString();
|
||||
ASSERT_FALSE(name.empty());
|
||||
|
||||
@ -228,22 +216,10 @@ std::string TestFileRef::TestGetPath() {
|
||||
pp::FileRef file_ref_temp(file_system_temp, kTempFilePath);
|
||||
ASSERT_EQ(kTempFilePath, file_ref_temp.GetPath().AsString());
|
||||
|
||||
pp::URLRequestInfo request(instance_);
|
||||
request.SetURL("test_url_loader_data/hello.txt");
|
||||
request.SetStreamToFile(true);
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
|
||||
pp::URLLoader loader(instance_);
|
||||
callback.WaitForResult(loader.Open(request, callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
pp::URLResponseInfo response_info(loader.GetResponseInfo());
|
||||
ASSERT_FALSE(response_info.is_null());
|
||||
ASSERT_EQ(200, response_info.GetStatusCode());
|
||||
|
||||
pp::FileRef file_ref_ext(response_info.GetBodyAsFileRef());
|
||||
pp::FileRef file_ref_ext;
|
||||
std::string result = MakeExternalFileRef(&file_ref_ext);
|
||||
if (!result.empty())
|
||||
return result;
|
||||
ASSERT_TRUE(file_ref_ext.GetPath().is_undefined());
|
||||
|
||||
PASS();
|
||||
@ -269,22 +245,10 @@ std::string TestFileRef::TestGetParent() {
|
||||
pp::FileRef file_ref_with_root_parent(file_system_temp, "/foo");
|
||||
ASSERT_EQ("/", file_ref_with_root_parent.GetParent().GetPath().AsString());
|
||||
|
||||
pp::URLRequestInfo request(instance_);
|
||||
request.SetURL("test_url_loader_data/hello.txt");
|
||||
request.SetStreamToFile(true);
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
|
||||
pp::URLLoader loader(instance_);
|
||||
callback.WaitForResult(loader.Open(request, callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
pp::URLResponseInfo response_info(loader.GetResponseInfo());
|
||||
ASSERT_FALSE(response_info.is_null());
|
||||
ASSERT_EQ(200, response_info.GetStatusCode());
|
||||
|
||||
pp::FileRef file_ref_ext(response_info.GetBodyAsFileRef());
|
||||
pp::FileRef file_ref_ext;
|
||||
std::string result = MakeExternalFileRef(&file_ref_ext);
|
||||
if (!result.empty())
|
||||
return result;
|
||||
ASSERT_TRUE(file_ref_ext.GetParent().is_null());
|
||||
|
||||
PASS();
|
||||
|
@ -453,7 +453,7 @@ std::string TestURLLoader::TestFailsBogusContentLength() {
|
||||
std::string TestURLLoader::TestStreamToFile() {
|
||||
pp::URLRequestInfo request(instance_);
|
||||
request.SetURL("test_url_loader_data/hello.txt");
|
||||
request.SetStreamToFile(true);
|
||||
ASSERT_FALSE(request.SetStreamToFile(true));
|
||||
|
||||
TestCompletionCallback callback(instance_->pp_instance(), callback_type());
|
||||
|
||||
@ -470,29 +470,11 @@ std::string TestURLLoader::TestStreamToFile() {
|
||||
return "Unexpected HTTP status code";
|
||||
|
||||
pp::FileRef body(response_info.GetBodyAsFileRef());
|
||||
if (body.is_null())
|
||||
return "URLResponseInfo::GetBody returned null";
|
||||
ASSERT_TRUE(body.is_null());
|
||||
|
||||
callback.WaitForResult(loader.FinishStreamingToFile(callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
pp::FileIO reader(instance_);
|
||||
callback.WaitForResult(reader.Open(body, PP_FILEOPENFLAG_READ,
|
||||
callback.GetCallback()));
|
||||
CHECK_CALLBACK_BEHAVIOR(callback);
|
||||
ASSERT_EQ(PP_OK, callback.result());
|
||||
|
||||
std::string data;
|
||||
std::string error = ReadEntireFile(&reader, &data);
|
||||
if (!error.empty())
|
||||
return error;
|
||||
|
||||
std::string expected_body = "hello\n";
|
||||
if (data.size() != expected_body.size())
|
||||
return "ReadEntireFile returned unexpected content length";
|
||||
if (data != expected_body)
|
||||
return "ReadEntireFile returned unexpected content";
|
||||
ASSERT_EQ(PP_ERROR_NOTSUPPORTED, callback.result());
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
@ -171,8 +171,10 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
// thresholds, etc). Error checking is delayed until request opening (aka url
|
||||
// loading).
|
||||
#define ID_STR(arg) arg, #arg
|
||||
PropertyTestData test_data[] = {
|
||||
TEST_BOOL(PP_URLREQUESTPROPERTY_STREAMTOFILE),
|
||||
PropertyTestData test_data[] = {
|
||||
TEST_INT_INVALID(PP_URLREQUESTPROPERTY_STREAMTOFILE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_STREAMTOFILE),
|
||||
PP_MakeBool(PP_TRUE), PP_FALSE),
|
||||
TEST_BOOL(PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS),
|
||||
TEST_BOOL(PP_URLREQUESTPROPERTY_RECORDDOWNLOADPROGRESS),
|
||||
TEST_BOOL(PP_URLREQUESTPROPERTY_RECORDUPLOADPROGRESS),
|
||||
@ -196,8 +198,8 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
PP_MakeString("POST"), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_HEADERS),
|
||||
PP_MakeString("Accept: text/plain"), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_HEADERS),
|
||||
PP_MakeString(""), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_HEADERS), PP_MakeString(""),
|
||||
PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL),
|
||||
PP_MakeString("http://www.google.com"), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_CUSTOMREFERRERURL),
|
||||
@ -213,19 +215,16 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING),
|
||||
PP_MakeUndefined(), PP_TRUE),
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeString("My Crazy Plugin"), PP_TRUE),
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeString(""), PP_TRUE),
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeUndefined(), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_URL),
|
||||
PP_MakeUndefined(), PP_FALSE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_METHOD),
|
||||
PP_MakeUndefined(), PP_FALSE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeString("My Crazy Plugin"), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeString(""), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_CUSTOMUSERAGENT),
|
||||
PP_MakeUndefined(), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_URL), PP_MakeUndefined(),
|
||||
PP_FALSE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_METHOD), PP_MakeUndefined(),
|
||||
PP_FALSE),
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_HEADERS),
|
||||
PP_MakeString("Proxy-Authorization: Basic dXNlcjpwYXNzd29yZA=="),
|
||||
@ -250,7 +249,7 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_URL),
|
||||
PP_MakeString("::::::::::::"), PP_TRUE),
|
||||
PropertyTestData(ID_STR(PP_URLREQUESTPROPERTY_METHOD),
|
||||
PP_MakeString("INVALID"), PP_TRUE),
|
||||
PP_MakeString("INVALID"), PP_TRUE),
|
||||
PropertyTestData(
|
||||
ID_STR(PP_URLREQUESTPROPERTY_CUSTOMCONTENTTRANSFERENCODING),
|
||||
PP_MakeString("invalid"), PP_TRUE),
|
||||
@ -261,7 +260,7 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
ID_STR(PP_URLREQUESTPROPERTY_PREFETCHBUFFERLOWERTHRESHOLD),
|
||||
PP_MakeInt32(-100), PP_TRUE),
|
||||
|
||||
};
|
||||
};
|
||||
std::string error;
|
||||
|
||||
PP_Resource url_request = ppb_url_request_interface_->Create(
|
||||
@ -281,7 +280,6 @@ std::string TestURLRequest::TestSetProperty() {
|
||||
error = std::string("Setting property ") +
|
||||
test_data[i].property_name + " to " + var.DebugString() +
|
||||
" did not return " + (test_data[i].expected_value ? "True" : "False");
|
||||
error = test_data[i].property_name;
|
||||
}
|
||||
ppb_var_interface_->Release(test_data[i].var);
|
||||
}
|
||||
@ -452,9 +450,9 @@ std::string TestURLRequest::TestStress() {
|
||||
url_request_info[i])) {
|
||||
error = "IsURLRequestInfo() failed";
|
||||
} else if (PP_FALSE == ppb_url_request_interface_->SetProperty(
|
||||
url_request_info[i],
|
||||
PP_URLREQUESTPROPERTY_STREAMTOFILE,
|
||||
PP_MakeBool(PP_FALSE))) {
|
||||
url_request_info[i],
|
||||
PP_URLREQUESTPROPERTY_FOLLOWREDIRECTS,
|
||||
PP_MakeBool(PP_TRUE))) {
|
||||
error = "SetProperty() failed";
|
||||
}
|
||||
if (!error.empty()) {
|
||||
|
Reference in New Issue
Block a user