Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the current extension popup when using ShowActionUI #7935

Merged
merged 1 commit into from
Feb 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions browser/ui/brave_actions/brave_action_view_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ bool BraveActionViewController::TriggerPopupWithUrl(
PopupShowAction show_action,
const GURL& popup_url,
bool grant_tab_permissions) {
// If this extension is currently showing a popup, hide it. This behavior is
// a bit different than ExtensionActionViewController, which will hide any
// popup, regardless of extension. Consider duplicating the original behavior.
HidePopup();

std::unique_ptr<extensions::ExtensionViewHost> host =
extensions::ExtensionViewHostFactory::CreatePopupHost(popup_url,
browser_);
Expand Down
17 changes: 17 additions & 0 deletions components/brave_rewards/browser/test/rewards_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "base/time/time_override.h"
#include "bat/ledger/internal/uphold/uphold_util.h"
#include "brave/browser/brave_rewards/rewards_service_factory.h"
#include "brave/browser/extensions/api/brave_action_api.h"
#include "brave/common/brave_paths.h"
#include "brave/components/brave_rewards/browser/rewards_service_impl.h"
#include "brave/components/brave_rewards/browser/test/common/rewards_browsertest_context_helper.h"
Expand Down Expand Up @@ -505,4 +506,20 @@ IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, BAPCutoffAfter) {
}
}

IN_PROC_BROWSER_TEST_F(RewardsBrowserTest, BAPPopup) {
// Open the rewards popup.
content::WebContents* popup_contents = context_helper_->OpenRewardsPopup();
ASSERT_TRUE(popup_contents);

// Attempt to open the BAP deprecation popup at the same time. The rewards
// panel popup should close. If both popups are shown at the same time, this
// test will crash on exit.
std::string error;
bool popup_shown = extensions::BraveActionAPI::ShowActionUI(
browser(), brave_rewards_extension_id,
std::make_unique<std::string>("brave_rewards_panel.html#bap-deprecation"),
&error);
EXPECT_TRUE(popup_shown);
}

} // namespace rewards_browsertest