Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: extensions/renderer/script_context_set_unittest.cc

Issue 402553002: Don't create a gin::IsolateHolder in extensions unittests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_loop/message_loop.h" 5 #include "base/message_loop/message_loop.h"
6 #include "extensions/common/extension.h" 6 #include "extensions/common/extension.h"
7 #include "extensions/common/features/feature.h" 7 #include "extensions/common/features/feature.h"
8 #include "extensions/renderer/script_context.h" 8 #include "extensions/renderer/script_context.h"
9 #include "extensions/renderer/script_context_set.h" 9 #include "extensions/renderer/script_context_set.h"
10 #include "gin/public/context_holder.h" 10 #include "gin/public/context_holder.h"
11 #include "gin/public/isolate_holder.h"
12 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
15 14
16 namespace extensions { 15 namespace extensions {
17 16
18 TEST(ScriptContextSet, Lifecycle) { 17 TEST(ScriptContextSet, Lifecycle) {
19 base::MessageLoop loop; 18 base::MessageLoop loop;
20 19
21 ScriptContextSet context_set; 20 ScriptContextSet context_set;
22 21
23 v8::Isolate* isolate = v8::Isolate::GetCurrent(); 22 v8::Isolate* isolate = v8::Isolate::GetCurrent();
24 gin::IsolateHolder isolate_holder(isolate, NULL);
25 v8::HandleScope handle_scope(isolate); 23 v8::HandleScope handle_scope(isolate);
26 gin::ContextHolder context_holder(isolate); 24 gin::ContextHolder context_holder(isolate);
27 context_holder.SetContext(v8::Context::New(isolate)); 25 context_holder.SetContext(v8::Context::New(isolate));
28 26
29 // Dirty hack, but we don't actually need the frame, and this is easier than 27 // Dirty hack, but we don't actually need the frame, and this is easier than
30 // creating a whole webview. 28 // creating a whole webview.
31 blink::WebFrame* frame = reinterpret_cast<blink::WebFrame*>(1); 29 blink::WebFrame* frame = reinterpret_cast<blink::WebFrame*>(1);
32 const Extension* extension = NULL; 30 const Extension* extension = NULL;
33 ScriptContext* context = 31 ScriptContext* context =
34 new ScriptContext(context_holder.context(), 32 new ScriptContext(context_holder.context(),
(...skipping 19 matching lines...) Expand all
54 EXPECT_EQ(1u, set_copy.size()); 52 EXPECT_EQ(1u, set_copy.size());
55 53
56 // After removal, the context should be marked for destruction. 54 // After removal, the context should be marked for destruction.
57 EXPECT_FALSE(context->web_frame()); 55 EXPECT_FALSE(context->web_frame());
58 56
59 // Run loop to do the actual deletion. 57 // Run loop to do the actual deletion.
60 loop.RunUntilIdle(); 58 loop.RunUntilIdle();
61 } 59 }
62 60
63 } // namespace extensions 61 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/module_system_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698