Index: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
diff --git a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
index 428268dfff62741f46ce14470614dd74b81aef7c..53789919e3a3f85e1756652d1eebf8d066b2da87 100644 |
--- a/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
+++ b/libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java |
@@ -25,87 +25,87 @@ import org.junit.Test; |
public class AndroidWebRequestTest extends BaseJsTest |
{ |
- @Override |
- protected void setUp() throws Exception |
- { |
- super.setUp(); |
+ @Override |
+ protected void setUp() throws Exception |
+ { |
+ super.setUp(); |
- jsEngine.setWebRequest(new AndroidWebRequest()); |
- } |
+ jsEngine.setWebRequest(new AndroidWebRequest()); |
+ } |
- @Test |
- public void testRealWebRequest() |
+ @Test |
+ public void testRealWebRequest() |
+ { |
+ // This URL should redirect to easylist-downloads.adblockplus.org and we |
+ // should get the actual filter list back. |
+ jsEngine.evaluate( |
+ "_webRequest.GET('https://easylist-downloads.adblockplus.org/easylist.txt', {}, " + |
+ "function(result) {foo = result;} )"); |
+ do |
{ |
- // This URL should redirect to easylist-downloads.adblockplus.org and we |
- // should get the actual filter list back. |
- jsEngine.evaluate( |
- "_webRequest.GET('https://easylist-downloads.adblockplus.org/easylist.txt', {}, " + |
- "function(result) {foo = result;} )"); |
- do |
- { |
- try |
- { |
- Thread.sleep(200); |
- } catch (InterruptedException e) |
- { |
- throw new RuntimeException(e); |
- } |
- } while (jsEngine.evaluate("this.foo").isUndefined()); |
+ try |
+ { |
+ Thread.sleep(200); |
+ } catch (InterruptedException e) |
+ { |
+ throw new RuntimeException(e); |
+ } |
+ } while (jsEngine.evaluate("this.foo").isUndefined()); |
- String response = jsEngine.evaluate("foo.responseText").asString(); |
- assertNotNull(response); |
- assertEquals( |
- ServerResponse.NsStatus.OK.getStatusCode(), |
- jsEngine.evaluate("foo.status").asLong()); |
- assertEquals(200l, jsEngine.evaluate("foo.responseStatus").asLong()); |
- assertEquals( |
- "[Adblock Plus ", |
- 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()); |
- assertTrue(jsEngine.evaluate("foo.responseHeaders['location']").isUndefined()); |
- } |
+ String response = jsEngine.evaluate("foo.responseText").asString(); |
+ assertNotNull(response); |
+ assertEquals( |
+ ServerResponse.NsStatus.OK.getStatusCode(), |
+ jsEngine.evaluate("foo.status").asLong()); |
+ assertEquals(200l, jsEngine.evaluate("foo.responseStatus").asLong()); |
+ assertEquals( |
+ "[Adblock Plus ", |
+ 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()); |
+ assertTrue(jsEngine.evaluate("foo.responseHeaders['location']").isUndefined()); |
+ } |
- @Test |
- public void testXMLHttpRequest() |
- { |
- 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" + |
- "request.addEventListener('error',function() {result='error';}, false);\n" + |
- "request.send(null);"); |
+ @Test |
+ public void testXMLHttpRequest() |
+ { |
+ 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" + |
+ "request.addEventListener('error',function() {result='error';}, false);\n" + |
+ "request.send(null);"); |
- do |
- { |
- try |
- { |
- Thread.sleep(200); |
- } catch (InterruptedException e) |
- { |
- throw new RuntimeException(e); |
- } |
- } while (jsEngine.evaluate("result").isUndefined()); |
+ do |
+ { |
+ try |
+ { |
+ Thread.sleep(200); |
+ } catch (InterruptedException e) |
+ { |
+ throw new RuntimeException(e); |
+ } |
+ } while (jsEngine.evaluate("result").isUndefined()); |
- assertEquals( |
- ServerResponse.NsStatus.OK.getStatusCode(), |
- jsEngine.evaluate("request.channel.status").asLong()); |
+ assertEquals( |
+ ServerResponse.NsStatus.OK.getStatusCode(), |
+ jsEngine.evaluate("request.channel.status").asLong()); |
- assertEquals(200l, jsEngine.evaluate("request.status").asLong()); |
- assertEquals("[Adblock Plus ", jsEngine.evaluate("result.substr(0, 14)").asString()); |
- assertEquals( |
- "text/plain", |
- jsEngine.evaluate("request.getResponseHeader('Content-Type').substr(0,10)").asString()); |
- assertTrue(jsEngine.evaluate("request.getResponseHeader('Location')").isNull()); |
- } |
+ assertEquals(200l, jsEngine.evaluate("request.status").asLong()); |
+ assertEquals("[Adblock Plus ", jsEngine.evaluate("result.substr(0, 14)").asString()); |
+ assertEquals( |
+ "text/plain", |
+ jsEngine.evaluate("request.getResponseHeader('Content-Type').substr(0,10)").asString()); |
+ assertTrue(jsEngine.evaluate("request.getResponseHeader('Location')").isNull()); |
+ } |
} |