Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | |
|
mmenke
2017/06/05 18:31:33
nit: new files shouldn't use the "(c)"
satorux1
2017/06/06 08:52:37
Good catch! Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/bind.h" | |
| 6 #include "base/command_line.h" | |
|
mmenke
2017/06/05 18:31:33
Neither of these are used.
satorux1
2017/06/06 08:52:37
Good catch again. These are leftover from a previo
| |
| 7 #include "base/path_service.h" | |
| 8 #include "base/strings/utf_string_conversions.h" | |
|
mmenke
2017/06/05 18:31:33
Not used.
satorux1
2017/06/06 08:52:37
Done.
| |
| 9 #include "chrome/browser/net/chrome_network_delegate.h" | |
| 10 #include "chrome/browser/net/errorpage_test_util.h" | |
| 11 #include "chrome/browser/ui/browser.h" | |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 13 #include "chrome/common/chrome_paths.h" | |
| 14 #include "chrome/test/base/in_process_browser_test.h" | |
| 15 #include "chrome/test/base/ui_test_utils.h" | |
| 16 #include "content/public/browser/web_contents.h" | |
| 17 #include "content/public/test/browser_test_utils.h" | |
| 18 #include "net/base/filename_util.h" | |
| 19 #include "net/base/network_delegate.h" | |
| 20 #include "url/gurl.h" | |
| 21 | |
| 22 #if defined(OS_CHROMEOS) | |
| 23 | |
| 24 class ChromeNetworkDelegateBrowserTest : public InProcessBrowserTest { | |
| 25 protected: | |
| 26 ChromeNetworkDelegateBrowserTest() {} | |
| 27 | |
| 28 private: | |
| 29 DISALLOW_COPY_AND_ASSIGN(ChromeNetworkDelegateBrowserTest); | |
|
mmenke
2017/06/05 18:31:33
include base/macros.h
satorux1
2017/06/06 08:52:37
Done.
| |
| 30 }; | |
| 31 | |
| 32 // Ensure that access to a test file via file: scheme is rejected with | |
| 33 // ERR_ACCESS_DENIED. | |
|
mmenke
2017/06/05 18:31:33
Also add a test with a symbolic like that is acces
satorux1
2017/06/06 08:52:37
Good point. Added a test for that.
Also created
| |
| 34 IN_PROC_BROWSER_TEST_F(ChromeNetworkDelegateBrowserTest, AccessToFile) { | |
| 35 // Access to all files via file: scheme is allowed on browser tests. Bring | |
| 36 // back the production behaviors. | |
| 37 ChromeNetworkDelegate::EnableAccessToAllFilesForTesting(false); | |
|
mmenke
2017/06/05 18:31:33
It's possible some other module has already starte
satorux1
2017/06/06 08:52:37
Good idea! However, I was surprised that your code
| |
| 38 | |
| 39 base::FilePath test_directory; | |
| 40 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_directory)); | |
| 41 const base::FilePath test_file = test_directory.AppendASCII("empty.html"); | |
| 42 const GURL url = net::FilePathToFileURL(test_file); | |
|
mmenke
2017/06/05 18:31:33
nit: convention is not to use const, except for b
satorux1
2017/06/06 08:52:37
Done.
| |
| 43 | |
| 44 ui_test_utils::NavigateToURL(browser(), url); | |
| 45 EXPECT_TRUE(errorpage_test_util::IsDisplayingText( | |
| 46 browser(), net::ErrorToShortString(net::ERR_ACCESS_DENIED))); | |
|
mmenke
2017/06/05 18:31:33
Rather than sharing errorpage_test_util::IsDisplay
satorux1
2017/06/06 08:52:37
This was a brilliant idea. Done!
| |
| 47 } | |
| 48 | |
| 49 #endif // defined(OS_CHROMEOS) | |
| OLD | NEW |