OLD | NEW |
---|---|
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 "extensions/common/extension_api.h" | 5 #include "extensions/common/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 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 } | 666 } |
667 | 667 |
668 TEST(ExtensionAPITest, URLMatching) { | 668 TEST(ExtensionAPITest, URLMatching) { |
669 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration()); | 669 scoped_ptr<ExtensionAPI> api(ExtensionAPI::CreateWithDefaultConfiguration()); |
670 | 670 |
671 // "app" API is available to all URLs that content scripts can be injected. | 671 // "app" API is available to all URLs that content scripts can be injected. |
672 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html")); | 672 EXPECT_TRUE(MatchesURL(api.get(), "app", "http://example.com/example.html")); |
673 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net")); | 673 EXPECT_TRUE(MatchesURL(api.get(), "app", "https://blah.net")); |
674 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html")); | 674 EXPECT_TRUE(MatchesURL(api.get(), "app", "file://somefile.html")); |
675 | 675 |
676 // But not internal URLs. | 676 // Also to internal URLs. |
677 EXPECT_FALSE(MatchesURL(api.get(), "app", "about:flags")); | 677 EXPECT_TRUE(MatchesURL(api.get(), "app", "about:flags")); |
678 EXPECT_FALSE(MatchesURL(api.get(), "app", "chrome://flags")); | 678 EXPECT_TRUE(MatchesURL(api.get(), "app", "chrome://flags")); |
not at google - send to devlin
2014/08/06 17:26:18
Ah I think you caught an actual bug here. we shoul
sadrul
2014/08/06 18:51:51
Done.
| |
679 | 679 |
680 // "app" should be available to chrome-extension URLs. | 680 // "app" should be available to chrome-extension URLs. |
681 EXPECT_TRUE(MatchesURL(api.get(), "app", | 681 EXPECT_TRUE(MatchesURL(api.get(), "app", |
682 "chrome-extension://fakeextension")); | 682 "chrome-extension://fakeextension")); |
683 | 683 |
684 // "storage" API (for example) isn't available to any URLs. | 684 // "storage" API (for example) isn't available to any URLs. |
685 EXPECT_FALSE(MatchesURL(api.get(), "storage", | 685 EXPECT_FALSE(MatchesURL(api.get(), "storage", |
686 "http://example.com/example.html")); | 686 "http://example.com/example.html")); |
687 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net")); | 687 EXPECT_FALSE(MatchesURL(api.get(), "storage", "https://blah.net")); |
688 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html")); | 688 EXPECT_FALSE(MatchesURL(api.get(), "storage", "file://somefile.html")); |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 extension.get(), | 927 extension.get(), |
928 Feature::BLESSED_EXTENSION_CONTEXT, | 928 Feature::BLESSED_EXTENSION_CONTEXT, |
929 GURL()).is_available()); | 929 GURL()).is_available()); |
930 EXPECT_FALSE(extension_api->IsAvailable("pageAction", | 930 EXPECT_FALSE(extension_api->IsAvailable("pageAction", |
931 extension.get(), | 931 extension.get(), |
932 Feature::BLESSED_EXTENSION_CONTEXT, | 932 Feature::BLESSED_EXTENSION_CONTEXT, |
933 GURL()).is_available()); | 933 GURL()).is_available()); |
934 } | 934 } |
935 | 935 |
936 } // namespace extensions | 936 } // namespace extensions |
OLD | NEW |