| 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/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h" |
| 7 #include "chrome/common/extensions/extension_manifest_constants.h" | 8 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 9 #include "chrome/common/extensions/manifest_handler.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 11 |
| 10 namespace errors = extension_manifest_errors; | 12 namespace extensions { |
| 11 | 13 |
| 12 TEST_F(ExtensionManifestTest, OptionsPageInApps) { | 14 class OptionsManifestTest : public ExtensionManifestTest { |
| 15 protected: |
| 16 virtual void SetUp() OVERRIDE { |
| 17 ExtensionManifestTest::SetUp(); |
| 18 ManifestHandler::Register(extension_manifest_keys::kOptionsPage, |
| 19 new OptionsPageHandler); |
| 20 } |
| 21 }; |
| 22 |
| 23 TEST_F(OptionsManifestTest, OptionsPageInApps) { |
| 13 scoped_refptr<extensions::Extension> extension; | 24 scoped_refptr<extensions::Extension> extension; |
| 14 | 25 |
| 15 // Allow options page with absolute URL in hosted apps. | 26 // Allow options page with absolute URL in hosted apps. |
| 16 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); | 27 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); |
| 17 EXPECT_STREQ("http", | 28 EXPECT_STREQ("http", |
| 18 extension->options_url().scheme().c_str()); | 29 ExtensionURL::GetOptionsURL(extension).scheme().c_str()); |
| 19 EXPECT_STREQ("example.com", | 30 EXPECT_STREQ("example.com", |
| 20 extension->options_url().host().c_str()); | 31 ExtensionURL::GetOptionsURL(extension).host().c_str()); |
| 21 EXPECT_STREQ("options.html", | 32 EXPECT_STREQ( |
| 22 extension->options_url().ExtractFileName().c_str()); | 33 "options.html", |
| 34 ExtensionURL::GetOptionsURL(extension).ExtractFileName().c_str()); |
| 23 | 35 |
| 24 Testcase testcases[] = { | 36 Testcase testcases[] = { |
| 25 // Forbid options page with relative URL in hosted apps. | 37 // Forbid options page with relative URL in hosted apps. |
| 26 Testcase("hosted_app_relative_options.json", | 38 Testcase("hosted_app_relative_options.json", |
| 27 errors::kInvalidOptionsPageInHostedApp), | 39 errors::kInvalidOptionsPageInHostedApp), |
| 28 | 40 |
| 29 // Forbid options page with non-(http|https) scheme in hosted app. | 41 // Forbid options page with non-(http|https) scheme in hosted app. |
| 30 Testcase("hosted_app_file_options.json", | 42 Testcase("hosted_app_file_options.json", |
| 31 errors::kInvalidOptionsPageInHostedApp), | 43 errors::kInvalidOptionsPageInHostedApp), |
| 32 | 44 |
| 33 // Forbid absolute URL for options page in packaged apps. | 45 // Forbid absolute URL for options page in packaged apps. |
| 34 Testcase("packaged_app_absolute_options.json", | 46 Testcase("packaged_app_absolute_options.json", |
| 35 errors::kInvalidOptionsPageExpectUrlInPackage) | 47 errors::kInvalidOptionsPageExpectUrlInPackage) |
| 36 }; | 48 }; |
| 37 RunTestcases(testcases, arraysize(testcases), | 49 RunTestcases(testcases, arraysize(testcases), |
| 38 EXPECT_TYPE_ERROR); | 50 EXPECT_TYPE_ERROR); |
| 39 } | 51 } |
| 52 |
| 53 } // namespace extensions |
| OLD | NEW |