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

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

Issue 13604005: Prevent chrome.app JSON schema from loading on every page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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
« no previous file with comments | « chrome/common/extensions/api/app.json ('k') | chrome/renderer/extensions/chrome_v8_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, GURL() }, 175 { "test3.foo", true, Feature::BLESSED_EXTENSION_CONTEXT,
176 { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 176 GURL("http://bad.com") },
177 { "test4.foo", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 177 { "test4", true, Feature::BLESSED_EXTENSION_CONTEXT,
178 { "test4.foo", false, Feature::UNBLESSED_EXTENSION_CONTEXT, GURL() }, 178 GURL("http://bad.com") },
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") },
179 { "test4.foo.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() }, 183 { "test4.foo.foo", true, Feature::CONTENT_SCRIPT_CONTEXT, GURL() },
180 { "test5", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 184 { "test5", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
181 { "test5", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 185 { "test5", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
182 { "test5.blah", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 186 { "test5.blah", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
183 { "test5.blah", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 187 { "test5.blah", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
184 { "test6", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 188 { "test6", false, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
185 { "test6.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() }, 189 { "test6.foo", true, Feature::BLESSED_EXTENSION_CONTEXT, GURL() },
186 { "test7", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 190 { "test7", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
187 { "test7.foo", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") }, 191 { "test7.foo", false, Feature::WEB_PAGE_CONTEXT, GURL("http://bar.com") },
188 { "test7.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") }, 192 { "test7.foo", true, Feature::WEB_PAGE_CONTEXT, GURL("http://foo.com") },
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 377 }
374 378
375 TEST_F(ExtensionAPITest, URLMatching) { 379 TEST_F(ExtensionAPITest, URLMatching) {
376 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration()); 380 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration());
377 381
378 // "app" API is available to all URLs that content scripts can be injected. 382 // "app" API is available to all URLs that content scripts can be injected.
379 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html")); 383 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html"));
380 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net")); 384 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net"));
381 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html")); 385 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html"));
382 386
383 // But not internal URLs (for chrome-extension:// the app API is injected by 387 // But not internal URLs.
384 // GetSchemasForExtension).
385 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags")); 388 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags"));
386 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags")); 389 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags"));
387 EXPECT_FALSE(MatchesURL(api.get(), "app", 390
391 // "app" should be available to chrome-extension URLs.
392 EXPECT_TRUE(MatchesURL(api.get(), "app",
388 "chrome-extension://fakeextension")); 393 "chrome-extension://fakeextension"));
389 394
390 // "storage" API (for example) isn't available to any URLs. 395 // "storage" API (for example) isn't available to any URLs.
391 EXPECT_FALSE(MatchesURL(api.get(), "storage", 396 EXPECT_FALSE(MatchesURL(api.get(), "storage",
392 "http://example.com/example.html")); 397 "http://example.com/example.html"));
393 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net")); 398 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net"));
394 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html")); 399 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html"));
395 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags")); 400 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags"));
396 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags")); 401 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags"));
397 EXPECT_FALSE(MatchesURL(api.get(), "storage", 402 EXPECT_FALSE(MatchesURL(api.get(), "storage",
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 GetDictionaryFromList(dict, "parameters", 0, &sub_dict); 557 GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
553 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 558 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
554 EXPECT_EQ("test.foo.TestType", type); 559 EXPECT_EQ("test.foo.TestType", type);
555 GetDictionaryFromList(dict, "parameters", 1, &sub_dict); 560 GetDictionaryFromList(dict, "parameters", 1, &sub_dict);
556 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 561 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
557 EXPECT_EQ("fully.qualified.Type", type); 562 EXPECT_EQ("fully.qualified.Type", type);
558 } 563 }
559 564
560 } // namespace 565 } // namespace
561 } // namespace extensions 566 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/app.json ('k') | chrome/renderer/extensions/chrome_v8_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698