1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_apitest.h"
6 #include "extensions/test/extension_test_message_listener.h"
8 using extensions::Extension
;
10 // NB: We use LoadExtension instead of InstallExtension for shared modules so
11 // the public-keys in their manifests are used to generate the extension ID, so
12 // it can be imported correctly. We use InstallExtension otherwise so the loads
13 // happen through the CRX installer which validates imports.
15 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, SharedModule
) {
16 // import_pass depends on this shared module.
17 ASSERT_TRUE(LoadExtension(
18 test_data_dir_
.AppendASCII("shared_module").AppendASCII("shared")));
20 EXPECT_TRUE(RunExtensionTest("shared_module/import_pass"));
22 EXPECT_FALSE(InstallExtension(
23 test_data_dir_
.AppendASCII("shared_module")
24 .AppendASCII("import_wrong_version"), 0));
25 EXPECT_FALSE(InstallExtension(
26 test_data_dir_
.AppendASCII("shared_module")
27 .AppendASCII("import_non_existent"), 0));
30 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, SharedModuleWhitelist
) {
31 ASSERT_TRUE(LoadExtension(
32 test_data_dir_
.AppendASCII("shared_module")
33 .AppendASCII("shared_whitelist")));
35 EXPECT_FALSE(InstallExtension(
36 test_data_dir_
.AppendASCII("shared_module")
37 .AppendASCII("import_not_in_whitelist"), 0));
40 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, SharedModuleInstallEvent
) {
41 ExtensionTestMessageListener
listener1("ready", false);
43 const Extension
* extension
= LoadExtension(
44 test_data_dir_
.AppendASCII("shared_module").AppendASCII("shared"));
45 ASSERT_TRUE(extension
);
46 ASSERT_TRUE(InstallExtension(
47 test_data_dir_
.AppendASCII("shared_module").AppendASCII("import_pass"),
51 IN_PROC_BROWSER_TEST_F(ExtensionApiTest
, SharedModuleLocale
) {
52 const Extension
* extension
= LoadExtension(
53 test_data_dir_
.AppendASCII("shared_module").AppendASCII("shared"));
54 ASSERT_TRUE(extension
);
56 EXPECT_TRUE(RunExtensionTest("shared_module/import_locales"));