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

Unified Diff: content/public/test/content_browser_test_utils.h

Issue 1917073002: Block webpages from navigating to view-source URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add layout and browser tests Created 4 years, 7 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: content/public/test/content_browser_test_utils.h
diff --git a/content/public/test/content_browser_test_utils.h b/content/public/test/content_browser_test_utils.h
index 47b2c07c7ed2ab487bea6a40880fb58890cd765f..0af58b2a51346afd7829aaedeb72f26c106cda24 100644
--- a/content/public/test/content_browser_test_utils.h
+++ b/content/public/test/content_browser_test_utils.h
@@ -8,6 +8,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "content/public/browser/web_contents_delegate.h"
#include "content/public/common/page_type.h"
#include "ui/gfx/native_widget_types.h"
#include "url/gurl.h"
@@ -29,6 +30,7 @@ namespace content {
class MessageLoopRunner;
class Shell;
+class WebContents;
// Generate the file path for testing a particular test.
// The file for the tests is all located in
@@ -98,6 +100,34 @@ class ShellAddedObserver {
DISALLOW_COPY_AND_ASSIGN(ShellAddedObserver);
};
+// A WebContentsDelegate that catches messages sent to the console.
+class ConsoleObserverDelegate : public WebContentsDelegate {
+ public:
+ ConsoleObserverDelegate(WebContents* web_contents, const std::string& filter);
+
+ ~ConsoleObserverDelegate() override;
Charlie Reis 2016/05/24 22:54:17 nit: No blank line above.
meacer 2016/05/31 23:57:54 Done.
+
+ bool AddMessageToConsole(WebContents* source,
Charlie Reis 2016/05/24 22:54:17 nit: // WebContentsDelegate overrides.
meacer 2016/05/31 23:57:54 Done.
+ int32_t level,
+ const base::string16& message,
+ int32_t line_no,
+ const base::string16& source_id) override;
+
+ std::string message() { return message_; }
Charlie Reis 2016/05/24 22:54:17 nit: This is now a public interface, so it needs c
meacer 2016/05/31 23:57:54 Done.
+
+ void Wait();
Charlie Reis 2016/05/24 22:54:17 // Wait for the next message sent to the console.
meacer 2016/05/31 23:57:54 Done.
+
+ private:
+ WebContents* web_contents_;
+ std::string filter_;
+ std::string message_;
+
+ // The MessageLoopRunner used to spin the message loop.
+ scoped_refptr<MessageLoopRunner> message_loop_runner_;
+
+ DISALLOW_COPY_AND_ASSIGN(ConsoleObserverDelegate);
+};
+
#if defined OS_MACOSX
void SetWindowBounds(gfx::NativeWindow window, const gfx::Rect& bounds);
#endif

Powered by Google App Engine
This is Rietveld 408576698