Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: trunk/src/chrome/common/extensions/api/extension_api_unittest.cc

Issue 13852042: Revert 195143 "Prevent chrome.app JSON schema from loading on ev..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/api/extension_api.h" 5 #include "chrome/common/extensions/api/extension_api.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 { "test1", true, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL() }, 165 { "test1", true, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL() },
166 { "test1", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() }, 166 { "test1", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
167 { "test2", true, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") }, 167 { "test2", true, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") },
168 { "test2", false, Feature::BLESSED_EXTENSION_CONTEXT, 168 { "test2", false, Feature::BLESSED_EXTENSION_CONTEXT,
169 GURL("http://google.com") }, 169 GURL("http://google.com") },
170 { "test2.foo", false, Feature::WEB_PAGE_CONTEXT, 170 { "test2.foo", false, Feature::WEB_PAGE_CONTEXT,
171 GURL("http://google.com") }, 171 GURL("http://google.com") },
172 { "test2.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() }, 172 { "test2.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
173 { "test3", false, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") }, 173 { "test3", false, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") },
174 { "test3.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") }, 174 { "test3.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://google.com") },
175 { "test3.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, 175 { "test3.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
176 GURL("http://bad.com") }, 176 { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
177 { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT, 177 { "test4.foo", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
178 GURL("http://bad.com") }, 178 { "test4.foo", false, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL() },
179 { "test4.foo", false, Feature::BLESSED_EXTENSION_CONTEXT,
180 GURL("http://bad.com") },
181 { "test4.foo", false, Feature::UNBLESSED_EXTENSION_CONTEXT,
182 GURL("http://bad.com") },
183 { "test4.foo.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() }, 179 { "test4.foo.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
184 { "test5", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 180 { "test5", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
185 { "test5", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 181 { "test5", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
186 { "test5.blah", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 182 { "test5.blah", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
187 { "test5.blah", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 183 { "test5.blah", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
188 { "test6", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 184 { "test6", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
189 { "test6.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 185 { "test6.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
190 { "test7", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 186 { "test7", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
191 { "test7.foo", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 187 { "test7.foo", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
192 { "test7.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 188 { "test7.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 373 }
378 374
379 TEST_F(ExtensionAPITest, URLMatching) { 375 TEST_F(ExtensionAPITest, URLMatching) {
380 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration()); 376 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration());
381 377
382 // "app" API is available to all URLs that content scripts can be injected. 378 // "app" API is available to all URLs that content scripts can be injected.
383 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html")); 379 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html"));
384 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net")); 380 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net"));
385 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html")); 381 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html"));
386 382
387 // But not internal URLs. 383 // But not internal URLs (for chrome-extension:// the app API is injected by
384 // GetSchemasForExtension).
388 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags")); 385 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags"));
389 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags")); 386 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags"));
390 387 EXPECT_FALSE(MatchesURL(api.get(), "app",
391 // "app" should be available to chrome-extension URLs.
392 EXPECT_TRUE(MatchesURL(api.get(), "app",
393 "chrome-extension://fakeextension")); 388 "chrome-extension://fakeextension"));
394 389
395 // "storage" API (for example) isn't available to any URLs. 390 // "storage" API (for example) isn't available to any URLs.
396 EXPECT_FALSE(MatchesURL(api.get(), "storage", 391 EXPECT_FALSE(MatchesURL(api.get(), "storage",
397 "http://example.com/example.html")); 392 "http://example.com/example.html"));
398 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net")); 393 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net"));
399 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html")); 394 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html"));
400 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags")); 395 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags"));
401 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags")); 396 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags"));
402 EXPECT_FALSE(MatchesURL(api.get(), "storage", 397 EXPECT_FALSE(MatchesURL(api.get(), "storage",
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 GetDictionaryFromList(dict, "parameters", 0, &sub_dict); 552 GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
558 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 553 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
559 EXPECT_EQ("test.foo.TestType", type); 554 EXPECT_EQ("test.foo.TestType", type);
560 GetDictionaryFromList(dict, "parameters", 1, &sub_dict); 555 GetDictionaryFromList(dict, "parameters", 1, &sub_dict);
561 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 556 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
562 EXPECT_EQ("fully.qualified.Type", type); 557 EXPECT_EQ("fully.qualified.Type", type);
563 } 558 }
564 559
565 } // namespace 560 } // namespace
566 } // namespace extensions 561 } // namespace extensions
OLDNEW
« no previous file with comments | « trunk/src/chrome/common/extensions/api/app.json ('k') | trunk/src/chrome/renderer/extensions/chrome_v8_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698