Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
=================================================================== |
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
@@ -13,16 +13,17 @@ |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
package org.adblockplus.libadblockplus.tests; |
import org.adblockplus.android.AndroidWebRequest; |
+import org.adblockplus.libadblockplus.FilterEngine; |
import org.adblockplus.libadblockplus.JsValue; |
import org.adblockplus.libadblockplus.ServerResponse; |
import org.junit.Test; |
public class AndroidWebRequestTest extends BaseJsTest |
{ |
@Override |
@@ -63,23 +64,27 @@ |
jsEngine.evaluate("foo.responseText.substr(0, 14)").asString()); |
JsValue jsHeaders = jsEngine.evaluate("foo.responseHeaders"); |
assertNotNull(jsHeaders); |
assertFalse(jsHeaders.isUndefined()); |
assertFalse(jsHeaders.isNull()); |
assertTrue(jsHeaders.isObject()); |
assertEquals( |
"text/plain", |
- jsEngine.evaluate("foo.responseHeaders['Content-Type'].substr(0,10)").asString()); |
+ jsEngine.evaluate("foo.responseHeaders['content-type'].substr(0,10)").asString()); |
assertTrue(jsEngine.evaluate("foo.responseHeaders['location']").isUndefined()); |
} |
@Test |
public void testXMLHttpRequest() |
{ |
+ // creating not used anywhere FilterEngine object is not as useless as it seems: |
+ // it loads compat.js JsEngine to add XMLHttpRequest class support |
+ new FilterEngine(jsEngine); |
+ |
jsEngine.evaluate( |
"var result;\n" + |
"var request = new XMLHttpRequest();\n" + |
"request.open('GET', 'https://easylist-downloads.adblockplus.org/easylist.txt');\n" + |
"request.setRequestHeader('X', 'Y');\n" + |
"request.setRequestHeader('X2', 'Y2');\n" + |
"request.overrideMimeType('text/plain');\n" + |
"request.addEventListener('load',function() {result=request.responseText;}, false);\n" + |