OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/test/base/module_system_test.h" | |
7 #include "extensions/renderer/module_system.h" | 6 #include "extensions/renderer/module_system.h" |
7 #include "extensions/renderer/module_system_test.h" | |
8 #include "gin/modules/module_registry.h" | 8 #include "gin/modules/module_registry.h" |
9 | 9 |
10 // TODO(cduvall/kalman): Put this file in extensions namespace. | 10 // TODO(cduvall/kalman): Put this file in extensions namespace. |
not at google - send to devlin
2014/07/10 15:22:56
and here
Sam McNally
2014/07/11 00:01:18
Done.
| |
11 using extensions::ModuleSystem; | 11 using extensions::ModuleSystem; |
12 using extensions::NativeHandler; | 12 using extensions::NativeHandler; |
13 using extensions::ObjectBackedNativeHandler; | 13 using extensions::ObjectBackedNativeHandler; |
14 | 14 |
15 class CounterNatives : public ObjectBackedNativeHandler { | 15 class CounterNatives : public ObjectBackedNativeHandler { |
16 public: | 16 public: |
17 explicit CounterNatives(extensions::ChromeV8Context* context) | 17 explicit CounterNatives(extensions::ScriptContext* context) |
18 : ObjectBackedNativeHandler(context), counter_(0) { | 18 : ObjectBackedNativeHandler(context), counter_(0) { |
19 RouteFunction("Get", base::Bind(&CounterNatives::Get, | 19 RouteFunction("Get", base::Bind(&CounterNatives::Get, |
20 base::Unretained(this))); | 20 base::Unretained(this))); |
21 RouteFunction("Increment", base::Bind(&CounterNatives::Increment, | 21 RouteFunction("Increment", base::Bind(&CounterNatives::Increment, |
22 base::Unretained(this))); | 22 base::Unretained(this))); |
23 } | 23 } |
24 | 24 |
25 void Get(const v8::FunctionCallbackInfo<v8::Value>& args) { | 25 void Get(const v8::FunctionCallbackInfo<v8::Value>& args) { |
26 args.GetReturnValue().Set(static_cast<int32_t>(counter_)); | 26 args.GetReturnValue().Set(static_cast<int32_t>(counter_)); |
27 } | 27 } |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 " requireNative('assert').AssertTrue(" | 480 " requireNative('assert').AssertTrue(" |
481 " natives.requireAsync('foo') === undefined);" | 481 " natives.requireAsync('foo') === undefined);" |
482 "});"); | 482 "});"); |
483 scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment(); | 483 scoped_ptr<ModuleSystemTestEnvironment> other_env = CreateEnvironment(); |
484 gin::ModuleRegistry::From(env()->context()->v8_context())->AddBuiltinModule( | 484 gin::ModuleRegistry::From(env()->context()->v8_context())->AddBuiltinModule( |
485 env()->isolate(), "natives", other_env->module_system()->NewInstance()); | 485 env()->isolate(), "natives", other_env->module_system()->NewInstance()); |
486 other_env->ShutdownModuleSystem(); | 486 other_env->ShutdownModuleSystem(); |
487 env()->module_system()->Require("test"); | 487 env()->module_system()->Require("test"); |
488 RunResolvedPromises(); | 488 RunResolvedPromises(); |
489 } | 489 } |
OLD | NEW |