Revert "[AWC] Add browsertests for window.minimize|maximize|restore()"

This reverts commit b33461b7b4dd84cc528989be55813744feca0008.

Reason for revert:
LUCI Bisection has identified this change as the cause of a test failure. See the analysis: https://ci.chromium.org/ui/p/chromium/bisection/test-analysis/b/5760603454963712

Sample build with failed test: https://ci.chromium.org/b/8758571353511364961
Affected test(s):
[ninja://chrome/test:browser_tests/WebAppFrameToolbarBrowserTest_AdditionalWindowingControls.NavigatingBetweenTwoPagesWithNonNullResizability](https://ci.chromium.org/ui/test/chromium/ninja:%2F%2Fchrome%2Ftest:browser_tests%2FWebAppFrameToolbarBrowserTest_AdditionalWindowingControls.NavigatingBetweenTwoPagesWithNonNullResizability?q=VHash%3A28b8316ef11973ff)

If this is a false positive, please report it at http://b.corp.google.com/createIssue?component=1199205&description=Analysis%3A+https%3A%2F%2Fci.chromium.org%2Fui%2Fp%2Fchromium%2Fbisection%2Ftest-analysis%2Fb%2F5760603454963712&format=PLAIN&priority=P3&title=Wrongly+blamed+https%3A%2F%2Fchromium-review.googlesource.com%2Fc%2Fchromium%2Fsrc%2F%2B%2F5201087&type=BUG

Original change's description:
> [AWC] Add browsertests for window.minimize|maximize|restore()
>
> Bug: 1466855, b:288265319
> Change-Id: Ie8112d612b9eebe5e2dffcd27fc8c2a2a6ba84c8
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5201087
> Reviewed-by: Daniel Murphy <dmurph@chromium.org>
> Commit-Queue: Sonja Laurila <laurila@google.com>
> Cr-Commit-Position: refs/heads/main@{#1248641}
>

Bug: 1466855, b:288265319
Change-Id: I75a0cc721bbe45ee9a10e2a5c568b47220fbc77c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5211132
Commit-Queue: Sonja Laurila <laurila@google.com>
Reviewed-by: Sonja Laurila <laurila@google.com>
Reviewed-by: Renato Silva <rrsilva@google.com>
Owners-Override: Renato Silva <rrsilva@google.com>
Cr-Commit-Position: refs/heads/main@{#1248775}
diff --git a/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc b/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc
index 0f6a899..ed71df0 100644
--- a/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc
+++ b/chrome/browser/ui/views/web_apps/frame_toolbar/web_app_frame_toolbar_browsertest.cc
@@ -17,7 +17,6 @@
 #include "base/strings/utf_string_conversions.h"
 #include "base/test/bind.h"
 #include "base/test/icu_test_util.h"
-#include "base/test/run_until.h"
 #include "base/test/test_future.h"
 #include "base/test/test_timeouts.h"
 #include "build/build_config.h"
@@ -1776,11 +1775,6 @@
         browser(), std::move(web_app_info), start_url);
   }
 
-  bool MatchMediaMatches(content::WebContents* web_contents,
-                         std::string match_media_script) {
-    return EvalJs(web_contents, match_media_script).ExtractBool();
-  }
-
   void SetResizableAndWait(content::WebContents* web_contents,
                            bool resizable,
                            bool expected) {
@@ -1788,12 +1782,19 @@
         content::JsReplace("window.setResizable($1)", resizable);
     EXPECT_TRUE(ExecJs(web_contents, set_resizable_script));
     content::WaitForLoadStop(web_contents);
-    EXPECT_TRUE(base::test::RunUntil([&]() {
-      return MatchMediaMatches(
-          web_contents,
-          content::JsReplace("window.matchMedia('(resizable: $1)').matches",
-                             expected));
-    }));
+
+    auto MatchMediaMatches = [&web_contents, &expected]() {
+      auto match_media_script = content::JsReplace(
+          "window.matchMedia('(resizable: $1)').matches", expected);
+      return EvalJs(web_contents, match_media_script).ExtractBool();
+    };
+
+    while (!MatchMediaMatches()) {
+      base::RunLoop run_loop;
+      base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask(
+          FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
+      run_loop.Run();
+    }
   }
 
   void CheckCanResize(bool browser_view_can_resize_expected,
@@ -2021,66 +2022,6 @@
   EXPECT_EQ(EvalJs(web_contents, "window.screenY").ExtractInt(), initial_pos_y);
 }
 #endif  // defined(USE_AURA)
-
-IN_PROC_BROWSER_TEST_F(
-    WebAppFrameToolbarBrowserTest_AdditionalWindowingControls,
-    MinimizeWindowWithApi) {
-  InstallAndLaunchWebApp();
-  helper()->GrantWindowManagementPermission();
-  auto* web_contents = helper()->browser_view()->GetActiveWebContents();
-
-  // Ensure minimizing is allowed.
-  helper()->browser_view()->SetCanMinimize(true);
-  EXPECT_TRUE(helper()->browser_view()->CanMinimize());
-  content::WaitForLoadStop(web_contents);
-
-  // Minimize window
-  EXPECT_TRUE(ExecJs(web_contents, "window.minimize()"));
-  EXPECT_TRUE(base::test::RunUntil(
-      [&]() { return helper()->browser_view()->IsMinimized(); }));
-
-  // On Windows the minimizing seems to be so fast that it doesn't have
-  // sufficient time to update the CSS before it already minimized.
-#if !BUILDFLAG(IS_WIN)
-  EXPECT_TRUE(base::test::RunUntil([&]() {
-    return MatchMediaMatches(
-        web_contents,
-        "window.matchMedia('(display-state: minimized)').matches");
-  }));
-#endif
-}
-
-IN_PROC_BROWSER_TEST_F(
-    WebAppFrameToolbarBrowserTest_AdditionalWindowingControls,
-    MaximizeAndRestoreWindowWithApi) {
-  InstallAndLaunchWebApp();
-  helper()->GrantWindowManagementPermission();
-  auto* web_contents = helper()->browser_view()->GetActiveWebContents();
-
-  // Ensure maximizing is allowed.
-  helper()->browser_view()->SetCanMaximize(true);
-  EXPECT_TRUE(helper()->browser_view()->CanMaximize());
-  content::WaitForLoadStop(web_contents);
-
-  // Maximize window
-  EXPECT_TRUE(ExecJs(web_contents, "window.maximize()"));
-  EXPECT_TRUE(base::test::RunUntil(
-      [&]() { return helper()->browser_view()->IsMaximized(); }));
-  EXPECT_TRUE(base::test::RunUntil([&]() {
-    return MatchMediaMatches(
-        web_contents,
-        "window.matchMedia('(display-state: maximized)').matches");
-  }));
-
-  // Restore window
-  EXPECT_TRUE(ExecJs(web_contents, "window.restore()"));
-  EXPECT_TRUE(base::test::RunUntil(
-      [&]() { return !helper()->browser_view()->IsMaximized(); }));
-  EXPECT_TRUE(base::test::RunUntil([&]() {
-    return MatchMediaMatches(
-        web_contents, "window.matchMedia('(display-state: normal)').matches");
-  }));
-}
 #endif  // !BUILDFLAG(IS_ANDROID)
 
 class OriginTextVisibilityWaiter : public views::ViewObserver {