| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/values.h" | 6 #include "base/values.h" |
| 7 #include "extensions/renderer/activity_log_converter_strategy.h" | 7 #include "extensions/renderer/activity_log_converter_strategy.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
| 9 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" |
| 10 | 11 |
| 11 using content::V8ValueConverter; | 12 using content::V8ValueConverter; |
| 12 | 13 |
| 13 namespace extensions { | 14 namespace extensions { |
| 14 | 15 |
| 15 class ActivityLogConverterStrategyTest : public testing::Test { | 16 class ActivityLogConverterStrategyTest : public testing::Test { |
| 16 public: | 17 public: |
| 17 ActivityLogConverterStrategyTest() | 18 ActivityLogConverterStrategyTest() |
| 18 : isolate_(v8::Isolate::GetCurrent()), | 19 : isolate_(v8::Isolate::GetCurrent()), |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 "hot: \"dog\"," | 116 "hot: \"dog\"," |
| 116 "}," | 117 "}," |
| 117 "empty_dictionary: {}," | 118 "empty_dictionary: {}," |
| 118 "list: [ \"monkey\", \"balls\" ]," | 119 "list: [ \"monkey\", \"balls\" ]," |
| 119 "empty_list: []," | 120 "empty_list: []," |
| 120 "function: (0, function() {})," // ensure function is anonymous | 121 "function: (0, function() {})," // ensure function is anonymous |
| 121 "named_function: foo" | 122 "named_function: foo" |
| 122 "};" | 123 "};" |
| 123 "})();"; | 124 "})();"; |
| 124 | 125 |
| 126 blink::WebScopedMicrotaskSuppression microtasks_scope; |
| 125 v8::Local<v8::Script> script( | 127 v8::Local<v8::Script> script( |
| 126 v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source))); | 128 v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source))); |
| 127 v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>(); | 129 v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>(); |
| 128 | 130 |
| 129 EXPECT_TRUE(VerifyString(v8_object, "[Object]")); | 131 EXPECT_TRUE(VerifyString(v8_object, "[Object]")); |
| 130 EXPECT_TRUE( | 132 EXPECT_TRUE( |
| 131 VerifyNull(v8_object->Get(v8::String::NewFromUtf8(isolate_, "null")))); | 133 VerifyNull(v8_object->Get(v8::String::NewFromUtf8(isolate_, "null")))); |
| 132 EXPECT_TRUE(VerifyBoolean( | 134 EXPECT_TRUE(VerifyBoolean( |
| 133 v8_object->Get(v8::String::NewFromUtf8(isolate_, "true")), true)); | 135 v8_object->Get(v8::String::NewFromUtf8(isolate_, "true")), true)); |
| 134 EXPECT_TRUE(VerifyBoolean( | 136 EXPECT_TRUE(VerifyBoolean( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 161 "[Array]")); | 163 "[Array]")); |
| 162 EXPECT_TRUE(VerifyString( | 164 EXPECT_TRUE(VerifyString( |
| 163 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), | 165 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), |
| 164 "[Function]")); | 166 "[Function]")); |
| 165 EXPECT_TRUE(VerifyString( | 167 EXPECT_TRUE(VerifyString( |
| 166 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), | 168 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), |
| 167 "[Function foo()]")); | 169 "[Function foo()]")); |
| 168 } | 170 } |
| 169 | 171 |
| 170 } // namespace extensions | 172 } // namespace extensions |
| OLD | NEW |