OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/stringprintf.h" | 5 #include "base/stringprintf.h" |
6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
7 #include "chrome/browser/background/background_contents_service.h" | 7 #include "chrome/browser/background/background_contents_service.h" |
8 #include "chrome/browser/background/background_contents_service_factory.h" | 8 #include "chrome/browser/background/background_contents_service_factory.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #endif | 54 #endif |
55 | 55 |
56 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, MAYBE_Basic) { | 56 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, MAYBE_Basic) { |
57 host_resolver()->AddRule("a.com", "127.0.0.1"); | 57 host_resolver()->AddRule("a.com", "127.0.0.1"); |
58 ASSERT_TRUE(StartTestServer()); | 58 ASSERT_TRUE(StartTestServer()); |
59 | 59 |
60 std::string app_manifest = base::StringPrintf( | 60 std::string app_manifest = base::StringPrintf( |
61 "{" | 61 "{" |
62 " \"name\": \"App\"," | 62 " \"name\": \"App\"," |
63 " \"version\": \"0.1\"," | 63 " \"version\": \"0.1\"," |
| 64 " \"manifest_version\": 2," |
64 " \"app\": {" | 65 " \"app\": {" |
65 " \"urls\": [" | 66 " \"urls\": [" |
66 " \"http://a.com/\"" | 67 " \"http://a.com/\"" |
67 " ]," | 68 " ]," |
68 " \"launch\": {" | 69 " \"launch\": {" |
69 " \"web_url\": \"http://a.com:%d/\"" | 70 " \"web_url\": \"http://a.com:%d/\"" |
70 " }" | 71 " }" |
71 " }," | 72 " }," |
72 " \"permissions\": [\"background\"]" | 73 " \"permissions\": [\"background\"]" |
73 "}", | 74 "}", |
74 test_server()->host_port_pair().port()); | 75 test_server()->host_port_pair().port()); |
75 | 76 |
76 FilePath app_dir; | 77 FilePath app_dir; |
77 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); | 78 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); |
78 ASSERT_TRUE(LoadExtension(app_dir)); | 79 ASSERT_TRUE(LoadExtension(app_dir)); |
79 ASSERT_TRUE(RunExtensionTest("app_background_page/basic")) << message_; | 80 ASSERT_TRUE(RunExtensionTest("app_background_page/basic")) << message_; |
80 } | 81 } |
81 | 82 |
82 // Crashy, http://crbug.com/69215. | 83 // Crashy, http://crbug.com/69215. |
83 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) { | 84 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, DISABLED_LacksPermission) { |
84 host_resolver()->AddRule("a.com", "127.0.0.1"); | 85 host_resolver()->AddRule("a.com", "127.0.0.1"); |
85 ASSERT_TRUE(StartTestServer()); | 86 ASSERT_TRUE(StartTestServer()); |
86 | 87 |
87 std::string app_manifest = base::StringPrintf( | 88 std::string app_manifest = base::StringPrintf( |
88 "{" | 89 "{" |
89 " \"name\": \"App\"," | 90 " \"name\": \"App\"," |
90 " \"version\": \"0.1\"," | 91 " \"version\": \"0.1\"," |
| 92 " \"manifest_version\": 2," |
91 " \"app\": {" | 93 " \"app\": {" |
92 " \"urls\": [" | 94 " \"urls\": [" |
93 " \"http://a.com/\"" | 95 " \"http://a.com/\"" |
94 " ]," | 96 " ]," |
95 " \"launch\": {" | 97 " \"launch\": {" |
96 " \"web_url\": \"http://a.com:%d/\"" | 98 " \"web_url\": \"http://a.com:%d/\"" |
97 " }" | 99 " }" |
98 " }" | 100 " }" |
99 "}", | 101 "}", |
100 test_server()->host_port_pair().port()); | 102 test_server()->host_port_pair().port()); |
101 | 103 |
102 FilePath app_dir; | 104 FilePath app_dir; |
103 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); | 105 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); |
104 ASSERT_TRUE(LoadExtension(app_dir)); | 106 ASSERT_TRUE(LoadExtension(app_dir)); |
105 ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission")) | 107 ASSERT_TRUE(RunExtensionTest("app_background_page/lacks_permission")) |
106 << message_; | 108 << message_; |
107 } | 109 } |
108 | 110 |
109 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) { | 111 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, ManifestBackgroundPage) { |
110 host_resolver()->AddRule("a.com", "127.0.0.1"); | 112 host_resolver()->AddRule("a.com", "127.0.0.1"); |
111 ASSERT_TRUE(StartTestServer()); | 113 ASSERT_TRUE(StartTestServer()); |
112 | 114 |
113 std::string app_manifest = base::StringPrintf( | 115 std::string app_manifest = base::StringPrintf( |
114 "{" | 116 "{" |
115 " \"name\": \"App\"," | 117 " \"name\": \"App\"," |
116 " \"version\": \"0.1\"," | 118 " \"version\": \"0.1\"," |
| 119 " \"manifest_version\": 2," |
117 " \"app\": {" | 120 " \"app\": {" |
118 " \"urls\": [" | 121 " \"urls\": [" |
119 " \"http://a.com/\"" | 122 " \"http://a.com/\"" |
120 " ]," | 123 " ]," |
121 " \"launch\": {" | 124 " \"launch\": {" |
122 " \"web_url\": \"http://a.com:%d/\"" | 125 " \"web_url\": \"http://a.com:%d/\"" |
123 " }" | 126 " }" |
124 " }," | 127 " }," |
125 " \"permissions\": [\"background\"]," | 128 " \"permissions\": [\"background\"]," |
126 " \"background_page\": \"http://a.com:%d/test.html\"" | 129 " \"background_page\": \"http://a.com:%d/test.html\"" |
(...skipping 12 matching lines...) Expand all Loading... |
139 } | 142 } |
140 | 143 |
141 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) { | 144 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoBackgroundPages) { |
142 host_resolver()->AddRule("a.com", "127.0.0.1"); | 145 host_resolver()->AddRule("a.com", "127.0.0.1"); |
143 ASSERT_TRUE(StartTestServer()); | 146 ASSERT_TRUE(StartTestServer()); |
144 | 147 |
145 std::string app_manifest = base::StringPrintf( | 148 std::string app_manifest = base::StringPrintf( |
146 "{" | 149 "{" |
147 " \"name\": \"App\"," | 150 " \"name\": \"App\"," |
148 " \"version\": \"0.1\"," | 151 " \"version\": \"0.1\"," |
| 152 " \"manifest_version\": 2," |
149 " \"app\": {" | 153 " \"app\": {" |
150 " \"urls\": [" | 154 " \"urls\": [" |
151 " \"http://a.com/\"" | 155 " \"http://a.com/\"" |
152 " ]," | 156 " ]," |
153 " \"launch\": {" | 157 " \"launch\": {" |
154 " \"web_url\": \"http://a.com:%d/\"" | 158 " \"web_url\": \"http://a.com:%d/\"" |
155 " }" | 159 " }" |
156 " }," | 160 " }," |
157 " \"permissions\": [\"background\"]" | 161 " \"permissions\": [\"background\"]" |
158 "}", | 162 "}", |
159 test_server()->host_port_pair().port()); | 163 test_server()->host_port_pair().port()); |
160 | 164 |
161 FilePath app_dir; | 165 FilePath app_dir; |
162 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); | 166 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); |
163 ASSERT_TRUE(LoadExtension(app_dir)); | 167 ASSERT_TRUE(LoadExtension(app_dir)); |
164 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_; | 168 ASSERT_TRUE(RunExtensionTest("app_background_page/two_pages")) << message_; |
165 } | 169 } |
166 | 170 |
167 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoPagesWithManifest) { | 171 IN_PROC_BROWSER_TEST_F(AppBackgroundPageApiTest, OpenTwoPagesWithManifest) { |
168 host_resolver()->AddRule("a.com", "127.0.0.1"); | 172 host_resolver()->AddRule("a.com", "127.0.0.1"); |
169 ASSERT_TRUE(StartTestServer()); | 173 ASSERT_TRUE(StartTestServer()); |
170 | 174 |
171 std::string app_manifest = base::StringPrintf( | 175 std::string app_manifest = base::StringPrintf( |
172 "{" | 176 "{" |
173 " \"name\": \"App\"," | 177 " \"name\": \"App\"," |
174 " \"version\": \"0.1\"," | 178 " \"version\": \"0.1\"," |
| 179 " \"manifest_version\": 2," |
175 " \"app\": {" | 180 " \"app\": {" |
176 " \"urls\": [" | 181 " \"urls\": [" |
177 " \"http://a.com/\"" | 182 " \"http://a.com/\"" |
178 " ]," | 183 " ]," |
179 " \"launch\": {" | 184 " \"launch\": {" |
180 " \"web_url\": \"http://a.com:%d/\"" | 185 " \"web_url\": \"http://a.com:%d/\"" |
181 " }" | 186 " }" |
182 " }," | 187 " }," |
183 " \"background_page\": \"http://a.com:%d/bg.html\"," | 188 " \"background_page\": \"http://a.com:%d/bg.html\"," |
184 " \"permissions\": [\"background\"]" | 189 " \"permissions\": [\"background\"]" |
185 "}", | 190 "}", |
186 test_server()->host_port_pair().port(), | 191 test_server()->host_port_pair().port(), |
187 test_server()->host_port_pair().port()); | 192 test_server()->host_port_pair().port()); |
188 | 193 |
189 FilePath app_dir; | 194 FilePath app_dir; |
190 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); | 195 ASSERT_TRUE(CreateApp(app_manifest, &app_dir)); |
191 ASSERT_TRUE(LoadExtension(app_dir)); | 196 ASSERT_TRUE(LoadExtension(app_dir)); |
192 ASSERT_TRUE(RunExtensionTest("app_background_page/two_with_manifest")) << | 197 ASSERT_TRUE(RunExtensionTest("app_background_page/two_with_manifest")) << |
193 message_; | 198 message_; |
194 } | 199 } |
OLD | NEW |