LEFT | RIGHT |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 assertEquals( | 62 assertEquals( |
63 "[Adblock Plus ", | 63 "[Adblock Plus ", |
64 jsEngine.evaluate("foo.responseText.substr(0, 14)").asString()); | 64 jsEngine.evaluate("foo.responseText.substr(0, 14)").asString()); |
65 JsValue jsHeaders = jsEngine.evaluate("foo.responseHeaders"); | 65 JsValue jsHeaders = jsEngine.evaluate("foo.responseHeaders"); |
66 assertNotNull(jsHeaders); | 66 assertNotNull(jsHeaders); |
67 assertFalse(jsHeaders.isUndefined()); | 67 assertFalse(jsHeaders.isUndefined()); |
68 assertFalse(jsHeaders.isNull()); | 68 assertFalse(jsHeaders.isNull()); |
69 assertTrue(jsHeaders.isObject()); | 69 assertTrue(jsHeaders.isObject()); |
70 assertEquals( | 70 assertEquals( |
71 "text/plain", | 71 "text/plain", |
72 jsEngine.evaluate("foo.responseHeaders['Content-Type'].substr(0,10)").asSt
ring()); | 72 jsEngine.evaluate("foo.responseHeaders['Content-Type'].substr(0, 10)").asS
tring()); |
73 assertTrue(jsEngine.evaluate("foo.responseHeaders['location']").isUndefined(
)); | 73 assertTrue(jsEngine.evaluate("foo.responseHeaders['location']").isUndefined(
)); |
74 } | 74 } |
75 | 75 |
76 @Test | 76 @Test |
77 public void testXMLHttpRequest() | 77 public void testXMLHttpRequest() |
78 { | 78 { |
79 jsEngine.evaluate( | 79 jsEngine.evaluate( |
80 "var result;\n" + | 80 "var result;\n" + |
81 "var request = new XMLHttpRequest();\n" + | 81 "var request = new XMLHttpRequest();\n" + |
82 "request.open('GET', 'https://easylist-downloads.adblockplus.org/easylist.
txt');\n" + | 82 "request.open('GET', 'https://easylist-downloads.adblockplus.org/easylist.
txt');\n" + |
(...skipping 17 matching lines...) Expand all Loading... |
100 } while (jsEngine.evaluate("result").isUndefined()); | 100 } while (jsEngine.evaluate("result").isUndefined()); |
101 | 101 |
102 assertEquals( | 102 assertEquals( |
103 ServerResponse.NsStatus.OK.getStatusCode(), | 103 ServerResponse.NsStatus.OK.getStatusCode(), |
104 jsEngine.evaluate("request.channel.status").asLong()); | 104 jsEngine.evaluate("request.channel.status").asLong()); |
105 | 105 |
106 assertEquals(200l, jsEngine.evaluate("request.status").asLong()); | 106 assertEquals(200l, jsEngine.evaluate("request.status").asLong()); |
107 assertEquals("[Adblock Plus ", jsEngine.evaluate("result.substr(0, 14)").asS
tring()); | 107 assertEquals("[Adblock Plus ", jsEngine.evaluate("result.substr(0, 14)").asS
tring()); |
108 assertEquals( | 108 assertEquals( |
109 "text/plain", | 109 "text/plain", |
110 jsEngine.evaluate("request.getResponseHeader('Content-Type').substr(0,10)"
).asString()); | 110 jsEngine.evaluate("request.getResponseHeader('Content-Type').substr(0, 10)
").asString()); |
111 assertTrue(jsEngine.evaluate("request.getResponseHeader('Location')").isNull
()); | 111 assertTrue(jsEngine.evaluate("request.getResponseHeader('Location')").isNull
()); |
112 } | 112 } |
113 } | 113 } |
LEFT | RIGHT |