diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index ec436d8325..f9ae615149 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -1022,7 +1022,14 @@ bool App::IsAccessibilitySupportEnabled() { return ax_state->IsAccessibleBrowser(); } -void App::SetAccessibilitySupportEnabled(bool enabled) { +void App::SetAccessibilitySupportEnabled(bool enabled, mate::Arguments* args) { + if (!Browser::Get()->is_ready()) { + args->ThrowError( + "app.setAccessibilitySupportEnabled() can only be called " + "after app is ready"); + return; + } + auto* ax_state = content::BrowserAccessibilityState::GetInstance(); if (enabled) { ax_state->OnScreenReaderDetected(); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index c506b54556..94148f30a1 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -192,7 +192,7 @@ class App : public AtomBrowserClient::Delegate, void DisableHardwareAcceleration(mate::Arguments* args); void DisableDomainBlockingFor3DAPIs(mate::Arguments* args); bool IsAccessibilitySupportEnabled(); - void SetAccessibilitySupportEnabled(bool enabled); + void SetAccessibilitySupportEnabled(bool enabled, mate::Arguments* args); Browser::LoginItemSettings GetLoginItemSettings(mate::Arguments* args); #if defined(USE_NSS_CERTS) void ImportCertificate(const base::DictionaryValue& options, diff --git a/docs/api/app.md b/docs/api/app.md index a759a81d87..3ba62c2712 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1098,9 +1098,11 @@ details. * `enabled` Boolean - Enable or disable [accessibility tree](https://developers.google.com/web/fundamentals/accessibility/semantics-builtin/the-accessibility-tree) rendering -Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings. https://www.chromium.org/developers/design-documents/accessibility for more +Manually enables Chrome's accessibility support, allowing to expose accessibility switch to users in application settings. See [Chromium's accessibility docs](https://www.chromium.org/developers/design-documents/accessibility) for more details. Disabled by default. +This API must be called after the `ready` event is emitted. + **Note:** Rendering accessibility tree can significantly affect the performance of your app. It should not be enabled by default. ### `app.showAboutPanel` _macOS_ _Linux_