Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(231)

Side by Side Diff: ppapi/tests/test_url_loader.cc

Issue 9139076: Added bounds checks to the URLLoader prefetch buffer threshhold. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ppapi/tests/test_url_loader.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ppapi/tests/test_url_loader.h" 5 #include "ppapi/tests/test_url_loader.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string.h> 8 #include <string.h>
9 #include <string> 9 #include <string>
10 10
11 #include "ppapi/c/dev/ppb_testing_dev.h" 11 #include "ppapi/c/dev/ppb_testing_dev.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedCrossOriginRequest, filter); 110 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedCrossOriginRequest, filter);
111 RUN_TEST_FORCEASYNC_AND_NOT(TrustedCrossOriginRequest, filter); 111 RUN_TEST_FORCEASYNC_AND_NOT(TrustedCrossOriginRequest, filter);
112 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedJavascriptURLRestriction, filter); 112 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedJavascriptURLRestriction, filter);
113 RUN_TEST_FORCEASYNC_AND_NOT(TrustedJavascriptURLRestriction, filter); 113 RUN_TEST_FORCEASYNC_AND_NOT(TrustedJavascriptURLRestriction, filter);
114 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedHttpRequests, filter); 114 RUN_TEST_FORCEASYNC_AND_NOT(UntrustedHttpRequests, filter);
115 RUN_TEST_FORCEASYNC_AND_NOT(TrustedHttpRequests, filter); 115 RUN_TEST_FORCEASYNC_AND_NOT(TrustedHttpRequests, filter);
116 RUN_TEST_FORCEASYNC_AND_NOT(FollowURLRedirect, filter); 116 RUN_TEST_FORCEASYNC_AND_NOT(FollowURLRedirect, filter);
117 RUN_TEST_FORCEASYNC_AND_NOT(AuditURLRedirect, filter); 117 RUN_TEST_FORCEASYNC_AND_NOT(AuditURLRedirect, filter);
118 RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls, filter); 118 RUN_TEST_FORCEASYNC_AND_NOT(AbortCalls, filter);
119 RUN_TEST_FORCEASYNC_AND_NOT(UntendedLoad, filter); 119 RUN_TEST_FORCEASYNC_AND_NOT(UntendedLoad, filter);
120 RUN_TEST_FORCEASYNC_AND_NOT(PrefetchBufferThreshold, filter);
120 } 121 }
121 122
122 std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io, 123 std::string TestURLLoader::ReadEntireFile(pp::FileIO* file_io,
123 std::string* data) { 124 std::string* data) {
124 TestCompletionCallback callback(instance_->pp_instance(), force_async_); 125 TestCompletionCallback callback(instance_->pp_instance(), force_async_);
125 char buf[256]; 126 char buf[256];
126 int64_t offset = 0; 127 int64_t offset = 0;
127 128
128 for (;;) { 129 for (;;) {
129 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback); 130 int32_t rv = file_io->Read(offset, buf, sizeof(buf), callback);
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 std::string body; 865 std::string body;
865 std::string error = ReadEntireResponseBody(&loader, &body); 866 std::string error = ReadEntireResponseBody(&loader, &body);
866 if (!error.empty()) 867 if (!error.empty())
867 return error; 868 return error;
868 if (body != "hello\n") 869 if (body != "hello\n")
869 return ReportError("Couldn't read data", rv); 870 return ReportError("Couldn't read data", rv);
870 871
871 PASS(); 872 PASS();
872 } 873 }
873 874
875 int32_t TestURLLoader::OpenWithPrefetchBufferThreshold(int32_t lower,
876 int32_t upper) {
877 pp::URLRequestInfo request(instance_);
878 request.SetURL("test_url_loader_data/hello.txt");
879 request.SetPrefetchBufferLowerThreshold(lower);
880 request.SetPrefetchBufferUpperThreshold(upper);
881
882 return OpenUntrusted(request);
883 }
884
885 std::string TestURLLoader::TestPrefetchBufferThreshold() {
886 int32_t rv = OpenWithPrefetchBufferThreshold(-1, 1);
887 if (rv != PP_ERROR_FAILED) {
888 return ReportError("The prefetch limits contained a negative value but "
889 "the URLLoader did not fail.", rv);
890 }
891
892 rv = OpenWithPrefetchBufferThreshold(0, 1);
893 if (rv != PP_OK) {
894 return ReportError("The prefetch buffer limits were legal values but "
895 "the URLLoader failed.", rv);
896 }
897
898 rv = OpenWithPrefetchBufferThreshold(1000, 1);
899 if (rv != PP_ERROR_FAILED) {
900 return ReportError("The lower buffer value was higher than the upper but "
901 "the URLLoader did not fail.", rv);
902 }
903
904 PASS();
905 }
906
874 // TODO(viettrungluu): Add tests for Get{Upload,Download}Progress, Close 907 // TODO(viettrungluu): Add tests for Get{Upload,Download}Progress, Close
875 // (including abort tests if applicable). 908 // (including abort tests if applicable).
876
OLDNEW
« no previous file with comments | « ppapi/tests/test_url_loader.h ('k') | webkit/plugins/ppapi/ppb_url_request_info_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698