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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 package org.adblockplus.libadblockplus.tests; | 18 package org.adblockplus.libadblockplus.tests; |
19 | 19 |
20 import org.adblockplus.libadblockplus.AdblockPlusException; | 20 import org.adblockplus.libadblockplus.AdblockPlusException; |
21 | 21 |
22 import org.junit.Test; | 22 import org.junit.Test; |
23 | 23 |
24 public class GlobalJsObjectTest extends BaseJsTest | 24 public class GlobalJsObjectTest extends BaseJsEngineTest |
25 { | 25 { |
26 @Test | 26 @Test |
27 public void testSetTimeout() throws InterruptedException | 27 public void testSetTimeout() throws InterruptedException |
28 { | 28 { |
29 jsEngine.evaluate("let foo; setTimeout(function() {foo = 'bar';}, 100)"); | 29 jsEngine.evaluate("let foo; setTimeout(function() {foo = 'bar';}, 100)"); |
30 assertTrue(jsEngine.evaluate("foo").isUndefined()); | 30 assertTrue(jsEngine.evaluate("foo").isUndefined()); |
31 Thread.sleep(200); | 31 Thread.sleep(200); |
32 assertEquals("bar", jsEngine.evaluate("foo").asString()); | 32 assertEquals("bar", jsEngine.evaluate("foo").asString()); |
33 } | 33 } |
34 | 34 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 @Test | 68 @Test |
69 public void testSetMultipleTimeouts() throws InterruptedException | 69 public void testSetMultipleTimeouts() throws InterruptedException |
70 { | 70 { |
71 jsEngine.evaluate("let foo = []"); | 71 jsEngine.evaluate("let foo = []"); |
72 jsEngine.evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); | 72 jsEngine.evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); |
73 jsEngine.evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); | 73 jsEngine.evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); |
74 Thread.sleep(200); | 74 Thread.sleep(200); |
75 assertEquals("1,2", jsEngine.evaluate("foo").asString()); | 75 assertEquals("1,2", jsEngine.evaluate("foo").asString()); |
76 } | 76 } |
77 } | 77 } |
OLD | NEW |