Commit 785d30bd authored by Mike Wasserman's avatar Mike Wasserman Committed by Commit Bot

Window Placement: Fix PermissionContextTest flakiness

A speculative fix for flakiness in the Accept test fixture.
Await getScreens() and then await the permission status.
That should run permission context logic before checks.

Bug: 1134240
Test: No WindowPlacementPermissionContextTest flakes
Change-Id: I21f1e4b2019112d79adf28d8609728fdbe5eaf4e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2446844
Auto-Submit: Michael Wasserman <msw@chromium.org>
Reviewed-by: default avatarVictor Costan <pwnall@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Commit-Queue: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814327}
parent 06ff9f0a
...@@ -14,6 +14,15 @@ ...@@ -14,6 +14,15 @@
#include "content/public/test/browser_test.h" #include "content/public/test/browser_test.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
namespace {
constexpr char kGetScreens[] = R"(
(async () => {
try { const screens = await self.getScreens(); } catch {}
return (await navigator.permissions.query({name:'window-placement'})).state;
})();
)";
// Tests of WindowPlacementPermissionContext behavior. // Tests of WindowPlacementPermissionContext behavior.
class WindowPlacementPermissionContextTest : public InProcessBrowserTest { class WindowPlacementPermissionContextTest : public InProcessBrowserTest {
public: public:
...@@ -38,17 +47,15 @@ IN_PROC_BROWSER_TEST_F(WindowPlacementPermissionContextTest, DismissAndDeny) { ...@@ -38,17 +47,15 @@ IN_PROC_BROWSER_TEST_F(WindowPlacementPermissionContextTest, DismissAndDeny) {
// Auto-dismiss the permission request; user activation should not be granted. // Auto-dismiss the permission request; user activation should not be granted.
permission_request_manager->set_auto_response_for_test( permission_request_manager->set_auto_response_for_test(
permissions::PermissionRequestManager::DISMISS); permissions::PermissionRequestManager::DISMISS);
EXPECT_FALSE( EXPECT_EQ("prompt",
EvalJs(tab, "self.getScreens()", content::EXECUTE_SCRIPT_NO_USER_GESTURE) EvalJs(tab, kGetScreens, content::EXECUTE_SCRIPT_NO_USER_GESTURE));
.error.empty());
EXPECT_FALSE(tab->GetMainFrame()->HasTransientUserActivation()); EXPECT_FALSE(tab->GetMainFrame()->HasTransientUserActivation());
// Auto-deny the permission request; user activation should not be granted. // Auto-deny the permission request; user activation should not be granted.
permission_request_manager->set_auto_response_for_test( permission_request_manager->set_auto_response_for_test(
permissions::PermissionRequestManager::DENY_ALL); permissions::PermissionRequestManager::DENY_ALL);
EXPECT_FALSE( EXPECT_EQ("denied",
EvalJs(tab, "self.getScreens()", content::EXECUTE_SCRIPT_NO_USER_GESTURE) EvalJs(tab, kGetScreens, content::EXECUTE_SCRIPT_NO_USER_GESTURE));
.error.empty());
EXPECT_FALSE(tab->GetMainFrame()->HasTransientUserActivation()); EXPECT_FALSE(tab->GetMainFrame()->HasTransientUserActivation());
} }
...@@ -66,8 +73,9 @@ IN_PROC_BROWSER_TEST_F(WindowPlacementPermissionContextTest, Accept) { ...@@ -66,8 +73,9 @@ IN_PROC_BROWSER_TEST_F(WindowPlacementPermissionContextTest, Accept) {
// Auto-accept the permission request; user activation should be granted. // Auto-accept the permission request; user activation should be granted.
permission_request_manager->set_auto_response_for_test( permission_request_manager->set_auto_response_for_test(
permissions::PermissionRequestManager::ACCEPT_ALL); permissions::PermissionRequestManager::ACCEPT_ALL);
EXPECT_TRUE( EXPECT_EQ("granted",
EvalJs(tab, "self.getScreens()", content::EXECUTE_SCRIPT_NO_USER_GESTURE) EvalJs(tab, kGetScreens, content::EXECUTE_SCRIPT_NO_USER_GESTURE));
.error.empty());
EXPECT_TRUE(tab->GetMainFrame()->HasTransientUserActivation()); EXPECT_TRUE(tab->GetMainFrame()->HasTransientUserActivation());
} }
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment