| Index: ios/chrome/browser/web/child_window_open_by_dom_egtest.mm
|
| diff --git a/ios/chrome/browser/web/child_window_open_by_dom_egtest.mm b/ios/chrome/browser/web/child_window_open_by_dom_egtest.mm
|
| index 54bf8778e010dcbe3fed244b33f416db333fa4c0..53967423446af86ffc571e9d9e375aef44759b6b 100644
|
| --- a/ios/chrome/browser/web/child_window_open_by_dom_egtest.mm
|
| +++ b/ios/chrome/browser/web/child_window_open_by_dom_egtest.mm
|
| @@ -5,6 +5,7 @@
|
| #import <EarlGrey/EarlGrey.h>
|
|
|
| #include "base/ios/ios_util.h"
|
| +#include "base/strings/sys_string_conversions.h"
|
| #include "components/content_settings/core/common/content_settings.h"
|
| #include "ios/chrome/test/app/settings_test_util.h"
|
| #import "ios/chrome/test/app/tab_test_util.h"
|
| @@ -16,9 +17,9 @@
|
| #import "ios/web/public/test/http_server.h"
|
| #include "ios/web/public/test/http_server_util.h"
|
|
|
| +using base::SysUTF8ToNSString;
|
| using chrome_test_util::AssertMainTabCount;
|
| using chrome_test_util::TapWebViewElementWithId;
|
| -using chrome_test_util::WebViewContainingText;
|
| using web::test::HttpServer;
|
|
|
| namespace {
|
| @@ -58,8 +59,8 @@ const char kWindow2Closed[] = "window2.closed: true";
|
| const char kChildWindowTestURL[] =
|
| "http://ios/testing/data/http_server_files/window_proxy.html";
|
| [ChromeEarlGrey loadURL:HttpServer::MakeUrl(kChildWindowTestURL)];
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kNamedWindowLink)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kNamedWindowLink)];
|
| AssertMainTabCount(1);
|
| }
|
|
|
| @@ -78,8 +79,8 @@ const char kWindow2Closed[] = "window2.closed: true";
|
| // Check that they're the same window.
|
| TapWebViewElementWithId("compareNamedWindows");
|
| const char kWindowsEqualText[] = "named windows equal: true";
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindowsEqualText)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindowsEqualText)];
|
| }
|
|
|
| // Tests that multiple calls to window.open() with no window name passed in
|
| @@ -97,8 +98,8 @@ const char kWindow2Closed[] = "window2.closed: true";
|
| // Check that they aren't the same window object.
|
| TapWebViewElementWithId("compareUnnamedWindows");
|
| const char kWindowsEqualText[] = "unnamed windows equal: false";
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindowsEqualText)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindowsEqualText)];
|
| }
|
|
|
| // Tests that calling window.open() with a name returns a different window
|
| @@ -117,8 +118,8 @@ const char kWindow2Closed[] = "window2.closed: true";
|
| // Check that they aren't the same window object.
|
| TapWebViewElementWithId("compareNamedAndUnnamedWindows");
|
| const char kWindowsEqualText[] = "named and unnamed equal: false";
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindowsEqualText)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindowsEqualText)];
|
| }
|
|
|
| // Tests that window.closed is correctly set to true when the corresponding tab
|
| @@ -133,15 +134,14 @@ const char kWindow2Closed[] = "window2.closed: true";
|
|
|
| // Check that named window 1 is opened and named window 2 isn't.
|
| const char kCheckWindow1Link[] = "checkNamedWindow1Closed";
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kCheckWindow1Link)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kCheckWindow1Link)];
|
| TapWebViewElementWithId(kCheckWindow1Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow1Open)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey waitForWebViewContainingText:SysUTF8ToNSString(kWindow1Open)];
|
| const char kCheckWindow2Link[] = "checkNamedWindow2Closed";
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2NeverOpen)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow2NeverOpen)];
|
|
|
| // Open another window with the same name. Check that named window 2 is now
|
| // opened.
|
| @@ -149,18 +149,17 @@ const char kWindow2Closed[] = "window2.closed: true";
|
| AssertMainTabCount(2);
|
| chrome_test_util::SelectTabAtIndexInCurrentMode(0);
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2Open)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey waitForWebViewContainingText:SysUTF8ToNSString(kWindow2Open)];
|
|
|
| // Close the opened window. Check that named window 1 and 2 are both closed.
|
| chrome_test_util::CloseTabAtIndex(1);
|
| AssertMainTabCount(1);
|
| TapWebViewElementWithId(kCheckWindow1Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow1Closed)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow1Closed)];
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2Closed)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow2Closed)];
|
| }
|
|
|
| // Tests that closing a tab will set window.closed to true for only
|
| @@ -172,39 +171,36 @@ const char kWindow2Closed[] = "window2.closed: true";
|
|
|
| // Check that unnamed window 1 is opened and unnamed window 2 isn't.
|
| const char kCheckWindow1Link[] = "checkUnnamedWindow1Closed";
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kCheckWindow1Link)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kCheckWindow1Link)];
|
| TapWebViewElementWithId(kCheckWindow1Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow1Open)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey waitForWebViewContainingText:SysUTF8ToNSString(kWindow1Open)];
|
| const char kCheckWindow2Link[] = "checkUnnamedWindow2Closed";
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2NeverOpen)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow2NeverOpen)];
|
|
|
| // Open another unnamed window. Check that unnamed window 2 is now opened.
|
| TapWebViewElementWithId("openWindowNoName");
|
| AssertMainTabCount(3);
|
| chrome_test_util::SelectTabAtIndexInCurrentMode(0);
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2Open)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey waitForWebViewContainingText:SysUTF8ToNSString(kWindow2Open)];
|
|
|
| // Close the first opened window. Check that unnamed window 1 is closed and
|
| // unnamed window 2 is still open.
|
| chrome_test_util::CloseTabAtIndex(1);
|
| TapWebViewElementWithId(kCheckWindow1Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow1Closed)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow1Closed)];
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2Open)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey waitForWebViewContainingText:SysUTF8ToNSString(kWindow2Open)];
|
|
|
| // Close the second opened window. Check that unnamed window 2 is closed.
|
| chrome_test_util::CloseTabAtIndex(1);
|
| TapWebViewElementWithId(kCheckWindow2Link);
|
| - [[EarlGrey selectElementWithMatcher:WebViewContainingText(kWindow2Closed)]
|
| - assertWithMatcher:grey_notNil()];
|
| + [ChromeEarlGrey
|
| + waitForWebViewContainingText:SysUTF8ToNSString(kWindow2Closed)];
|
| }
|
|
|
| @end
|
|
|