OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 return embedded_test_server() | 92 return embedded_test_server() |
93 ->GetURL("/" + host + ".html") | 93 ->GetURL("/" + host + ".html") |
94 .ReplaceComponents(replacements); | 94 .ReplaceComponents(replacements); |
95 } | 95 } |
96 | 96 |
97 void InitializeTestServer() { | 97 void InitializeTestServer() { |
98 base::FilePath test_data; | 98 base::FilePath test_data; |
99 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); | 99 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data)); |
100 embedded_test_server()->ServeFilesFromDirectory( | 100 embedded_test_server()->ServeFilesFromDirectory( |
101 test_data.AppendASCII("extensions/content_capabilities")); | 101 test_data.AppendASCII("extensions/content_capabilities")); |
102 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 102 ASSERT_TRUE(embedded_test_server()->Start()); |
103 host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); | 103 host_resolver()->AddRule("*", embedded_test_server()->base_url().host()); |
104 } | 104 } |
105 | 105 |
106 // Run some script in the context of the given origin and in the presence of | 106 // Run some script in the context of the given origin and in the presence of |
107 // the given extension. This is used to wrap calls into the JS test functions | 107 // the given extension. This is used to wrap calls into the JS test functions |
108 // defined by | 108 // defined by |
109 // $(DIR_TEST_DATA)/extensions/content_capabilities/capability_tests.js. | 109 // $(DIR_TEST_DATA)/extensions/content_capabilities/capability_tests.js. |
110 testing::AssertionResult TestScriptResult(const Extension* extension, | 110 testing::AssertionResult TestScriptResult(const Extension* extension, |
111 const GURL& url, | 111 const GURL& url, |
112 const char* code) { | 112 const char* code) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 // This extension has unlimitedStorage but doesn't grant it to foo.example.com | 229 // This extension has unlimitedStorage but doesn't grant it to foo.example.com |
230 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( | 230 scoped_refptr<const Extension> extension = LoadExtensionWithCapabilities( |
231 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"), | 231 MakeJSONList("http://foo.example.com/*"), MakeJSONList("clipboardRead"), |
232 MakeJSONList("unlimitedStorage")); | 232 MakeJSONList("unlimitedStorage")); |
233 | 233 |
234 EXPECT_TRUE( | 234 EXPECT_TRUE( |
235 HasUnlimitedStorage(extension.get(), extension->GetResourceURL(""))); | 235 HasUnlimitedStorage(extension.get(), extension->GetResourceURL(""))); |
236 EXPECT_FALSE( | 236 EXPECT_FALSE( |
237 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); | 237 HasUnlimitedStorage(extension.get(), GetTestURLFor("foo.example.com"))); |
238 } | 238 } |
OLD | NEW |