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

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

Issue 2737353006: Replaced webPageOrderedClose with WebStateDelegate API. (Closed)
Patch Set: 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
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 9a6f792943fdf5762445dec839d7856b0e232443..850acf5ea8d85fd02dc35fc1ad712ee42e54ae74 100644
--- a/ios/web/web_state/ui/crw_web_controller_unittest.mm
+++ b/ios/web/web_state/ui/crw_web_controller_unittest.mm
@@ -840,12 +840,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_;
@@ -895,6 +898,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) {

Powered by Google App Engine
This is Rietveld 408576698