summaryrefslogtreecommitdiffstats
path: root/webkit/support/weburl_loader_mock_factory.cc
diff options
context:
space:
mode:
authorviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-10 21:28:05 +0000
committerviettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-10 21:28:05 +0000
commitbfea4f019c41e9e9327c0b8b07526bed8b1f3e89 (patch)
tree3c351fc581f532b32e39a0b2713efe754497d856 /webkit/support/weburl_loader_mock_factory.cc
parent3d7c43f861956c50ff4d048601e9ebfcc139c9f7 (diff)
downloadchromium_src-bfea4f019c41e9e9327c0b8b07526bed8b1f3e89.zip
chromium_src-bfea4f019c41e9e9327c0b8b07526bed8b1f3e89.tar.gz
chromium_src-bfea4f019c41e9e9327c0b8b07526bed8b1f3e89.tar.bz2
Add WebURLLoaderMockFactory::GetLastHandledAsynchronousRequest.
This provides a way of getting the last request that was actually (mock) served, so that WebKit unit tests can, e.g., inspect headers that were "actually" sent out. BUG=http://crbug.com/134615 and https://bugs.webkit.org/show_bug.cgi?id=90893 TEST=see WebKit bug (forthcoming WebKit unit test) Review URL: https://chromiumcodereview.appspot.com/10735037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@145960 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/support/weburl_loader_mock_factory.cc')
-rw-r--r--webkit/support/weburl_loader_mock_factory.cc8
1 files changed, 8 insertions, 0 deletions
diff --git a/webkit/support/weburl_loader_mock_factory.cc b/webkit/support/weburl_loader_mock_factory.cc
index ccf3891..b3d3fdd 100644
--- a/webkit/support/weburl_loader_mock_factory.cc
+++ b/webkit/support/weburl_loader_mock_factory.cc
@@ -61,6 +61,7 @@ void WebURLLoaderMockFactory::UnregisterAllURLs() {
}
void WebURLLoaderMockFactory::ServeAsynchronousRequests() {
+ last_handled_asynchronous_request_.reset();
// Serving a request might trigger more requests, so we cannot iterate on
// pending_loaders_ as it might get modified.
while (!pending_loaders_.empty()) {
@@ -70,6 +71,7 @@ void WebURLLoaderMockFactory::ServeAsynchronousRequests() {
WebURLResponse response;
WebURLError error;
WebData data;
+ last_handled_asynchronous_request_ = request;
LoadRequest(request, &response, &error, &data);
// Follow any redirects while the loader is still active.
while (response.httpStatusCode() >= 300 &&
@@ -77,6 +79,7 @@ void WebURLLoaderMockFactory::ServeAsynchronousRequests() {
WebURLRequest newRequest = loader->ServeRedirect(response);
if (!IsPending(loader) || loader->isDeferred())
break;
+ last_handled_asynchronous_request_ = newRequest;
LoadRequest(newRequest, &response, &error, &data);
}
// Serve the request if the loader is still active.
@@ -87,6 +90,11 @@ void WebURLLoaderMockFactory::ServeAsynchronousRequests() {
}
}
+WebKit::WebURLRequest
+WebURLLoaderMockFactory::GetLastHandledAsynchronousRequest() {
+ return last_handled_asynchronous_request_;
+}
+
bool WebURLLoaderMockFactory::IsMockedURL(const WebKit::WebURL& url) {
return url_to_reponse_info_.find(url) != url_to_reponse_info_.end();
}