1 // Copyright 2014 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 "base/strings/string_number_conversions.h"
6 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
7 #include "extensions/common/error_utils.h"
8 #include "extensions/common/manifest_constants.h"
9 #include "extensions/common/manifest_handlers/webview_info.h"
11 using extensions::ErrorUtils
;
12 using extensions::Extension
;
13 using extensions::WebviewInfo
;
14 namespace errors
= extensions::manifest_errors
;
16 class WebviewAccessibleResourcesManifestTest
: public ExtensionManifestTest
{
19 TEST_F(WebviewAccessibleResourcesManifestTest
, WebviewAccessibleResources
) {
20 // Manifest version 2 with webview accessible resources specified.
21 scoped_refptr
<Extension
> extension1(
22 LoadAndExpectSuccess("webview_accessible_resources_1.json"));
25 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
29 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
33 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
37 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
42 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
46 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
50 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
54 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
59 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
63 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
67 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
71 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
76 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
80 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
84 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
88 WebviewInfo::IsResourceWebviewAccessible(extension1
.get(),
93 TEST_F(WebviewAccessibleResourcesManifestTest
, InvalidManifest
) {
94 LoadAndExpectError("webview_accessible_resources_invalid1.json",
95 errors::kInvalidWebview
);
96 LoadAndExpectError("webview_accessible_resources_invalid2.json",
97 errors::kInvalidWebviewPartitionsList
);
98 LoadAndExpectError("webview_accessible_resources_invalid3.json",
99 errors::kInvalidWebviewPartitionsList
);
100 LoadAndExpectError("webview_accessible_resources_invalid4.json",
101 ErrorUtils::FormatErrorMessage(
102 errors::kInvalidWebviewPartition
, base::IntToString(0)));
103 LoadAndExpectError("webview_accessible_resources_invalid5.json",
104 errors::kInvalidWebviewPartitionName
);
105 LoadAndExpectError("webview_accessible_resources_invalid6.json",
106 errors::kInvalidWebviewAccessibleResourcesList
);
107 LoadAndExpectError("webview_accessible_resources_invalid7.json",
108 errors::kInvalidWebviewAccessibleResourcesList
);
109 LoadAndExpectError("webview_accessible_resources_invalid8.json",
110 ErrorUtils::FormatErrorMessage(
111 errors::kInvalidWebviewAccessibleResource
, base::IntToString(0)));