summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 22:31:35 +0000
committerbrettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-08 22:31:35 +0000
commit71e5874e3bea5a8adb67310e717bcf34ac9d9e65 (patch)
tree9b42c0fb48224ba6f230f7a862fb713b77f17f03 /ppapi
parent73006d2d5b0e9fe0a56b8fc9d98ee6e5e2b8d361 (diff)
downloadchromium_src-71e5874e3bea5a8adb67310e717bcf34ac9d9e65.zip
chromium_src-71e5874e3bea5a8adb67310e717bcf34ac9d9e65.tar.gz
chromium_src-71e5874e3bea5a8adb67310e717bcf34ac9d9e65.tar.bz2
* Add follow_redirects_ field to pepper::URLRequestInfo, follow_redirects() accessor, modified SetProperty to support this
* Add status_text_, redirect_url_ fields to pepper::URLResponseInfo, modified GetProperty to return these * Add URL redirect auditing to pepper::URLLoader. BUG=49790 BUG=51345 TEST=ui_tests --gtest_filter=PPAPI* Review=http://codereview.chromium.org/4394003/show git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65443 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/tests/test_url_loader.cc32
-rw-r--r--ppapi/tests/test_url_loader.h1
2 files changed, 33 insertions, 0 deletions
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index b1cdd6f..3203f39 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -38,6 +38,7 @@ void TestURLLoader::RunTest() {
RUN_TEST(IgnoresBogusContentLength);
RUN_TEST(SameOriginRestriction);
RUN_TEST(StreamToFile);
+ RUN_TEST(AuditURLRedirect);
}
std::string TestURLLoader::ReadEntireFile(pp::FileIO_Dev* file_io,
@@ -255,4 +256,35 @@ std::string TestURLLoader::TestSameOriginRestriction() {
return "";
}
+// This test should cause a redirect and ensure that the loader runs
+// the callback, rather than following the redirect.
+std::string TestURLLoader::TestAuditURLRedirect() {
+ pp::URLRequestInfo_Dev request;
+ // This path will cause the server to return a 301 redirect.
+ request.SetURL("/server-redirect?www.google.com");
+ request.SetFollowRedirects(false);
+
+ TestCompletionCallback callback;
+
+ pp::URLLoader_Dev loader(*instance_);
+ int32_t rv = loader.Open(request, callback);
+ if (rv == PP_ERROR_WOULDBLOCK)
+ rv = callback.WaitForResult();
+ if (rv != PP_OK)
+ return ReportError("URLLoader::Open", rv);
+
+ // Checks that the response indicates a redirect, and that the URL
+ // is correct.
+ pp::URLResponseInfo_Dev response_info(loader.GetResponseInfo());
+ if (response_info.is_null())
+ return "URLLoader::GetResponseInfo returned null";
+ int32_t status_code = response_info.GetStatusCode();
+ if (status_code != 301)
+ return "Response status should be 301";
+ if (response_info.GetRedirectURL().AsString() != "www.google.com")
+ return "Redirect URL should be www.google.com";
+
+ return "";
+}
+
// TODO(darin): Add a test for GrantUniversalAccess.
diff --git a/ppapi/tests/test_url_loader.h b/ppapi/tests/test_url_loader.h
index 9664508..681016d 100644
--- a/ppapi/tests/test_url_loader.h
+++ b/ppapi/tests/test_url_loader.h
@@ -39,6 +39,7 @@ class TestURLLoader : public TestCase {
std::string TestIgnoresBogusContentLength();
std::string TestStreamToFile();
std::string TestSameOriginRestriction();
+ std::string TestAuditURLRedirect();
};
#endif // PAPPI_TESTS_TEST_URL_LOADER_H_