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

Unified Diff: libadblockplus-android-tests/src/org/adblockplus/libadblockplus/tests/AndroidWebRequestTest.java

Issue 29347164: Issue 4202 - Fix failing AndroidWebRequestTest.testXMLHttpRequest (Closed)
Patch Set: Created June 30, 2016, 12:30 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" +
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld