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

Unified Diff: chrome/browser/net/errorpage_test_util.cc

Issue 2913733002: Add a browser test for access control for file: scheme (Closed)
Patch Set: Rework the patch per feedback 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/net/errorpage_test_util.cc
diff --git a/chrome/browser/net/errorpage_test_util.cc b/chrome/browser/net/errorpage_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f745821f4387545e89e34881e548a387d513efe8
--- /dev/null
+++ b/chrome/browser/net/errorpage_test_util.cc
@@ -0,0 +1,38 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
mmenke 2017/06/05 18:31:34 --(c)
satorux1 2017/06/06 08:52:37 done - but this file is gone.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/net/errorpage_test_util.h"
+
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "content/public/browser/web_contents.h"
+#include "content/public/test/browser_test_utils.h"
+#include "net/base/net_errors.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace errorpage_test_util {
+
+bool IsDisplayingText(Browser* browser, const std::string& text) {
+ // clang-format off
+ std::string command = base::StringPrintf(R"(
+ function isNodeVisible(node) {
+ if (!node || node.classList.contains('hidden'))
+ return false;
+ if (!node.parentElement)
+ return true;
+ // Otherwise, we must check all parent nodes
+ return isNodeVisible(node.parentElement);
+ }
+ var node = document.evaluate("//*[contains(text(),'%s')]", document,
+ null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
+ domAutomationController.send(isNodeVisible(node));
+ )", text.c_str());
+ // clang-format on
+ bool result = false;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ browser->tab_strip_model()->GetActiveWebContents(), command, &result));
+ return result;
+}
+
+} // namespace errorpage_test_util

Powered by Google App Engine
This is Rietveld 408576698