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

Unified Diff: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc

Issue 212703005: Preserve Page::openedByDOM state across process swaps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/visitedlink/test/visitedlink_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
diff --git a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
index ecf15ddabd562e52f66ca943b689d8a8ef3bd419..42561b5a1d588d745be602a6f33f4472727a60d5 100644
--- a/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
+++ b/chrome/browser/ui/blocked_content/popup_blocker_browsertest.cc
@@ -6,6 +6,7 @@
#include "base/files/file_path.h"
#include "base/message_loop/message_loop.h"
#include "base/path_service.h"
+#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/autocomplete/autocomplete_result.h"
@@ -30,10 +31,13 @@
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
+#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_view.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/test_navigation_observer.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -69,6 +73,25 @@ class CountRenderViewHosts : public content::NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(CountRenderViewHosts);
};
+class CloseObserver : public content::WebContentsObserver {
+ public:
+ explicit CloseObserver(WebContents* contents)
+ : content::WebContentsObserver(contents) {}
+
+ void Wait() {
+ close_loop_.Run();
+ }
+
+ virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE {
+ close_loop_.Quit();
+ }
+
+ private:
+ base::RunLoop close_loop_;
+
+ DISALLOW_COPY_AND_ASSIGN(CloseObserver);
+};
+
class PopupBlockerBrowserTest : public InProcessBrowserTest {
public:
PopupBlockerBrowserTest() {}
@@ -388,6 +411,29 @@ IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, Opener) {
true);
}
+// Tests that the popup can still close itself after navigating. This tests that
+// the openedByDOM bit is preserved across blocked popups.
+IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, ClosableAfterNavigation) {
+ // Open a popup.
+ WebContents* popup =
+ RunCheckTest(browser(),
+ "/popup_blocker/popup-opener.html",
+ true,
+ true);
+
+ // Navigate it elsewhere.
+ content::TestNavigationObserver nav_observer(popup);
+ popup->GetMainFrame()->ExecuteJavaScript(
+ base::UTF8ToUTF16("location.href = '/empty.html'"));
+ nav_observer.Wait();
+
+ // Have it close itself.
+ CloseObserver close_observer(popup);
+ popup->GetMainFrame()->ExecuteJavaScript(
+ base::UTF8ToUTF16("window.close()"));
+ close_observer.Wait();
+}
+
IN_PROC_BROWSER_TEST_F(PopupBlockerBrowserTest, OpenerSuppressed) {
RunCheckTest(browser(),
"/popup_blocker/popup-openersuppressed.html",
« no previous file with comments | « no previous file | components/visitedlink/test/visitedlink_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698