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

Unified Diff: ios/web/web_state/ui/crw_web_controller_unittest.mm

Issue 2737353006: Replaced webPageOrderedClose with WebStateDelegate API. (Closed)
Patch Set: Addressed review comments Created 3 years, 9 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 | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/web_state_delegate.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller_unittest.mm
diff --git a/ios/web/web_state/ui/crw_web_controller_unittest.mm b/ios/web/web_state/ui/crw_web_controller_unittest.mm
index c204bcc7bbf425aecc92450077cbd587205775bd..b41327ea12a39e6076e37d638809dc91d266beb6 100644
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -842,12 +842,15 @@ class WindowOpenByDomTest : public web::WebTestWithWebController {
// as a string.
id OpenWindowByDom() {
NSString* const kOpenWindowScript =
- @"var w = window.open('javascript:void(0);', target='_blank');"
+ @"w = window.open('javascript:void(0);', target='_blank');"
"w ? w.toString() : null;";
id windowJSObject = ExecuteJavaScript(kOpenWindowScript);
- WaitForBackgroundTasks();
return windowJSObject;
}
+
+ // Executes JavaScript that closes previously opened window.
+ void CloseWindow() { ExecuteJavaScript(@"w.close()"); }
+
// URL of a page which opens child windows.
const GURL opener_url_;
web::TestWebStateDelegate delegate_;
@@ -897,6 +900,22 @@ TEST_F(WindowOpenByDomTest, DontBlockPopup) {
EXPECT_TRUE(delegate_.popups().empty());
}
+// Tests that window.close closes the web state.
+TEST_F(WindowOpenByDomTest, CloseWindow) {
+ delegate_.allow_popups(opener_url_);
+ ASSERT_NSEQ(@"[object Window]", OpenWindowByDom());
+
+ ASSERT_EQ(1U, delegate_.child_windows().size());
+ ASSERT_TRUE(delegate_.child_windows()[0]);
+ EXPECT_TRUE(delegate_.popups().empty());
+
+ delegate_.child_windows()[0]->SetDelegate(&delegate_);
+ CloseWindow();
+
+ EXPECT_TRUE(delegate_.child_windows().empty());
+ EXPECT_TRUE(delegate_.popups().empty());
+}
+
// Tests page title changes.
typedef web::WebTestWithWebState CRWWebControllerTitleTest;
TEST_F(CRWWebControllerTitleTest, TitleChange) {
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/web_state_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698