Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: test/GlobalJsObject.cpp

Issue 29393573: Issue 4692 - Dont' keep a strong reference from timer thread (Closed)
Patch Set: Created March 23, 2017, 5:24 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/GlobalJsObject.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« src/GlobalJsObject.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld