diff options
author | sammc <sammc@chromium.org> | 2015-01-13 17:25:06 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-01-14 01:26:02 +0000 |
commit | 2cc22656103e5df811de911b693eadc55d3ad0b2 (patch) | |
tree | 323e0a192efa7c6e27d65038bbecda1c47574c65 /extensions/renderer/api | |
parent | e1b07409f19d84853d4730e3ab5b862fd65838d0 (diff) | |
download | chromium_src-2cc22656103e5df811de911b693eadc55d3ad0b2.zip chromium_src-2cc22656103e5df811de911b693eadc55d3ad0b2.tar.gz chromium_src-2cc22656103e5df811de911b693eadc55d3ad0b2.tar.bz2 |
Add a mojoPrivate API that exposes mojo to component apps/extensions.
Some component apps and extensions use private extension APIs to
communicate with their browser components. This CL adds the mojoPrivate
API as a way to use mojo directly from Javascript without needing to
create a private API.
BUG=448565,448569
Review URL: https://codereview.chromium.org/649003003
Cr-Commit-Position: refs/heads/master@{#311385}
Diffstat (limited to 'extensions/renderer/api')
-rw-r--r-- | extensions/renderer/api/mojo_private/mojo_private_unittest.cc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/extensions/renderer/api/mojo_private/mojo_private_unittest.cc b/extensions/renderer/api/mojo_private/mojo_private_unittest.cc new file mode 100644 index 0000000..d9607bf --- /dev/null +++ b/extensions/renderer/api/mojo_private/mojo_private_unittest.cc @@ -0,0 +1,48 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "extensions/renderer/api_test_base.h" + +#include "gin/modules/module_registry.h" + +// A test launcher for tests for the mojoPrivate API defined in +// extensions/test/data/mojo_private_unittest.js. + +namespace extensions { + +class MojoPrivateApiTest : public ApiTestBase { + public: + MojoPrivateApiTest() = default; + + gin::ModuleRegistry* module_registry() { + return gin::ModuleRegistry::From(env()->context()->v8_context()); + } + + private: + DISALLOW_COPY_AND_ASSIGN(MojoPrivateApiTest); +}; + +TEST_F(MojoPrivateApiTest, Define) { + ASSERT_NO_FATAL_FAILURE(RunTest("mojo_private_unittest.js", "testDefine")); + EXPECT_EQ(1u, module_registry()->available_modules().count("testModule")); +} + +TEST_F(MojoPrivateApiTest, DefineRegistersModule) { + ASSERT_NO_FATAL_FAILURE( + RunTest("mojo_private_unittest.js", "testDefineRegistersModule")); + EXPECT_EQ(1u, module_registry()->available_modules().count("testModule")); + EXPECT_EQ(1u, module_registry()->available_modules().count("dependency")); +} + +TEST_F(MojoPrivateApiTest, DefineModuleDoesNotExist) { + ASSERT_NO_FATAL_FAILURE( + RunTest("mojo_private_unittest.js", "testDefineModuleDoesNotExist")); + EXPECT_EQ(0u, module_registry()->available_modules().count("testModule")); + EXPECT_EQ(0u, + module_registry()->available_modules().count("does not exist!")); + EXPECT_EQ(1u, module_registry()->unsatisfied_dependencies().count( + "does not exist!")); +} + +} // namespace extensions |