| Left: | ||
| Right: |
| 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-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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 "_webRequest.GET('http://example.com/', {}, null)", | 70 "_webRequest.GET('http://example.com/', {}, null)", |
| 71 "_webRequest.GET('http://example.com/', {}, function(){}, 0)" | 71 "_webRequest.GET('http://example.com/', {}, function(){}, 0)" |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 for (String source : sources) | 74 for (String source : sources) |
| 75 { | 75 { |
| 76 try | 76 try |
| 77 { | 77 { |
| 78 jsEngine.evaluate(source); | 78 jsEngine.evaluate(source); |
| 79 fail(source); | 79 fail(source); |
| 80 } catch (AdblockPlusException e) | 80 } |
|
anton
2018/08/24 12:25:04
new line required here
René Jeschke
2018/08/27 20:02:15
Done.
| |
| 81 catch (AdblockPlusException e) | |
| 81 { | 82 { |
| 82 // ignored | 83 // ignored |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 | 87 |
| 87 @Test | 88 @Test |
| 88 public void testSuccessfulRequest() | 89 public void testSuccessfulRequest() |
| 89 { | 90 { |
| 90 jsEngine.evaluate( | 91 jsEngine.evaluate( |
| 91 "let foo = true; _webRequest.GET('http://example.com/', {X: 'Y'}, function (result) {foo = result;} )"); | 92 "let foo = true; _webRequest.GET('http://example.com/', {X: 'Y'}, function (result) {foo = result;} )"); |
| 92 assertTrue(jsEngine.evaluate("foo").isBoolean()); | 93 assertTrue(jsEngine.evaluate("foo").isBoolean()); |
| 93 assertTrue(jsEngine.evaluate("foo").asBoolean()); | 94 assertTrue(jsEngine.evaluate("foo").asBoolean()); |
| 94 | 95 |
| 95 SystemClock.sleep(200); | 96 SystemClock.sleep(200); |
| 96 | 97 |
| 97 assertEquals( | 98 assertEquals( |
| 98 ServerResponse.NsStatus.OK.getStatusCode(), | 99 ServerResponse.NsStatus.OK.getStatusCode(), |
| 99 jsEngine.evaluate("foo.status").asLong()); | 100 jsEngine.evaluate("foo.status").asLong()); |
| 100 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex t").asString()); | 101 assertEquals("http://example.com/\nX\nY", jsEngine.evaluate("foo.responseTex t").asString()); |
| 101 assertEquals("{\"Foo\":\"Bar\"}", | 102 assertEquals("{\"Foo\":\"Bar\"}", |
| 102 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString()); | 103 jsEngine.evaluate("JSON.stringify(foo.responseHeaders)").asString()); |
| 103 } | 104 } |
| 104 } | 105 } |
| LEFT | RIGHT |