fix: avoid redundant page-favicon-updated events on setBounds (#50084)

* fix: avoid duplicate calls in electron_api_web_contents

Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com>

* Style: fix lint errors

Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com>

* fix: prevent duplicate page-favicon-updated events and add regression test

Co-authored-by: Ananya542 <ananyashrma6512@gmail.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: ANANYA542 <ananyashrma6512@gmail.com>
This commit is contained in:
trop[bot]
2026-03-05 12:47:58 -05:00
committed by GitHub
parent de61f6c5e8
commit 66ce2439cc
2 changed files with 9 additions and 0 deletions

View File

@@ -2201,6 +2201,11 @@ void WebContents::DidUpdateFaviconURL(
iter->icon_url.is_valid())
unique_urls.insert(iter->icon_url);
}
// Only emit if favicon URLs actually changed
if (unique_urls == last_favicon_urls_)
return;
last_favicon_urls_ = unique_urls;
Emit("page-favicon-updated", unique_urls);
}

View File

@@ -11,6 +11,7 @@
#include <string>
#include <vector>
#include "base/containers/flat_set.h"
#include "base/functional/callback_forward.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
@@ -462,6 +463,9 @@ class WebContents final : public ExclusiveAccessContext,
WebContents& operator=(const WebContents&) = delete;
private:
// Store last emitted favicon URLs to avoid duplicate page-favicon-updated
// events
base::flat_set<GURL> last_favicon_urls_;
// Does not manage lifetime of |web_contents|.
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
// Takes over ownership of |web_contents|.