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

Side by Side Diff: test/AppInfoJsObject.cpp

Issue 10173031: Don`t use references to JsEngine to avoid use-after-free errors,switch to shared_ptr instead (Closed)
Patch Set: Created April 18, 2013, 4:15 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
OLDNEW
1 #include <AdblockPlus.h> 1 #include <AdblockPlus.h>
2 #include <gtest/gtest.h> 2 #include <gtest/gtest.h>
3 3
4 TEST(AppInfoJsObjectTest, AllProperties) 4 TEST(AppInfoJsObjectTest, AllProperties)
5 { 5 {
6 AdblockPlus::AppInfo appInfo; 6 AdblockPlus::AppInfo appInfo;
7 appInfo.id = "1"; 7 appInfo.id = "1";
8 appInfo.version = "2"; 8 appInfo.version = "2";
9 appInfo.name = "4"; 9 appInfo.name = "4";
10 appInfo.platform = "5"; 10 appInfo.platform = "5";
11 AdblockPlus::JsEngine jsEngine(appInfo); 11 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New(appInfo));
12 ASSERT_EQ("1", jsEngine.Evaluate("_appInfo.id")->AsString()); 12 ASSERT_EQ("1", jsEngine->Evaluate("_appInfo.id")->AsString());
13 ASSERT_EQ("2", jsEngine.Evaluate("_appInfo.version")->AsString()); 13 ASSERT_EQ("2", jsEngine->Evaluate("_appInfo.version")->AsString());
14 ASSERT_EQ("4", jsEngine.Evaluate("_appInfo.name")->AsString()); 14 ASSERT_EQ("4", jsEngine->Evaluate("_appInfo.name")->AsString());
15 ASSERT_EQ("5", jsEngine.Evaluate("_appInfo.platform")->AsString()); 15 ASSERT_EQ("5", jsEngine->Evaluate("_appInfo.platform")->AsString());
16 } 16 }
OLDNEW
« src/JsEngine.cpp ('K') | « src/WebRequestJsObject.cpp ('k') | test/ConsoleJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld