Commit bdc39893 authored by Devlin Cronin's avatar Devlin Cronin Committed by Commit Bot

[Extensions Bindings] Fix GetPackageDirectoryEntry

GetPackageDirectoryEntry has a ModuleSystem::NativesEnabledScope that
wasn't quite long enough. We need to ensure that the scope allows the
function to generate the callback
(fileEntryBindingUtil.getBindDirectoryEntryCallback) to run with
natives, since it may require modules in the background page.

Expand the natives enabled scope by just enough to make this work.

Bug: 653596
Test: browser_tests --enable-features=NativeCrxBindings
                    --gtest_filter=*GetPackageDirectoryEntryApp*

Change-Id: I209c4e8f92d0b10955d1ecafe489b68a2b18af88
Reviewed-on: https://chromium-review.googlesource.com/898399Reviewed-by: default avatarJeremy Roman <jbroman@chromium.org>
Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534060}
parent c3eee4c4
......@@ -336,7 +336,7 @@ RequestResult RuntimeHooksDelegate::HandleGetPackageDirectoryEntryCallback(
v8::Isolate* isolate = script_context->isolate();
v8::Local<v8::Context> v8_context = script_context->v8_context();
v8::Local<v8::Function> get_bind_directory_entry_callback;
v8::MaybeLocal<v8::Value> maybe_custom_callback;
{ // Begin natives enabled scope (for requiring the module).
ModuleSystem::NativesEnabledScope enable_natives(
script_context->module_system());
......@@ -391,16 +391,16 @@ RequestResult RuntimeHooksDelegate::HandleGetPackageDirectoryEntryCallback(
return RequestResult(RequestResult::HANDLED);
}
get_bind_directory_entry_callback =
v8::Local<v8::Function> get_bind_directory_entry_callback =
get_bind_directory_entry_callback_value.As<v8::Function>();
} // End modules enabled scope.
v8::MaybeLocal<v8::Value> script_result =
JSRunner::Get(v8_context)
->RunJSFunctionSync(get_bind_directory_entry_callback, v8_context, 0,
nullptr);
maybe_custom_callback =
JSRunner::Get(v8_context)
->RunJSFunctionSync(get_bind_directory_entry_callback, v8_context,
0, nullptr);
} // End modules enabled scope.
v8::Local<v8::Value> callback;
if (!script_result.ToLocal(&callback)) {
if (!maybe_custom_callback.ToLocal(&callback)) {
NOTREACHED();
return RequestResult(RequestResult::THROWN);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment