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

Unified 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.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/GlobalJsObject.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/GlobalJsObject.cpp
diff --git a/test/GlobalJsObject.cpp b/test/GlobalJsObject.cpp
index cc8478ae07413a16fa65326f1bab161886dd482e..62a2a20503471dc7831a575af3971609d7f89d94 100644
--- a/test/GlobalJsObject.cpp
+++ b/test/GlobalJsObject.cpp
@@ -55,3 +55,13 @@ TEST_F(GlobalJsObjectTest, SetMultipleTimeouts)
AdblockPlus::Sleep(200);
ASSERT_EQ("1,2", jsEngine->Evaluate("this.foo")->AsString());
}
+
+TEST_F(GlobalJsObjectTest, TimeoutDoesNotKeepJsEngine)
+{
+ jsEngine->Evaluate("setTimeout(function() {}, 50000)");
+ EXPECT_EQ(1u, jsEngine.use_count()); // check that counter is still 1
+ AdblockPlus::Sleep(200);
+ std::weak_ptr<AdblockPlus::JsEngine> weakJsEngine = jsEngine;
+ jsEngine.reset();
+ EXPECT_FALSE(weakJsEngine.lock());
+}
« src/GlobalJsObject.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld