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

Unified Diff: test/GlobalJsObject.cpp

Issue 29523555: Issue 5552 - use strict mode for all JS in libadblocklus (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created Aug. 22, 2017, 7:29 a.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
Index: test/GlobalJsObject.cpp
diff --git a/test/GlobalJsObject.cpp b/test/GlobalJsObject.cpp
index 0c2e32d2594fa86c05fa5caa82e108ac133bff10..20fc7a1da4cbf32dee9418143079b52a2d2f5cdd 100644
--- a/test/GlobalJsObject.cpp
+++ b/test/GlobalJsObject.cpp
@@ -34,18 +34,18 @@ namespace
TEST_F(GlobalJsObjectTest, SetTimeout)
{
- GetJsEngine().Evaluate("setTimeout(function() {foo = 'bar';}, 100)");
- ASSERT_TRUE(GetJsEngine().Evaluate("this.foo").IsUndefined());
+ GetJsEngine().Evaluate("let foo; setTimeout(function() {foo = 'bar';}, 100)");
+ ASSERT_TRUE(GetJsEngine().Evaluate("foo").IsUndefined());
AdblockPlus::Sleep(200);
- ASSERT_EQ("bar", GetJsEngine().Evaluate("this.foo").AsString());
+ ASSERT_EQ("bar", GetJsEngine().Evaluate("foo").AsString());
}
TEST_F(GlobalJsObjectTest, SetTimeoutWithArgs)
{
- GetJsEngine().Evaluate("setTimeout(function(s) {foo = s;}, 100, 'foobar')");
- ASSERT_TRUE(GetJsEngine().Evaluate("this.foo").IsUndefined());
+ GetJsEngine().Evaluate("let foo; setTimeout(function(s) {foo = s;}, 100, 'foobar')");
+ ASSERT_TRUE(GetJsEngine().Evaluate("foo").IsUndefined());
AdblockPlus::Sleep(200);
- ASSERT_EQ("foobar", GetJsEngine().Evaluate("this.foo").AsString());
+ ASSERT_EQ("foobar", GetJsEngine().Evaluate("foo").AsString());
}
TEST_F(GlobalJsObjectTest, SetTimeoutWithInvalidArgs)
@@ -56,9 +56,9 @@ TEST_F(GlobalJsObjectTest, SetTimeoutWithInvalidArgs)
TEST_F(GlobalJsObjectTest, SetMultipleTimeouts)
{
- GetJsEngine().Evaluate("foo = []");
+ GetJsEngine().Evaluate("let foo = []");
GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('1');}, 100)");
GetJsEngine().Evaluate("setTimeout(function(s) {foo.push('2');}, 150)");
AdblockPlus::Sleep(200);
- ASSERT_EQ("1,2", GetJsEngine().Evaluate("this.foo").AsString());
+ ASSERT_EQ("1,2", GetJsEngine().Evaluate("foo").AsString());
}
« src/JsEngine.cpp ('K') | « test/FileSystemJsObject.cpp ('k') | test/JsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld