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

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

Issue 2241203003: Pass user session type to extension feature checks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: split out some stuff Created 4 years, 4 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
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 <vector> 5 #include <vector>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "extensions/common/extension.h" 9 #include "extensions/common/extension.h"
10 #include "extensions/common/extension_set.h" 10 #include "extensions/common/extension_set.h"
(...skipping 19 matching lines...) Expand all
30 v8::HandleScope handle_scope(isolate); 30 v8::HandleScope handle_scope(isolate);
31 v8::Local<v8::Context> v8_context = v8::Context::New(isolate); 31 v8::Local<v8::Context> v8_context = v8::Context::New(isolate);
32 v8::Context::Scope context_scope(v8_context); 32 v8::Context::Scope context_scope(v8_context);
33 // ScriptContext relies on gin, it just doesn't look like it from here. 33 // ScriptContext relies on gin, it just doesn't look like it from here.
34 gin::ContextHolder context_holder(isolate); 34 gin::ContextHolder context_holder(isolate);
35 context_holder.SetContext(v8_context); 35 context_holder.SetContext(v8_context);
36 36
37 ExtensionIdSet active_extensions; 37 ExtensionIdSet active_extensions;
38 ScriptContextSet context_set(&active_extensions); 38 ScriptContextSet context_set(&active_extensions);
39 ScriptContext* context = context_set.Register( 39 ScriptContext* context = context_set.Register(
40 web_frame.frame(), v8_context, 0, 0); // no extension group or world ID 40 web_frame.frame(), v8_context, Feature::SESSION_TYPE_UNSPECIFIED, 0,
41 0); // no extension group or world ID
41 42
42 // Context is valid and resembles correctness. 43 // Context is valid and resembles correctness.
43 EXPECT_TRUE(context->is_valid()); 44 EXPECT_TRUE(context->is_valid());
44 EXPECT_EQ(web_frame.frame(), context->web_frame()); 45 EXPECT_EQ(web_frame.frame(), context->web_frame());
45 EXPECT_EQ(v8_context, context->v8_context()); 46 EXPECT_EQ(v8_context, context->v8_context());
46 47
47 // Context has been correctly added. 48 // Context has been correctly added.
48 EXPECT_EQ(1u, context_set.size()); 49 EXPECT_EQ(1u, context_set.size());
49 EXPECT_EQ(context, context_set.GetByV8Context(v8_context)); 50 EXPECT_EQ(context, context_set.GetByV8Context(v8_context));
50 51
51 // Test context is correctly removed. 52 // Test context is correctly removed.
52 context_set.Remove(context); 53 context_set.Remove(context);
53 EXPECT_EQ(0u, context_set.size()); 54 EXPECT_EQ(0u, context_set.size());
54 EXPECT_EQ(nullptr, context_set.GetByV8Context(v8_context)); 55 EXPECT_EQ(nullptr, context_set.GetByV8Context(v8_context));
55 56
56 // After removal, the context should be marked for destruction. 57 // After removal, the context should be marked for destruction.
57 EXPECT_FALSE(context->is_valid()); 58 EXPECT_FALSE(context->is_valid());
58 59
59 // Run loop to do the actual deletion. 60 // Run loop to do the actual deletion.
60 base::RunLoop().RunUntilIdle(); 61 base::RunLoop().RunUntilIdle();
61 } 62 }
62 63
63 } // namespace extensions 64 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698