| Index: extensions/renderer/native_extension_bindings_system_unittest.cc
|
| diff --git a/extensions/renderer/native_extension_bindings_system_unittest.cc b/extensions/renderer/native_extension_bindings_system_unittest.cc
|
| index 62d4d99d72fa91a68bb46d8ade6903775311683b..9c29539fae6f8656aacbf6952f6e93733822a49e 100644
|
| --- a/extensions/renderer/native_extension_bindings_system_unittest.cc
|
| +++ b/extensions/renderer/native_extension_bindings_system_unittest.cc
|
| @@ -285,6 +285,11 @@ TEST_F(NativeExtensionBindingsSystemUnittest, TestBridgingToJSCustomBindings) {
|
| " this.timeArg = time;\n"
|
| " callback('active');\n"
|
| " });\n"
|
| + " api.apiFunctions.setUpdateArgumentsPreValidate(\n"
|
| + " 'setDetectionInterval', (interval) => {\n"
|
| + " this.intervalArg = interval;\n"
|
| + " return [50];\n"
|
| + " });\n"
|
| " this.hookedExtensionId = extensionId;\n"
|
| " this.hookedContextType = contextType;\n"
|
| " api.compiledApi.hookedApiProperty = 'someProperty';\n"
|
| @@ -349,6 +354,30 @@ TEST_F(NativeExtensionBindingsSystemUnittest, TestBridgingToJSCustomBindings) {
|
|
|
| // ...and second, that the callback was called with the proper result.
|
| EXPECT_EQ("\"active\"", get_property_as_string(global, "responseState"));
|
| +
|
| + // Test the updateArgumentsPreValidate hook.
|
| + {
|
| + // Call the function correctly.
|
| + const char kCallIdleSetInterval[] =
|
| + "(function() {\n"
|
| + " chrome.idle.setDetectionInterval(20);\n"
|
| + "});";
|
| +
|
| + v8::Local<v8::Function> call_idle_set_interval =
|
| + FunctionFromString(context, kCallIdleSetInterval);
|
| + RunFunctionOnGlobal(call_idle_set_interval, context, 0, nullptr);
|
| + }
|
| +
|
| + // Since we don't have a custom request handler, the hook should have only
|
| + // updated the arguments. The request then should have gone to the browser
|
| + // normally.
|
| + EXPECT_EQ("20", get_property_as_string(global, "intervalArg"));
|
| + EXPECT_EQ(extension->id(), last_params().extension_id);
|
| + EXPECT_EQ("idle.setDetectionInterval", last_params().name);
|
| + EXPECT_EQ(extension->url(), last_params().source_url);
|
| + EXPECT_FALSE(last_params().has_callback);
|
| + EXPECT_TRUE(
|
| + last_params().arguments.Equals(ListValueFromString("[50]").get()));
|
| }
|
|
|
| } // namespace extensions
|
|
|