OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 jsEngine->Evaluate("_webRequest.GET('https://easylist-downloads.adblockplus.or
g/easylist.txt', {}, function(result) {foo = result;} )"); | 82 jsEngine->Evaluate("_webRequest.GET('https://easylist-downloads.adblockplus.or
g/easylist.txt', {}, function(result) {foo = result;} )"); |
83 do | 83 do |
84 { | 84 { |
85 AdblockPlus::Sleep(200); | 85 AdblockPlus::Sleep(200); |
86 } while (jsEngine->Evaluate("this.foo")->IsUndefined()); | 86 } while (jsEngine->Evaluate("this.foo")->IsUndefined()); |
87 ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'
].substr(0, 10)")->AsString()); | 87 ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'
].substr(0, 10)")->AsString()); |
88 ASSERT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status")->As
Int()); | 88 ASSERT_EQ(AdblockPlus::WebRequest::NS_OK, jsEngine->Evaluate("foo.status")->As
Int()); |
89 ASSERT_EQ(200, jsEngine->Evaluate("foo.responseStatus")->AsInt()); | 89 ASSERT_EQ(200, jsEngine->Evaluate("foo.responseStatus")->AsInt()); |
90 ASSERT_EQ("[Adblock Plus ", jsEngine->Evaluate("foo.responseText.substr(0, 14)
")->AsString()); | 90 ASSERT_EQ("[Adblock Plus ", jsEngine->Evaluate("foo.responseText.substr(0, 14)
")->AsString()); |
91 ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'
].substr(0, 10)")->AsString()); | 91 ASSERT_EQ("text/plain", jsEngine->Evaluate("foo.responseHeaders['content-type'
].substr(0, 10)")->AsString()); |
| 92 #if defined(HAVE_CURL) |
| 93 ASSERT_EQ("gzip", jsEngine->Evaluate("foo.responseHeaders['content-encoding'].
substr(0, 4)")->AsString()); |
| 94 #endif |
92 ASSERT_TRUE(jsEngine->Evaluate("foo.responseHeaders['location']")->IsUndefined
()); | 95 ASSERT_TRUE(jsEngine->Evaluate("foo.responseHeaders['location']")->IsUndefined
()); |
93 } | 96 } |
94 | 97 |
95 TEST_F(DefaultWebRequestTest, XMLHttpRequest) | 98 TEST_F(DefaultWebRequestTest, XMLHttpRequest) |
96 { | 99 { |
97 AdblockPlus::FilterEngine filterEngine(jsEngine); | 100 AdblockPlus::FilterEngine filterEngine(jsEngine); |
98 | 101 |
99 jsEngine->Evaluate("\ | 102 jsEngine->Evaluate("\ |
100 var result;\ | 103 var result;\ |
101 var request = new XMLHttpRequest();\ | 104 var request = new XMLHttpRequest();\ |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 { | 150 { |
148 AdblockPlus::Sleep(200); | 151 AdblockPlus::Sleep(200); |
149 } while (jsEngine->Evaluate("result")->IsUndefined()); | 152 } while (jsEngine->Evaluate("result")->IsUndefined()); |
150 ASSERT_EQ(AdblockPlus::WebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("reque
st.channel.status")->AsInt()); | 153 ASSERT_EQ(AdblockPlus::WebRequest::NS_ERROR_FAILURE, jsEngine->Evaluate("reque
st.channel.status")->AsInt()); |
151 ASSERT_EQ(0, jsEngine->Evaluate("request.status")->AsInt()); | 154 ASSERT_EQ(0, jsEngine->Evaluate("request.status")->AsInt()); |
152 ASSERT_EQ("error", jsEngine->Evaluate("result")->AsString()); | 155 ASSERT_EQ("error", jsEngine->Evaluate("result")->AsString()); |
153 ASSERT_TRUE(jsEngine->Evaluate("request.getResponseHeader('Content-Type')")->I
sNull()); | 156 ASSERT_TRUE(jsEngine->Evaluate("request.getResponseHeader('Content-Type')")->I
sNull()); |
154 } | 157 } |
155 | 158 |
156 #endif | 159 #endif |
OLD | NEW |