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 #include "BaseJsTest.h" | 18 #include "BaseJsTest.h" |
19 #include "../src/Thread.h" | 19 #include "../src/Thread.h" |
| 20 #include "../src/DefaultTimer.h" |
20 | 21 |
21 namespace | 22 namespace |
22 { | 23 { |
23 class GlobalJsObjectTest : public BaseJsTest | 24 class GlobalJsObjectTest : public BaseJsTest |
24 { | 25 { |
25 protected: | 26 protected: |
26 void SetUp() override | 27 void SetUp() override |
27 { | 28 { |
28 ThrowingPlatformCreationParameters params; | 29 ThrowingPlatformCreationParameters params; |
29 params.timer = AdblockPlus::CreateDefaultTimer(); | 30 params.timer.reset(new AdblockPlus::DefaultTimer()); |
30 platform.reset(new AdblockPlus::Platform(std::move(params))); | 31 platform.reset(new AdblockPlus::Platform(std::move(params))); |
31 } | 32 } |
32 }; | 33 }; |
33 } | 34 } |
34 | 35 |
35 TEST_F(GlobalJsObjectTest, SetTimeout) | 36 TEST_F(GlobalJsObjectTest, SetTimeout) |
36 { | 37 { |
37 GetJsEngine().Evaluate("let foo; setTimeout(function() {foo = 'bar';}, 100)"); | 38 GetJsEngine().Evaluate("let foo; setTimeout(function() {foo = 'bar';}, 100)"); |
38 ASSERT_TRUE(GetJsEngine().Evaluate("foo").IsUndefined()); | 39 ASSERT_TRUE(GetJsEngine().Evaluate("foo").IsUndefined()); |
39 AdblockPlus::Sleep(200); | 40 AdblockPlus::Sleep(200); |
(...skipping 15 matching lines...) Expand all Loading... |
55 } | 56 } |
56 | 57 |
57 TEST_F(GlobalJsObjectTest, SetMultipleTimeouts) | 58 TEST_F(GlobalJsObjectTest, SetMultipleTimeouts) |
58 { | 59 { |
59 GetJsEngine().Evaluate("let foo = []"); | 60 GetJsEngine().Evaluate("let foo = []"); |
60 GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); | 61 GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); |
61 GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); | 62 GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); |
62 AdblockPlus::Sleep(200); | 63 AdblockPlus::Sleep(200); |
63 ASSERT_EQ("1,2", GetJsEngine().Evaluate("foo").AsString()); | 64 ASSERT_EQ("1,2", GetJsEngine().Evaluate("foo").AsString()); |
64 } | 65 } |
OLD | NEW |