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

Side by Side Diff: extensions/browser/api/file_handlers/mime_util_unittest.cc

Issue 2802433004: ExtensionsTest: Move initialization to SetUp and avoid potential UAF. (Closed)
Patch Set: Avoid UAF. Created 3 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/browser/api/file_handlers/mime_util.h" 5 #include "extensions/browser/api/file_handlers/mime_util.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 } // namespace 50 } // namespace
51 51
52 class FileHandlersMimeUtilTest : public ExtensionsTest { 52 class FileHandlersMimeUtilTest : public ExtensionsTest {
53 protected: 53 protected:
54 FileHandlersMimeUtilTest() {} 54 FileHandlersMimeUtilTest() {}
55 ~FileHandlersMimeUtilTest() override {} 55 ~FileHandlersMimeUtilTest() override {}
56 56
57 void SetUp() override { 57 void SetUp() override {
58 ExtensionsTest::SetUp();
58 file_system_context_ = content::CreateFileSystemContextForTesting( 59 file_system_context_ = content::CreateFileSystemContextForTesting(
59 NULL, browser_context()->GetPath()); 60 NULL, browser_context()->GetPath());
60 61
61 EXPECT_TRUE(base::CreateTemporaryFile(&html_mime_file_path_)); 62 EXPECT_TRUE(base::CreateTemporaryFile(&html_mime_file_path_));
62 const std::string kSampleContent = "<html><body></body></html>"; 63 const std::string kSampleContent = "<html><body></body></html>";
63 EXPECT_TRUE(base::WriteFile(html_mime_file_path_, kSampleContent.c_str(), 64 EXPECT_TRUE(base::WriteFile(html_mime_file_path_, kSampleContent.c_str(),
64 kSampleContent.size())); 65 kSampleContent.size()));
65 } 66 }
66 67
67 content::TestBrowserThreadBundle thread_bundle_; 68 content::TestBrowserThreadBundle thread_bundle_;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 content::RunAllBlockingPoolTasksUntilIdle(); 138 content::RunAllBlockingPoolTasksUntilIdle();
138 139
139 ASSERT_EQ(3u, result.size()); 140 ASSERT_EQ(3u, result.size());
140 EXPECT_EQ("image/jpeg", result[0]); 141 EXPECT_EQ("image/jpeg", result[0]);
141 EXPECT_EQ("image/jpeg", result[1]); 142 EXPECT_EQ("image/jpeg", result[1]);
142 EXPECT_EQ("text/html", result[2]); 143 EXPECT_EQ("text/html", result[2]);
143 } 144 }
144 145
145 } // namespace app_file_handler_util 146 } // namespace app_file_handler_util
146 } // namespace extensions 147 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698