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

Unified Diff: chrome/common/secure_origin_whitelist_unittest.cc

Issue 2157363004: Fix SecureOriginWhiteListTest.UnsafelyTreatInsecureOriginAsSecure to not leak test state (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/common/origin_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/secure_origin_whitelist_unittest.cc
diff --git a/chrome/common/secure_origin_whitelist_unittest.cc b/chrome/common/secure_origin_whitelist_unittest.cc
index 261456518a38a4c7f90fc552cd6e69bc4ea2f1c9..6865d15b805d0f48074888bd8cc6e0265a075bd7 100644
--- a/chrome/common/secure_origin_whitelist_unittest.cc
+++ b/chrome/common/secure_origin_whitelist_unittest.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/command_line.h"
+#include "base/test/scoped_command_line.h"
#include "chrome/common/chrome_switches.h"
#include "content/public/common/origin_util.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -12,16 +13,23 @@ using content::IsOriginSecure;
namespace chrome {
-TEST(SecureOriginWhiteList, UnsafelyTreatInsecureOriginAsSecure) {
+class SecureOriginWhiteListTest : public testing::Test {
+ void TearDown() override {
+ // Ensure that we reset the whitelisted origins without any flags applied.
+ content::ResetSchemesAndOriginsWhitelistForTesting();
+ };
+};
+
+TEST_F(SecureOriginWhiteListTest, UnsafelyTreatInsecureOriginAsSecure) {
EXPECT_FALSE(content::IsOriginSecure(GURL("http://example.com/a.html")));
EXPECT_FALSE(
content::IsOriginSecure(GURL("http://127.example.com/a.html")));
-
// Add http://example.com and http://127.example.com to whitelist by
// command-line and see if they are now considered secure origins.
// (The command line is applied via
// ChromeContentClient::AddSecureSchemesAndOrigins)
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ base::test::ScopedCommandLine scoped_command_line;
+ base::CommandLine* command_line = scoped_command_line.GetProcessCommandLine();
command_line->AppendSwitchASCII(
switches::kUnsafelyTreatInsecureOriginAsSecure,
"http://example.com,http://127.example.com");
« no previous file with comments | « no previous file | content/common/origin_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698