summaryrefslogtreecommitdiffstats
path: root/ppapi/tests/test_url_loader.cc
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 21:48:32 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-16 21:48:32 +0000
commit11c872189721c56a4a0801a58f8d4a250a9b4914 (patch)
tree41e5c9e876503711bfc0366f6a3528c513983c67 /ppapi/tests/test_url_loader.cc
parentc9fcaecb9eb89955f6f9602d4fd73d15b3fe6420 (diff)
downloadchromium_src-11c872189721c56a4a0801a58f8d4a250a9b4914.zip
chromium_src-11c872189721c56a4a0801a58f8d4a250a9b4914.tar.gz
chromium_src-11c872189721c56a4a0801a58f8d4a250a9b4914.tar.bz2
Patch to fix problems with PPB_URLLoader_Impl and PPAPITests.URLLoader. The cross-origin test doesn't properly check for an error, and the custom-referrer change broke cross-origin requests as a result. Also, there was confusion with some errors being reported as PP_ERROR_FAILED and others as PP_ERROR_NOACCESS. After conversations with WebKit folks, it seems unlikely that a consistent system of error codes can be added, so instead, have PPB_URLLoader_Impl::didFail report PP_ERROR_NOACCESS for unknown error domains (WebKit) and switch on net::kErrorDomain errors from our lower level WebURLLoader.
Review URL: http://codereview.chromium.org/7046091 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_url_loader.cc')
-rw-r--r--ppapi/tests/test_url_loader.cc20
1 files changed, 17 insertions, 3 deletions
diff --git a/ppapi/tests/test_url_loader.cc b/ppapi/tests/test_url_loader.cc
index f559507..8fda286 100644
--- a/ppapi/tests/test_url_loader.cc
+++ b/ppapi/tests/test_url_loader.cc
@@ -11,11 +11,13 @@
#include "ppapi/c/dev/ppb_file_io_dev.h"
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/c/dev/ppb_url_util_dev.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_url_loader.h"
#include "ppapi/cpp/dev/file_io_dev.h"
#include "ppapi/cpp/dev/file_ref_dev.h"
#include "ppapi/cpp/dev/file_system_dev.h"
+#include "ppapi/cpp/dev/url_util_dev.h"
#include "ppapi/cpp/instance.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/url_loader.h"
@@ -271,9 +273,21 @@ std::string TestURLLoader::TestSameOriginRestriction() {
}
std::string TestURLLoader::TestCrossOriginRequest() {
+ // Get the document URL and use it to construct a URL that will be
+ // considered cross-origin by the WebKit access control code, and yet be
+ // reachable by the test server.
+ PP_URLComponents_Dev components;
+ pp::Var pp_document_url = pp::URLUtil_Dev::Get()->GetDocumentURL(
+ *instance_, &components);
+ std::string document_url = pp_document_url.AsString();
+ // Replace "127.0.0.1" with "localhost".
+ if (document_url.find("127.0.0.1") == std::string::npos)
+ return "Can't construct a cross-origin URL";
+ std::string cross_origin_url = document_url.replace(
+ components.host.begin, components.host.len, "localhost");
+
pp::URLRequestInfo request(instance_);
- // Create a URL that will be considered to be a different origin.
- request.SetURL("http://127.0.0.1/test_url_loader_data/hello.txt");
+ request.SetURL(cross_origin_url);
request.SetAllowCrossOriginRequests(true);
TestCompletionCallback callback(instance_->pp_instance());
@@ -284,7 +298,7 @@ std::string TestURLLoader::TestCrossOriginRequest() {
rv = callback.WaitForResult();
// We expect success since we allowed a cross-origin request.
- if (rv == PP_ERROR_NOACCESS)
+ if (rv != PP_OK)
return ReportError("URLLoader::Open()", rv);
PASS();