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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 24 matching lines...) Expand all Loading... |
35 { | 35 { |
36 return new AndroidWebRequest(true, true); | 36 return new AndroidWebRequest(true, true); |
37 } | 37 } |
38 | 38 |
39 @Test | 39 @Test |
40 public void testRealWebRequest() | 40 public void testRealWebRequest() |
41 { | 41 { |
42 // This URL should redirect to easylist-downloads.adblockplus.org and we | 42 // This URL should redirect to easylist-downloads.adblockplus.org and we |
43 // should get the actual filter list back. | 43 // should get the actual filter list back. |
44 jsEngine.evaluate( | 44 jsEngine.evaluate( |
45 "_webRequest.GET('https://easylist-downloads.adblockplus.org/easylist.txt'
, {}, " + | 45 "let foo; _webRequest.GET('https://easylist-downloads.adblockplus.org/easy
list.txt', {}, " + |
46 "function(result) {foo = result;} )"); | 46 "function(result) {foo = result;} )"); |
47 do | 47 do |
48 { | 48 { |
49 try | 49 try |
50 { | 50 { |
51 Thread.sleep(200); | 51 Thread.sleep(200); |
52 } | 52 } |
53 catch (InterruptedException e) | 53 catch (InterruptedException e) |
54 { | 54 { |
55 throw new RuntimeException(e); | 55 throw new RuntimeException(e); |
56 } | 56 } |
57 } while (jsEngine.evaluate("this.foo").isUndefined()); | 57 } while (jsEngine.evaluate("foo").isUndefined()); |
58 | 58 |
59 String response = jsEngine.evaluate("foo.responseText").asString(); | 59 String response = jsEngine.evaluate("foo.responseText").asString(); |
60 assertNotNull(response); | 60 assertNotNull(response); |
61 assertEquals( | 61 assertEquals( |
62 ServerResponse.NsStatus.OK.getStatusCode(), | 62 ServerResponse.NsStatus.OK.getStatusCode(), |
63 jsEngine.evaluate("foo.status").asLong()); | 63 jsEngine.evaluate("foo.status").asLong()); |
64 assertEquals(200l, jsEngine.evaluate("foo.responseStatus").asLong()); | 64 assertEquals(200l, jsEngine.evaluate("foo.responseStatus").asLong()); |
65 assertEquals( | 65 assertEquals( |
66 "[Adblock Plus ", | 66 "[Adblock Plus ", |
67 jsEngine.evaluate("foo.responseText.substr(0, 14)").asString()); | 67 jsEngine.evaluate("foo.responseText.substr(0, 14)").asString()); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 assertFalse(isDocumentWhitelisted); | 131 assertFalse(isDocumentWhitelisted); |
132 | 132 |
133 boolean isElemhideWhitelisted = filterEngine.isElemhideWhitelisted(url, null
); | 133 boolean isElemhideWhitelisted = filterEngine.isElemhideWhitelisted(url, null
); |
134 assertFalse(isElemhideWhitelisted); | 134 assertFalse(isElemhideWhitelisted); |
135 | 135 |
136 List<String> selectors = filterEngine.getElementHidingSelectors(url); | 136 List<String> selectors = filterEngine.getElementHidingSelectors(url); |
137 assertNotNull(selectors); | 137 assertNotNull(selectors); |
138 assertTrue(selectors.size() > 0); | 138 assertTrue(selectors.size() > 0); |
139 } | 139 } |
140 } | 140 } |
OLD | NEW |