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

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

Issue 12792005: Allow extensions on chrome:// URLs, when flag is set and permission is explicitly requested (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove allowed_schemes attribute from url_pattern; go back to re-using valid_schemes Created 7 years, 9 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 return apis->count(api_name); 298 return apis->count(api_name);
299 } 299 }
300 300
301 TEST(ExtensionAPI, URLMatching) { 301 TEST(ExtensionAPI, URLMatching) {
302 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration()); 302 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration());
303 303
304 // "app" API is available to all URLs that content scripts can be injected. 304 // "app" API is available to all URLs that content scripts can be injected.
305 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html")); 305 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html"));
306 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net")); 306 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net"));
307 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html")); 307 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html"));
308 EXPECT_TRUE(MatchesURL(api.get(), "app", "chrome://flags"));
308 309
309 // But not internal URLs (for chrome-extension:// the app API is injected by 310 // But not internal URLs (for chrome-extension:// the app API is injected by
310 // GetSchemasForExtension). 311 // GetSchemasForExtension).
311 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags")); 312 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags"));
312 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags"));
313 EXPECT_FALSE(MatchesURL(api.get(), "app", 313 EXPECT_FALSE(MatchesURL(api.get(), "app",
314 "chrome-extension://fakeextension")); 314 "chrome-extension://fakeextension"));
315 315
316 // "storage" API (for example) isn't available to any URLs. 316 // "storage" API (for example) isn't available to any URLs.
317 EXPECT_FALSE(MatchesURL(api.get(), "storage", 317 EXPECT_FALSE(MatchesURL(api.get(), "storage",
318 "http://example.com/example.html")); 318 "http://example.com/example.html"));
319 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net")); 319 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net"));
320 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html")); 320 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html"));
321 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags")); 321 EXPECT_FALSE(MatchesURL(api.get(), "storage", "about:flags"));
322 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags")); 322 EXPECT_FALSE(MatchesURL(api.get(), "storage", "chrome://flags"));
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 GetDictionaryFromList(dict, "parameters", 0, &sub_dict); 484 GetDictionaryFromList(dict, "parameters", 0, &sub_dict);
485 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 485 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
486 EXPECT_EQ("test.foo.TestType", type); 486 EXPECT_EQ("test.foo.TestType", type);
487 GetDictionaryFromList(dict, "parameters", 1, &sub_dict); 487 GetDictionaryFromList(dict, "parameters", 1, &sub_dict);
488 EXPECT_TRUE(sub_dict->GetString("$ref", &type)); 488 EXPECT_TRUE(sub_dict->GetString("$ref", &type));
489 EXPECT_EQ("fully.qualified.Type", type); 489 EXPECT_EQ("fully.qualified.Type", type);
490 } 490 }
491 491
492 } // namespace 492 } // namespace
493 } // namespace extensions 493 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698