diff options
Diffstat (limited to 'chrome/renderer/extensions/messaging_utils_unittest.cc')
-rw-r--r-- | chrome/renderer/extensions/messaging_utils_unittest.cc | 63 |
1 files changed, 2 insertions, 61 deletions
diff --git a/chrome/renderer/extensions/messaging_utils_unittest.cc b/chrome/renderer/extensions/messaging_utils_unittest.cc index 6e8f061..1163243 100644 --- a/chrome/renderer/extensions/messaging_utils_unittest.cc +++ b/chrome/renderer/extensions/messaging_utils_unittest.cc @@ -49,7 +49,7 @@ TEST_F(MessagingUtilsUnittest, ZeroArguments) { module_system_->Require("test"); } -TEST_F(MessagingUtilsUnittest, TooManyArgumentsNoOptions) { +TEST_F(MessagingUtilsUnittest, TooManyArguments) { ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); RegisterTestModule( "var args = messagingUtils.alignSendMessageArguments(\n" @@ -58,16 +58,7 @@ TEST_F(MessagingUtilsUnittest, TooManyArgumentsNoOptions) { module_system_->Require("test"); } -TEST_F(MessagingUtilsUnittest, TooManyArgumentsWithOptions) { - ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); - RegisterTestModule( - "var args = messagingUtils.alignSendMessageArguments(\n" - " ['a', 'b', 'c', 'd', 'e'], true);\n" - "AssertTrue(args === null);"); - module_system_->Require("test"); -} - -TEST_F(MessagingUtilsUnittest, FinalArgumentIsNotAFunctionNoOptions) { +TEST_F(MessagingUtilsUnittest, FinalArgumentIsNotAFunction) { ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); RegisterTestModule( "var args = messagingUtils.alignSendMessageArguments(\n" @@ -76,15 +67,6 @@ TEST_F(MessagingUtilsUnittest, FinalArgumentIsNotAFunctionNoOptions) { module_system_->Require("test"); } -TEST_F(MessagingUtilsUnittest, FinalArgumentIsNotAFunctionWithOptions) { - ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); - RegisterTestModule( - "var args = messagingUtils.alignSendMessageArguments(\n" - " ['a', 'b', 'c', 'd'], true);\n" - "AssertTrue(args === null);"); - module_system_->Require("test"); -} - TEST_F(MessagingUtilsUnittest, OneStringArgument) { ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); // Because the request argument is required, a single argument must get @@ -137,46 +119,5 @@ TEST_F(MessagingUtilsUnittest, OneStringAndOneFunctionArgument) { module_system_->Require("test"); } -TEST_F(MessagingUtilsUnittest, OneStringAndOneObjectArgument) { - ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); - // This tests an ambiguous set of arguments when options are present: - // chrome.runtime.sendMessage('target', {'msg': 'this is a message'}); - // vs. - // chrome.runtime.sendMessage('request', {'includeTlsChannelId': true}); - // - // The question is whether the string should map to the target and the - // dictionary to the message, or whether the string should map to the message - // and the dictionary to the options. Because the target and message arguments - // predate the options argument, we bind the string in this case to the - // targetId. - RegisterTestModule( - "var obj = {'b': true};\n" - "var args = messagingUtils.alignSendMessageArguments(['a', obj], true);\n" - "AssertTrue(args.length == 4);\n" - "AssertTrue(args[0] == 'a');\n" - "AssertTrue(args[1] == obj);\n" - "AssertTrue(args[2] === null);\n" - "AssertTrue(args[3] === null);"); - module_system_->Require("test"); -} - -TEST_F(MessagingUtilsUnittest, TwoObjectArguments) { - ModuleSystem::NativesEnabledScope natives_enabled_scope(module_system_.get()); - // When two non-string arguments are provided and options are present, the - // two arguments must match request and options, respectively, because - // targetId must be a string. - RegisterTestModule( - "var obj1 = {'a': 'foo'};\n" - "var obj2 = {'b': 'bar'};\n" - "var args = messagingUtils.alignSendMessageArguments(\n" - " [obj1, obj2], true);\n" - "AssertTrue(args.length == 4);\n" - "AssertTrue(args[0] === null);\n" - "AssertTrue(args[1] == obj1);\n" - "AssertTrue(args[2] == obj2);\n" - "AssertTrue(args[3] === null);"); - module_system_->Require("test"); -} - } // namespace } // namespace extensions |