summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/extensions/api/extension_action
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-09-07 13:12:05 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-11-09 10:02:59 +0000
commit33fc33aa94d4add0878ec30dc818e34e1dd3cc2a (patch)
treef6af110909c79b2759136554f1143d8b0572af0a /chromium/chrome/browser/extensions/api/extension_action
parent7d2c5d177e9813077a621df8d18c0deda73099b3 (diff)
BASELINE: Update Chromium to 104.0.5112.120
Change-Id: I5d2726c2ab018d75d055739b6ba64317904f05bb Reviewed-on: https://codereview.qt-project.org/c/qt/qtwebengine-chromium/+/438935 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/chrome/browser/extensions/api/extension_action')
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc33
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc42
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc20
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_api_interactive_uitest.cc10
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc6
-rw-r--r--chromium/chrome/browser/extensions/api/extension_action/page_action_browsertest.cc15
7 files changed, 70 insertions, 62 deletions
diff --git a/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc b/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
index 31bd31407f9..0b7ae5b359e 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/browser_action_apitest.cc
@@ -67,6 +67,7 @@
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
+#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/image/image_unittest_util.h"
using content::WebContents;
@@ -163,7 +164,8 @@ class BrowserActionApiTestWithContextType
protected:
void RunUpdateTest(base::StringPiece path, bool expect_failure) {
- ExtensionTestMessageListener ready_listener("ready", true);
+ ExtensionTestMessageListener ready_listener("ready",
+ ReplyBehavior::kWillReply);
ASSERT_TRUE(embedded_test_server()->Start());
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII(path));
@@ -202,7 +204,8 @@ class BrowserActionApiTestWithContextType
}
void RunEnableTest(base::StringPiece path, bool start_enabled) {
- ExtensionTestMessageListener ready_listener("ready", true);
+ ExtensionTestMessageListener ready_listener("ready",
+ ReplyBehavior::kWillReply);
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII(path));
ASSERT_TRUE(extension) << message_;
@@ -234,7 +237,7 @@ class BrowserActionApiTestWithContextType
};
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, Basic) {
- ExtensionTestMessageListener ready_listener("ready", false);
+ ExtensionTestMessageListener ready_listener("ready");
ASSERT_TRUE(embedded_test_server()->Start());
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("browser_action/basics"));
@@ -678,7 +681,7 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, RemovePopup) {
}
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoBasic) {
- ExtensionTestMessageListener ready_listener("ready", false);
+ ExtensionTestMessageListener ready_listener("ready");
ASSERT_TRUE(embedded_test_server()->Start());
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("browser_action/basics"));
@@ -700,7 +703,7 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoBasic) {
// action shows up.
// SetIsIncognitoEnabled() requires a reload of the extension, so we have to
// wait for it.
- ExtensionTestMessageListener incognito_ready_listener("ready", false);
+ ExtensionTestMessageListener incognito_ready_listener("ready");
TestExtensionRegistryObserver registry_observer(
ExtensionRegistry::Get(profile()), extension->id());
extensions::util::SetIsIncognitoEnabled(
@@ -728,7 +731,7 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoBasic) {
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoUpdate) {
ASSERT_TRUE(embedded_test_server()->Start());
ExtensionTestMessageListener incognito_not_allowed_listener(
- "incognito not allowed", false);
+ "incognito not allowed");
scoped_refptr<const Extension> extension =
LoadExtension(test_data_dir_.AppendASCII("browser_action/update"));
ASSERT_TRUE(extension) << message_;
@@ -750,8 +753,8 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoUpdate) {
// execution until the transition is completed, since the script will
// start and stop multiple times during the initial load of the extension
// and the enabling of incognito mode.
- ExtensionTestMessageListener incognito_allowed_listener("incognito allowed",
- true);
+ ExtensionTestMessageListener incognito_allowed_listener(
+ "incognito allowed", ReplyBehavior::kWillReply);
// Now enable the extension in incognito mode, and test that the browser
// action shows up. SetIsIncognitoEnabled() requires a reload of the
// extension, so we have to wait for it to finish.
@@ -789,8 +792,8 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoUpdate) {
// Tests that events are dispatched to the correct profile for split mode
// extensions.
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoSplit) {
- ExtensionTestMessageListener listener_ready("regular ready", false);
- ExtensionTestMessageListener incognito_ready("incognito ready", false);
+ ExtensionTestMessageListener listener_ready("regular ready");
+ ExtensionTestMessageListener incognito_ready("incognito ready");
// Open an incognito browser.
// Note: It is important that we create incognito profile before loading
@@ -823,7 +826,7 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType, IncognitoSplit) {
}
IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, CloseBackgroundPage) {
- ExtensionTestMessageListener listener("ready", /*will_reply=*/false);
+ ExtensionTestMessageListener listener("ready");
ASSERT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("browser_action/close_background")));
const Extension* extension = GetSingleLoadedExtension();
@@ -964,7 +967,8 @@ IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
IN_PROC_BROWSER_TEST_P(BrowserActionApiTestWithContextType,
WithRectangularIcon) {
- ExtensionTestMessageListener ready_listener("ready", true);
+ ExtensionTestMessageListener ready_listener("ready",
+ ReplyBehavior::kWillReply);
const Extension* extension = LoadExtension(
test_data_dir_.AppendASCII("browser_action").AppendASCII("rect_icon"));
@@ -1018,18 +1022,19 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest,
content::VideoPictureInPictureWindowController* window_controller =
content::PictureInPictureWindowController::
GetOrCreateVideoPictureInPictureController(web_contents);
- ASSERT_TRUE(window_controller->GetWindowForTesting());
- EXPECT_FALSE(window_controller->GetWindowForTesting()->IsVisible());
+ EXPECT_FALSE(window_controller->GetWindowForTesting());
// Click on the browser action icon to enter Picture-in-Picture.
ResultCatcher catcher;
GetBrowserActionsBar()->Press(extension->id());
EXPECT_TRUE(catcher.GetNextResult());
+ ASSERT_TRUE(window_controller->GetWindowForTesting());
EXPECT_TRUE(window_controller->GetWindowForTesting()->IsVisible());
// Click on the browser action icon to exit Picture-in-Picture.
GetBrowserActionsBar()->Press(extension->id());
EXPECT_TRUE(catcher.GetNextResult());
+ ASSERT_TRUE(window_controller->GetWindowForTesting());
EXPECT_FALSE(window_controller->GetWindowForTesting()->IsVisible());
}
diff --git a/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc b/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
index a125a3efc1b..dafe45be9ce 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/browser_action_browsertest.cc
@@ -49,8 +49,7 @@ void WaitForStateStore(Profile* profile, const std::string& extension_id) {
// action background to blue.
IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest,
PRE_BrowserActionDefaultPersistence) {
- ExtensionTestMessageListener listener("Background Color Set",
- false /* won't send custom reply */);
+ ExtensionTestMessageListener listener("Background Color Set");
const Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("api_test")
@@ -96,8 +95,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, BrowserActionDefaultPersistence) {
// If the extension hasn't already set the badge text, then we should wait for
// it to do so.
if (extension_action->GetExplicitlySetBadgeText(0) != "Hello") {
- ExtensionTestMessageListener listener("Badge Text Set",
- false /* won't send custom reply */);
+ ExtensionTestMessageListener listener("Badge Text Set");
ASSERT_TRUE(listener.WaitUntilSatisfied());
}
diff --git a/chromium/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc b/chromium/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
index f91b946d60d..4f2a14feff9 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/browser_action_interactive_test.cc
@@ -54,6 +54,13 @@
#include "ui/gfx/scrollbar_size.h"
#include "ui/views/widget/widget.h"
+#if !BUILDFLAG(IS_CHROMEOS)
+#include "chrome/browser/download/bubble/download_bubble_controller.h"
+#include "chrome/browser/download/bubble/download_display.h"
+#include "chrome/browser/download/bubble/download_display_controller.h"
+#include "components/safe_browsing/core/common/features.h"
+#endif
+
#if BUILDFLAG(IS_WIN)
#include "ui/views/win/hwnd_util.h"
#endif
@@ -61,6 +68,17 @@
namespace extensions {
namespace {
+#if !BUILDFLAG(IS_CHROMEOS)
+bool IsDownloadSurfaceVisible(BrowserWindow* window) {
+ return base::FeatureList::IsEnabled(safe_browsing::kDownloadBubble)
+ ? window->GetDownloadBubbleUIController()
+ ->display_controller_for_testing()
+ ->download_display_for_testing()
+ ->IsShowingDetails()
+ : window->IsDownloadShelfVisible();
+}
+#endif
+
// Helper to ensure all extension hosts are destroyed during the test. If a host
// is still alive, the Profile can not be destroyed in
// BrowserProcessImpl::StartTearDown().
@@ -180,7 +198,7 @@ class BrowserActionInteractiveTest : public ExtensionApiTest {
content::NotificationService::AllSources());
std::unique_ptr<ExtensionTestMessageListener> listener;
if (!will_reply)
- listener = std::make_unique<ExtensionTestMessageListener>("ready", false);
+ listener = std::make_unique<ExtensionTestMessageListener>("ready");
// Show first popup in first window and expect it to have loaded.
ASSERT_TRUE(RunExtensionTest("browser_action/open_popup",
{.page_url = "open_popup_succeeds.html"}))
@@ -253,7 +271,7 @@ class BrowserActionInteractiveTest : public ExtensionApiTest {
IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, DISABLED_TestOpenPopup) {
auto browserActionBar = ExtensionActionTestHelper::Create(browser());
// Setup extension message listener to wait for javascript to finish running.
- ExtensionTestMessageListener listener("ready", true);
+ ExtensionTestMessageListener listener("ready", ReplyBehavior::kWillReply);
{
OpenPopupViaAPI(true);
EXPECT_TRUE(browserActionBar->HasPopup());
@@ -328,7 +346,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
.AppendASCII("open_popup_background"),
{.allow_in_incognito = true});
ASSERT_TRUE(extension);
- ExtensionTestMessageListener listener(false);
+ ExtensionTestMessageListener listener;
listener.set_extension_id(extension->id());
Browser* incognito_browser =
@@ -349,7 +367,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest,
LoadExtension(test_data_dir_.AppendASCII("browser_action/popup"));
ASSERT_TRUE(first_extension) << message_;
- ExtensionTestMessageListener listener("ready", true);
+ ExtensionTestMessageListener listener("ready", ReplyBehavior::kWillReply);
// Load the test extension which will do nothing except notifyPass() to
// return control here.
ASSERT_TRUE(RunExtensionTest("browser_action/open_popup",
@@ -729,7 +747,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionInteractiveTest, OpenPopupOnPopup) {
// Load up the extension, which will call chrome.browserAction.openPopup()
// when it is loaded and verify that the popup didn't open.
- ExtensionTestMessageListener listener("ready", true);
+ ExtensionTestMessageListener listener("ready", ReplyBehavior::kWillReply);
EXPECT_TRUE(LoadExtension(
test_data_dir_.AppendASCII("browser_action/open_popup_on_reply")));
EXPECT_TRUE(listener.WaitUntilSatisfied());
@@ -1021,10 +1039,11 @@ IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupInteractiveTest,
downloads_directory.AppendASCII("download-test3-attachment.gif")));
// The test verification below is applicable only to scenarios where the
- // download shelf is supported - on ChromeOS, instead of the download shelf,
- // there is a download notification in the right-bottom corner of the screen.
+ // download surface is supported - on ChromeOS, instead of the download
+ // surface, there is a download notification in the right-bottom corner of the
+ // screen.
#if !BUILDFLAG(IS_CHROMEOS)
- EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
+ EXPECT_TRUE(IsDownloadSurfaceVisible(browser()->window()));
#endif
}
@@ -1056,10 +1075,11 @@ IN_PROC_BROWSER_TEST_F(NavigatingExtensionPopupInteractiveTest,
downloads_directory.AppendASCII("download-test3-attachment.gif")));
// The test verification below is applicable only to scenarios where the
- // download shelf is supported - on ChromeOS, instead of the download shelf,
- // there is a download notification in the right-bottom corner of the screen.
+ // download surface is supported - on ChromeOS, instead of the download
+ // surface, there is a download notification in the right-bottom corner of the
+ // screen.
#if !BUILDFLAG(IS_CHROMEOS)
- EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
+ EXPECT_TRUE(IsDownloadSurfaceVisible(browser()->window()));
#endif
}
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
index 84929283b8b..7cd02548061 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api.cc
@@ -229,9 +229,10 @@ void ExtensionActionAPI::DispatchExtensionActionClicked(
ExtensionTabUtil::ScrubTabBehavior scrub_tab_behavior =
ExtensionTabUtil::GetScrubTabBehavior(extension, context_type,
web_contents);
- args->Append(ExtensionTabUtil::CreateTabObject(
- web_contents, scrub_tab_behavior, extension)
- ->ToValue());
+ args->Append(base::Value::FromUniquePtrValue(
+ ExtensionTabUtil::CreateTabObject(web_contents, scrub_tab_behavior,
+ extension)
+ ->ToValue()));
DispatchEventToExtension(web_contents->GetBrowserContext(),
extension_action.extension_id(), histogram_value,
@@ -587,14 +588,13 @@ ExtensionActionGetBadgeTextFunction::RunExtensionAction() {
ExtensionFunction::ResponseAction
ExtensionActionGetBadgeBackgroundColorFunction::RunExtensionAction() {
- std::unique_ptr<base::ListValue> list(new base::ListValue());
+ base::Value::List list;
SkColor color = extension_action_->GetBadgeBackgroundColor(tab_id_);
- list->Append(static_cast<int>(SkColorGetR(color)));
- list->Append(static_cast<int>(SkColorGetG(color)));
- list->Append(static_cast<int>(SkColorGetB(color)));
- list->Append(static_cast<int>(SkColorGetA(color)));
- return RespondNow(
- OneArgument(base::Value::FromUniquePtrValue(std::move(list))));
+ list.Append(static_cast<int>(SkColorGetR(color)));
+ list.Append(static_cast<int>(SkColorGetG(color)));
+ list.Append(static_cast<int>(SkColorGetB(color)));
+ list.Append(static_cast<int>(SkColorGetA(color)));
+ return RespondNow(OneArgument(base::Value(std::move(list))));
}
ActionGetUserSettingsFunction::ActionGetUserSettingsFunction() = default;
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api_interactive_uitest.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api_interactive_uitest.cc
index 6f13209824a..53b4c45be3e 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_api_interactive_uitest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_api_interactive_uitest.cc
@@ -13,7 +13,7 @@
#include "chrome/test/base/ui_test_utils.h"
#include "components/version_info/channel.h"
#include "content/public/test/browser_test.h"
-#include "extensions/browser/browsertest_util.h"
+#include "extensions/browser/background_script_executor.h"
#include "extensions/browser/extension_action.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/browser/extension_host_registry.h"
@@ -44,12 +44,8 @@ class ActionAPIInteractiveUITest : public ExtensionApiTest {
// `extension`, and waits for a corresponding test success notification.
void RunScriptTest(const std::string& script, const Extension& extension) {
ResultCatcher result_catcher;
- base::RunLoop run_loop;
- auto callback = [&run_loop](base::Value value) { run_loop.Quit(); };
- browsertest_util::ExecuteScriptInServiceWorker(
- profile(), extension.id(), script,
- base::BindLambdaForTesting(callback));
- run_loop.Run();
+ BackgroundScriptExecutor::ExecuteScriptAsync(profile(), extension.id(),
+ script);
EXPECT_TRUE(result_catcher.GetNextResult()) << result_catcher.message();
}
diff --git a/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc b/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
index 27e7e7268ea..67f4ee4607b 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/extension_action_apitest.cc
@@ -270,7 +270,7 @@ class MultiActionAPICanvasTest : public MultiActionAPITest {
// cause a disk write (since we only persist the defaults).
// Only browser actions persist settings.
IN_PROC_BROWSER_TEST_F(BrowserActionAPITest, TestNoUnnecessaryIO) {
- ExtensionTestMessageListener ready_listener("ready", false);
+ ExtensionTestMessageListener ready_listener("ready");
TestExtensionDir test_dir;
test_dir.WriteManifest(
@@ -1461,7 +1461,7 @@ IN_PROC_BROWSER_TEST_F(ActionAPITest, TestGetUserSettings) {
const Extension* extension = nullptr;
{
- ExtensionTestMessageListener listener("ready", /*will_reply=*/false);
+ ExtensionTestMessageListener listener("ready");
extension = LoadExtension(test_dir.UnpackedPath());
ASSERT_TRUE(extension);
ASSERT_TRUE(listener.WaitUntilSatisfied());
@@ -1475,7 +1475,7 @@ IN_PROC_BROWSER_TEST_F(ActionAPITest, TestGetUserSettings) {
ExtensionActionTestHelper::Create(browser());
auto get_response = [extension, toolbar_helper = toolbar_helper.get()]() {
- ExtensionTestMessageListener listener(/*will_reply=*/false);
+ ExtensionTestMessageListener listener;
listener.set_extension_id(extension->id());
toolbar_helper->Press(extension->id());
EXPECT_TRUE(listener.WaitUntilSatisfied());
diff --git a/chromium/chrome/browser/extensions/api/extension_action/page_action_browsertest.cc b/chromium/chrome/browser/extensions/api/extension_action/page_action_browsertest.cc
index 38aed9231f6..99cb9a9a9c8 100644
--- a/chromium/chrome/browser/extensions/api/extension_action/page_action_browsertest.cc
+++ b/chromium/chrome/browser/extensions/api/extension_action/page_action_browsertest.cc
@@ -116,14 +116,7 @@ IN_PROC_BROWSER_TEST_P(PageActionBrowserTest, SameDocumentNavigation) {
ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(0));
}
-// Tests that the location bar forgets about unloaded page actions.
-// Flaky on Linux: https://crbug.com/1283900
-#if BUILDFLAG(IS_LINUX)
-#define MAYBE_UnloadPageAction DISABLED_UnloadPageAction
-#else
-#define MAYBE_UnloadPageAction UnloadPageAction
-#endif
-IN_PROC_BROWSER_TEST_P(PageActionBrowserTest, MAYBE_UnloadPageAction) {
+IN_PROC_BROWSER_TEST_P(PageActionBrowserTest, UnloadPageAction) {
ASSERT_TRUE(embedded_test_server()->Start());
base::FilePath extension_path(
@@ -144,11 +137,7 @@ IN_PROC_BROWSER_TEST_P(PageActionBrowserTest, MAYBE_UnloadPageAction) {
}
// Regression test for crbug.com/44415.
-// TODO(crbug.com/1284555): Re-enable test to run with service workers after
-// fixing flakiness.
-using PageActionWithoutServiceWorkerTest = ExtensionBrowserTest;
-IN_PROC_BROWSER_TEST_F(PageActionWithoutServiceWorkerTest,
- PageActionRefreshCrash) {
+IN_PROC_BROWSER_TEST_P(PageActionBrowserTest, PageActionRefreshCrash) {
ExtensionRegistry* registry =
extensions::ExtensionRegistry::Get(browser()->profile());