| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 6 #include "chrome/common/extensions/manifest_handler.h" |
| 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 7 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | 8 #include "chrome/common/extensions/manifest_url_info.h" |
| 7 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/options_page_handler.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 11 |
| 12 namespace keys = extension_manifest_keys; |
| 10 namespace errors = extension_manifest_errors; | 13 namespace errors = extension_manifest_errors; |
| 11 | 14 |
| 12 TEST_F(ExtensionManifestTest, OptionsPageInApps) { | 15 namespace { |
| 16 |
| 17 class OptionsPageManifestTest : public ExtensionManifestTest { |
| 18 virtual void SetUp() OVERRIDE { |
| 19 ExtensionManifestTest::SetUp(); |
| 20 extensions::ManifestHandler::Register(keys::kOptionsPage, |
| 21 new extensions::OptionsPageHandler); |
| 22 } |
| 23 }; |
| 24 |
| 25 TEST_F(OptionsPageManifestTest, OptionsPageInApps) { |
| 13 scoped_refptr<extensions::Extension> extension; | 26 scoped_refptr<extensions::Extension> extension; |
| 14 | 27 |
| 15 // Allow options page with absolute URL in hosted apps. | 28 // Allow options page with absolute URL in hosted apps. |
| 16 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); | 29 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); |
| 17 EXPECT_STREQ("http", | 30 EXPECT_STREQ( |
| 18 extension->options_url().scheme().c_str()); | 31 "http", |
| 19 EXPECT_STREQ("example.com", | 32 extensions::ManifestURLInfo::GetOptionsPage(extension).scheme().c_str()); |
| 20 extension->options_url().host().c_str()); | 33 EXPECT_STREQ( |
| 21 EXPECT_STREQ("options.html", | 34 "example.com", |
| 22 extension->options_url().ExtractFileName().c_str()); | 35 extensions::ManifestURLInfo::GetOptionsPage(extension).host().c_str()); |
| 36 EXPECT_STREQ( |
| 37 "options.html", |
| 38 extensions::ManifestURLInfo:: |
| 39 GetOptionsPage(extension).ExtractFileName().c_str()); |
| 23 | 40 |
| 24 Testcase testcases[] = { | 41 Testcase testcases[] = { |
| 25 // Forbid options page with relative URL in hosted apps. | 42 // Forbid options page with relative URL in hosted apps. |
| 26 Testcase("hosted_app_relative_options.json", | 43 Testcase("hosted_app_relative_options.json", |
| 27 errors::kInvalidOptionsPageInHostedApp), | 44 errors::kInvalidOptionsPageInHostedApp), |
| 28 | 45 |
| 29 // Forbid options page with non-(http|https) scheme in hosted app. | 46 // Forbid options page with non-(http|https) scheme in hosted app. |
| 30 Testcase("hosted_app_file_options.json", | 47 Testcase("hosted_app_file_options.json", |
| 31 errors::kInvalidOptionsPageInHostedApp), | 48 errors::kInvalidOptionsPageInHostedApp), |
| 32 | 49 |
| 33 // Forbid absolute URL for options page in packaged apps. | 50 // Forbid absolute URL for options page in packaged apps. |
| 34 Testcase("packaged_app_absolute_options.json", | 51 Testcase("packaged_app_absolute_options.json", |
| 35 errors::kInvalidOptionsPageExpectUrlInPackage) | 52 errors::kInvalidOptionsPageExpectUrlInPackage) |
| 36 }; | 53 }; |
| 37 RunTestcases(testcases, arraysize(testcases), | 54 RunTestcases(testcases, arraysize(testcases), |
| 38 EXPECT_TYPE_ERROR); | 55 EXPECT_TYPE_ERROR); |
| 39 } | 56 } |
| 57 |
| 58 } // namespace |
| OLD | NEW |