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

Side by Side Diff: chrome/browser/net/errorpage_browsertest.cc

Issue 2913733002: Add a browser test for access control for file: scheme (Closed)
Patch Set: Address comments Created 3 years, 6 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 (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 <memory> 5 #include <memory>
6 #include <utility> 6 #include <utility>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 #endif 82 #endif
83 #include "components/policy/core/common/mock_configuration_policy_provider.h" 83 #include "components/policy/core/common/mock_configuration_policy_provider.h"
84 84
85 using content::BrowserThread; 85 using content::BrowserThread;
86 using content::NavigationController; 86 using content::NavigationController;
87 using net::URLRequestFailedJob; 87 using net::URLRequestFailedJob;
88 using net::URLRequestTestJob; 88 using net::URLRequestTestJob;
89 89
90 namespace { 90 namespace {
91 91
92 // Returns true if |text| is displayed on the page |browser| is currently 92 // Searches for first node containing |text|, and if it finds one, searches
93 // displaying. Uses "innerText", so will miss hidden text, and whitespace 93 // through all ancestors seeing if any of them is of class "hidden". Since it
94 // space handling may be weird. 94 // relies on the hidden class used by network error pages, not suitable for
95 // general use.
95 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser, 96 bool WARN_UNUSED_RESULT IsDisplayingText(Browser* browser,
96 const std::string& text) { 97 const std::string& text) {
97 // clang-format off 98 // clang-format off
98 std::string command = base::StringPrintf(R"( 99 std::string command = base::StringPrintf(R"(
99 function isNodeVisible(node) { 100 function isNodeVisible(node) {
100 if (!node || node.classList.contains('hidden')) 101 if (!node || node.classList.contains('hidden'))
101 return false; 102 return false;
102 if (!node.parentElement) 103 if (!node.parentElement)
103 return true; 104 return true;
104 // Otherwise, we must check all parent nodes 105 // Otherwise, we must check all parent nodes
(...skipping 1437 matching lines...) Expand 10 before | Expand all | Expand 10 after
1542 Http09WeirdPortEnabled) { 1543 Http09WeirdPortEnabled) {
1543 const char kHttp09Response[] = "JumboShrimp"; 1544 const char kHttp09Response[] = "JumboShrimp";
1544 ASSERT_TRUE(embedded_test_server()->Start()); 1545 ASSERT_TRUE(embedded_test_server()->Start());
1545 ui_test_utils::NavigateToURL( 1546 ui_test_utils::NavigateToURL(
1546 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") + 1547 browser(), embedded_test_server()->GetURL(std::string("/echo-raw?") +
1547 kHttp09Response)); 1548 kHttp09Response));
1548 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response)); 1549 EXPECT_TRUE(IsDisplayingText(browser(), kHttp09Response));
1549 } 1550 }
1550 1551
1551 } // namespace 1552 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698