Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/WebRequest.cpp

Issue 10252013: Implemented curl support for web requests (Closed)
Patch Set: Addressed review comments Created April 12, 2013, 1:37 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« include/AdblockPlus/WebRequest.h ('K') | « src/DefaultWebRequestDummy.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/WebRequest.cpp
===================================================================
--- a/test/WebRequest.cpp
+++ b/test/WebRequest.cpp
@@ -40,17 +40,17 @@ TEST(WebRequestTest, BadCall)
TEST(WebRequestTest, TestWebRequest)
{
TestWebRequest webRequest;
AdblockPlus::JsEngine jsEngine(0, &webRequest, 0);
jsEngine.Evaluate("_webRequest.GET('http://example.com/', {X: 'Y'}, function(result) {foo = result;} )");
ASSERT_EQ("undefined", jsEngine.Evaluate("typeof foo"));
AdblockPlus::Sleep(200);
- ASSERT_EQ(ToString(NS_OK), jsEngine.Evaluate("foo.status"));
+ ASSERT_EQ(ToString(AdblockPlus::WebRequest::NS_OK), jsEngine.Evaluate("foo.status"));
ASSERT_EQ("123", jsEngine.Evaluate("foo.responseStatus"));
ASSERT_EQ("http://example.com/\nX\nY", jsEngine.Evaluate("foo.responseText"));
ASSERT_EQ("{\"Foo\":\"Bar\"}", jsEngine.Evaluate("JSON.stringify(foo.responseHeaders)"));
}
#if defined(HAVE_CURL)
TEST(WebRequestTest, RealWebRequest)
{
@@ -59,30 +59,30 @@ TEST(WebRequestTest, RealWebRequest)
// This URL should redirect to easylist-downloads.adblockplus.org and we
// should get the actual filter list back.
jsEngine.Evaluate("_webRequest.GET('https://easylist.adblockplus.org/easylist.txt', {}, function(result) {foo = result;} )");
do
{
AdblockPlus::Sleep(200);
} while (jsEngine.Evaluate("typeof foo") == "undefined");
- ASSERT_EQ(ToString(NS_OK), jsEngine.Evaluate("foo.status"));
+ ASSERT_EQ(ToString(AdblockPlus::WebRequest::NS_OK), jsEngine.Evaluate("foo.status"));
ASSERT_EQ("200", jsEngine.Evaluate("foo.responseStatus"));
ASSERT_EQ("[Adblock Plus ", jsEngine.Evaluate("foo.responseText.substr(0, 14)"));
ASSERT_EQ("text/plain", jsEngine.Evaluate("foo.responseHeaders['content-type'].substr(0, 10)"));
Oleksandr 2013/04/16 12:02:01 Do we care if the header is "content-type" or "Con
Felix Dahlke 2013/04/16 12:21:09 HTTP headers are case insensitive, so we can easil
Wladimir Palant 2013/04/16 13:30:32 I don't think that curl lowercases header names -
Felix Dahlke 2013/04/16 14:51:37 Hm, seems I missed that then.
Wladimir Palant 2013/04/17 06:56:20 I don't quite get this suggestion, WebRequestJsObj
ASSERT_EQ("undefined", jsEngine.Evaluate("typeof foo.responseHeaders['location']"));
}
#else
TEST(WebRequestTest, DummyWebRequest)
{
AdblockPlus::DefaultWebRequest webRequest;
AdblockPlus::JsEngine jsEngine(0, &webRequest, 0);
jsEngine.Evaluate("_webRequest.GET('https://easylist.adblockplus.org/easylist.txt', {}, function(result) {foo = result;} )");
do
{
AdblockPlus::Sleep(200);
} while (jsEngine.Evaluate("typeof foo") == "undefined");
- ASSERT_EQ(ToString(NS_ERROR_FAILURE), jsEngine.Evaluate("foo.status"));
+ ASSERT_EQ(ToString(AdblockPlus::WebRequest::NS_ERROR_FAILURE), jsEngine.Evaluate("foo.status"));
ASSERT_EQ("0", jsEngine.Evaluate("foo.responseStatus"));
ASSERT_EQ("", jsEngine.Evaluate("foo.responseText"));
ASSERT_EQ("{}", jsEngine.Evaluate("JSON.stringify(foo.responseHeaders)"));
}
#endif
« include/AdblockPlus/WebRequest.h ('K') | « src/DefaultWebRequestDummy.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld