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" | |
10 #include "v8/include/v8.h" | 9 #include "v8/include/v8.h" |
11 | 10 |
12 using content::V8ValueConverter; | 11 using content::V8ValueConverter; |
13 | 12 |
14 namespace extensions { | 13 namespace extensions { |
15 | 14 |
16 class ActivityLogConverterStrategyTest : public testing::Test { | 15 class ActivityLogConverterStrategyTest : public testing::Test { |
17 public: | 16 public: |
18 ActivityLogConverterStrategyTest() | 17 ActivityLogConverterStrategyTest() |
19 : isolate_(v8::Isolate::GetCurrent()), | 18 : isolate_(v8::Isolate::GetCurrent()), |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 "hot: \"dog\"," | 115 "hot: \"dog\"," |
117 "}," | 116 "}," |
118 "empty_dictionary: {}," | 117 "empty_dictionary: {}," |
119 "list: [ \"monkey\", \"balls\" ]," | 118 "list: [ \"monkey\", \"balls\" ]," |
120 "empty_list: []," | 119 "empty_list: []," |
121 "function: (0, function() {})," // ensure function is anonymous | 120 "function: (0, function() {})," // ensure function is anonymous |
122 "named_function: foo" | 121 "named_function: foo" |
123 "};" | 122 "};" |
124 "})();"; | 123 "})();"; |
125 | 124 |
126 blink::WebScopedMicrotaskSuppression microtasks_scope; | |
127 v8::Local<v8::Script> script( | 125 v8::Local<v8::Script> script( |
128 v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source))); | 126 v8::Script::Compile(v8::String::NewFromUtf8(isolate_, source))); |
129 v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>(); | 127 v8::Local<v8::Object> v8_object = script->Run().As<v8::Object>(); |
130 | 128 |
131 EXPECT_TRUE(VerifyString(v8_object, "[Object]")); | 129 EXPECT_TRUE(VerifyString(v8_object, "[Object]")); |
132 EXPECT_TRUE( | 130 EXPECT_TRUE( |
133 VerifyNull(v8_object->Get(v8::String::NewFromUtf8(isolate_, "null")))); | 131 VerifyNull(v8_object->Get(v8::String::NewFromUtf8(isolate_, "null")))); |
134 EXPECT_TRUE(VerifyBoolean( | 132 EXPECT_TRUE(VerifyBoolean( |
135 v8_object->Get(v8::String::NewFromUtf8(isolate_, "true")), true)); | 133 v8_object->Get(v8::String::NewFromUtf8(isolate_, "true")), true)); |
136 EXPECT_TRUE(VerifyBoolean( | 134 EXPECT_TRUE(VerifyBoolean( |
(...skipping 26 matching lines...) Expand all Loading... |
163 "[Array]")); | 161 "[Array]")); |
164 EXPECT_TRUE(VerifyString( | 162 EXPECT_TRUE(VerifyString( |
165 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), | 163 v8_object->Get(v8::String::NewFromUtf8(isolate_, "function")), |
166 "[Function]")); | 164 "[Function]")); |
167 EXPECT_TRUE(VerifyString( | 165 EXPECT_TRUE(VerifyString( |
168 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), | 166 v8_object->Get(v8::String::NewFromUtf8(isolate_, "named_function")), |
169 "[Function foo()]")); | 167 "[Function foo()]")); |
170 } | 168 } |
171 | 169 |
172 } // namespace extensions | 170 } // namespace extensions |
OLD | NEW |