| 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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 | 64 |
| 65 namespace { | 65 namespace { |
| 66 | 66 |
| 67 bool IsSame(AdblockPlus::JsEngine& jsEngine, | 67 bool IsSame(AdblockPlus::JsEngine& jsEngine, |
| 68 const AdblockPlus::JsValue& v1, const AdblockPlus::JsValue& v2) | 68 const AdblockPlus::JsValue& v1, const AdblockPlus::JsValue& v2) |
| 69 { | 69 { |
| 70 AdblockPlus::JsValueList params; | 70 AdblockPlus::JsValueList params; |
| 71 params.push_back(v1); | 71 params.push_back(v1); |
| 72 params.push_back(v2); | 72 params.push_back(v2); |
| 73 return jsEngine.Evaluate("f = function(a, b) { return a == b };").Call(param
s).AsBool(); | 73 return jsEngine.Evaluate("(function(a, b) { return a == b })").Call(params).
AsBool(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } | 76 } |
| 77 | 77 |
| 78 TEST_F(JsEngineTest, ValueCopy) | 78 TEST_F(JsEngineTest, ValueCopy) |
| 79 { | 79 { |
| 80 { | 80 { |
| 81 auto value = GetJsEngine().NewValue("foo"); | 81 auto value = GetJsEngine().NewValue("foo"); |
| 82 ASSERT_TRUE(value.IsString()); | 82 ASSERT_TRUE(value.IsString()); |
| 83 ASSERT_EQ("foo", value.AsString()); | 83 ASSERT_EQ("foo", value.AsString()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 // v8::Isolate by default requires 32MB (depends on platform), so if there is | 191 // v8::Isolate by default requires 32MB (depends on platform), so if there is |
| 192 // a memory leak than we will run out of memory on 32 bit platform because it | 192 // a memory leak than we will run out of memory on 32 bit platform because it |
| 193 // will allocate 32000 MB which is less than 2GB where it reaches out of | 193 // will allocate 32000 MB which is less than 2GB where it reaches out of |
| 194 // memory. Even on android where it allocates initially 16MB, the test still | 194 // memory. Even on android where it allocates initially 16MB, the test still |
| 195 // makes sense. | 195 // makes sense. |
| 196 for (int i = 0; i < 1000; ++i) | 196 for (int i = 0; i < 1000; ++i) |
| 197 { | 197 { |
| 198 JsEngine::New(AppInfo(), platform); | 198 JsEngine::New(AppInfo(), platform); |
| 199 } | 199 } |
| 200 } | 200 } |
| OLD | NEW |