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

Side by Side Diff: third_party/WebKit/Source/platform/weborigin/SchemeRegistryTest.cpp

Issue 1383483007: Add scheme exceptions for isSecureContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fixes Created 5 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "config.h" 5 #include "config.h"
6 #include "platform/weborigin/SchemeRegistry.h" 6 #include "platform/weborigin/SchemeRegistry.h"
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 9
10 namespace blink { 10 namespace blink {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(kTestSchem e, SchemeRegistry::PolicyAreaImage); 43 SchemeRegistry::registerURLSchemeAsBypassingContentSecurityPolicy(kTestSchem e, SchemeRegistry::PolicyAreaImage);
44 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme)); 44 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme));
45 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc hemeUppercase)); 45 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc hemeUppercase));
46 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSch eme, SchemeRegistry::PolicyAreaImage)); 46 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSch eme, SchemeRegistry::PolicyAreaImage));
47 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSch emeUppercase, SchemeRegistry::PolicyAreaImage)); 47 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSch emeUppercase, SchemeRegistry::PolicyAreaImage));
48 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme, SchemeRegistry::PolicyAreaStyle)); 48 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme, SchemeRegistry::PolicyAreaStyle));
49 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc hemeUppercase, SchemeRegistry::PolicyAreaStyle)); 49 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc hemeUppercase, SchemeRegistry::PolicyAreaStyle));
50 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme2, SchemeRegistry::PolicyAreaImage)); 50 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassContentSecurityPolicy(kTestSc heme2, SchemeRegistry::PolicyAreaImage));
51 } 51 }
52 52
53 TEST_F(SchemeRegistryTest, BypassSecureContextCheck)
54 {
55 const char* scheme1 = "http";
56 const char* scheme2 = "https";
57 const char* scheme3 = "random-scheme";
58 const char* scheme4 = "RANDOM-SCHEME";
59
60 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme1));
61 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme2));
62 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme3));
63 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme4));
64
65 SchemeRegistry::registerURLSchemeBypassingSecureContextCheck("random-scheme" );
66
67 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme1));
68 EXPECT_FALSE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme2));
69 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme3));
70 EXPECT_TRUE(SchemeRegistry::schemeShouldBypassSecureContextCheck(scheme4));
71 }
72
53 } // namespace 73 } // namespace
54 } // namespace blink 74 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698