summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/v8_context_native_handler.cc
diff options
context:
space:
mode:
authordtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 07:01:11 +0000
committerdtseng@chromium.org <dtseng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 07:01:11 +0000
commitdfa752b6bcd39e2078062f0328074a0fb391476d (patch)
tree88b26b96e42c4ba2c1dd177ebe1147e329d4f1cd /extensions/renderer/v8_context_native_handler.cc
parentafdfa351007d0666c2501b6c4087eedf34abdece (diff)
downloadchromium_src-dfa752b6bcd39e2078062f0328074a0fb391476d.zip
chromium_src-dfa752b6bcd39e2078062f0328074a0fb391476d.tar.gz
chromium_src-dfa752b6bcd39e2078062f0328074a0fb391476d.tar.bz2
Allow access to the module system as part of an extension browser test.
This cl adds a renderer-only binding to chrome.test to retrieve the current module system. It then becomes possible to require modules that ordinarily have little to no coverage by tests (e.g. internal bindings). It also makes js heavy API's easier to test. TEST=AutomationApiTest.Unit BUG=309681,387954 Review URL: https://codereview.chromium.org/345233003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279942 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/renderer/v8_context_native_handler.cc')
-rw-r--r--extensions/renderer/v8_context_native_handler.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/extensions/renderer/v8_context_native_handler.cc b/extensions/renderer/v8_context_native_handler.cc
index 56cd973..09f9c8a 100644
--- a/extensions/renderer/v8_context_native_handler.cc
+++ b/extensions/renderer/v8_context_native_handler.cc
@@ -22,6 +22,10 @@ V8ContextNativeHandler::V8ContextNativeHandler(ScriptContext* context,
RouteFunction("GetModuleSystem",
base::Bind(&V8ContextNativeHandler::GetModuleSystem,
base::Unretained(this)));
+ RouteFunction(
+ "RunWithNativesEnabledModuleSystem",
+ base::Bind(&V8ContextNativeHandler::RunWithNativesEnabledModuleSystem,
+ base::Unretained(this)));
}
void V8ContextNativeHandler::GetAvailability(
@@ -52,4 +56,16 @@ void V8ContextNativeHandler::GetModuleSystem(
args.GetReturnValue().Set(context->module_system()->NewInstance());
}
+void V8ContextNativeHandler::RunWithNativesEnabledModuleSystem(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ CHECK_EQ(args.Length(), 1);
+ CHECK(args[0]->IsFunction());
+ v8::Handle<v8::Value> call_with_args[] = {
+ context()->module_system()->NewInstance()
+ };
+ ModuleSystem::NativesEnabledScope natives_enabled(context()->module_system());
+ context()->CallFunction(
+ v8::Handle<v8::Function>::Cast(args[0]), 1, call_with_args);
+}
+
} // namespace extensions