Skip to content

Commit

Permalink
fix: bind fake mojo service for badging (#25369)
Browse files Browse the repository at this point in the history
* fix: bind fake mojo service for badging

* Add a test

Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
  • Loading branch information
trop[bot] and codebytere committed Sep 10, 2020
1 parent c6eeff8 commit 88d7bdc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions shell/browser/electron_browser_client.cc
Expand Up @@ -96,6 +96,7 @@
#include "shell/common/options_switches.h"
#include "shell/common/platform_util.h"
#include "third_party/blink/public/common/loader/url_loader_throttle.h"
#include "third_party/blink/public/mojom/badging/badging.mojom.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/native_theme/native_theme.h"
#include "v8/include/v8.h"
Expand Down Expand Up @@ -1583,6 +1584,12 @@ void ElectronBrowserClient::BindHostReceiverForRenderer(
#endif
}

void BindBadgeManagerFrameReceiver(
content::RenderFrameHost* frame,
mojo::PendingReceiver<blink::mojom::BadgeService> receiver) {
LOG(WARNING) << "The Chromium Badging API is not available in Electron";
}

#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
void BindMimeHandlerService(
content::RenderFrameHost* frame_host,
Expand Down Expand Up @@ -1619,6 +1626,8 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame(
mojo::BinderMapWithContext<content::RenderFrameHost*>* map) {
map->Add<network_hints::mojom::NetworkHintsHandler>(
base::BindRepeating(&BindNetworkHintsHandler));
map->Add<blink::mojom::BadgeService>(
base::BindRepeating(&BindBadgeManagerFrameReceiver));
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
map->Add<extensions::mime_handler::MimeHandlerService>(
base::BindRepeating(&BindMimeHandlerService));
Expand Down
8 changes: 8 additions & 0 deletions spec/chromium-spec.js
Expand Up @@ -17,6 +17,14 @@ const features = process.electronBinding('features');
describe('chromium feature', () => {
const fixtures = path.resolve(__dirname, 'fixtures');

describe('Badging API', () => {
it('does not crash', () => {
expect(() => {
navigator.setAppBadge(42);
}).to.not.throw();
});
});

describe('heap snapshot', () => {
it('does not crash', function () {
process.electronBinding('v8_util').takeHeapSnapshot();
Expand Down

0 comments on commit 88d7bdc

Please sign in to comment.