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-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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 } | 48 } |
49 | 49 |
50 TEST_F(GlobalJsObjectTest, SetMultipleTimeouts) | 50 TEST_F(GlobalJsObjectTest, SetMultipleTimeouts) |
51 { | 51 { |
52 jsEngine->Evaluate("foo = []"); | 52 jsEngine->Evaluate("foo = []"); |
53 jsEngine->Evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); | 53 jsEngine->Evaluate("setTimeout(function(s) {foo.push('1');}, 100)"); |
54 jsEngine->Evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); | 54 jsEngine->Evaluate("setTimeout(function(s) {foo.push('2');}, 150)"); |
55 AdblockPlus::Sleep(200); | 55 AdblockPlus::Sleep(200); |
56 ASSERT_EQ("1,2", jsEngine->Evaluate("this.foo")->AsString()); | 56 ASSERT_EQ("1,2", jsEngine->Evaluate("this.foo")->AsString()); |
57 } | 57 } |
| 58 |
| 59 TEST_F(GlobalJsObjectTest, TimeoutDoesNotKeepJsEngine) |
| 60 { |
| 61 jsEngine->Evaluate("setTimeout(function() {}, 50000)"); |
| 62 EXPECT_EQ(1u, jsEngine.use_count()); // check that counter is still 1 |
| 63 AdblockPlus::Sleep(200); |
| 64 std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine = jsEngine; |
| 65 jsEngine.reset(); |
| 66 EXPECT_FALSE(weakJsEngine.lock()); |
| 67 } |
OLD | NEW |