This source file includes following definitions.
- TEST_F
#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_handlers/csp_info.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace extensions {
namespace errors = manifest_errors;
class SandboxedPagesManifestTest : public ExtensionManifestTest {
};
TEST_F(SandboxedPagesManifestTest, SandboxedPages) {
scoped_refptr<Extension> extension1(
LoadAndExpectSuccess("sandboxed_pages_valid_1.json"));
scoped_refptr<Extension> extension2(
LoadAndExpectSuccess("sandboxed_pages_valid_2.json"));
scoped_refptr<Extension> extension3(
LoadAndExpectSuccess("sandboxed_pages_valid_3.json"));
scoped_refptr<Extension> extension4(
LoadAndExpectSuccess("sandboxed_pages_valid_4.json"));
scoped_refptr<Extension> extension5(
LoadAndExpectSuccess("sandboxed_pages_valid_5.json"));
const char kSandboxedCSP[] = "sandbox allow-scripts allow-forms allow-popups";
const char kDefaultCSP[] =
"script-src 'self' chrome-extension-resource:; object-src 'self'";
const char kCustomSandboxedCSP[] =
"sandbox; script-src: https://www.google.com";
EXPECT_EQ(
kSandboxedCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/test"));
EXPECT_EQ(
kDefaultCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension1.get(), "/none"));
EXPECT_EQ(
kDefaultCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension2.get(), "/test"));
EXPECT_EQ(
kCustomSandboxedCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/test"));
EXPECT_EQ(
kDefaultCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension3.get(), "/none"));
EXPECT_EQ(
kSandboxedCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension4.get(), "/test"));
EXPECT_EQ(kSandboxedCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension5.get(),
"/path/test.ext"));
EXPECT_EQ(
kDefaultCSP,
CSPInfo::GetResourceContentSecurityPolicy(extension5.get(), "/test"));
Testcase testcases[] = {
Testcase("sandboxed_pages_invalid_1.json",
errors::kInvalidSandboxedPagesList),
Testcase("sandboxed_pages_invalid_2.json",
errors::kInvalidSandboxedPage),
Testcase("sandboxed_pages_invalid_3.json",
errors::kInvalidSandboxedPagesCSP),
Testcase("sandboxed_pages_invalid_4.json",
errors::kInvalidSandboxedPagesCSP),
Testcase("sandboxed_pages_invalid_5.json",
errors::kInvalidSandboxedPagesCSP)
};
RunTestcases(testcases, arraysize(testcases),
EXPECT_TYPE_ERROR);
}
}