mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 22:07:41 +00:00
Backed out 2 changesets (bug 1401980) for failures in browser_shutdown_pref.js
CLOSED TREE Backed out changeset cea72923c4be (bug 1401980) Backed out changeset 72f9e62daa10 (bug 1401980) MozReview-Commit-ID: 2bhiTKZmmib
This commit is contained in:
parent
e242afd753
commit
15fafc3560
@ -27,6 +27,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "OuterDocAccessible.h"
|
||||
#include "Platform.h"
|
||||
#include "Role.h"
|
||||
#ifdef MOZ_ACCESSIBILITY_ATK
|
||||
#include "RootAccessibleWrap.h"
|
||||
@ -95,15 +96,6 @@ using namespace mozilla;
|
||||
using namespace mozilla::a11y;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
/**
|
||||
* Accessibility service force enable/disable preference.
|
||||
* Supported values:
|
||||
* Accessibility is force enabled (accessibility should always be enabled): -1
|
||||
* Accessibility is enabled (will be started upon a request, default value): 0
|
||||
* Accessibility is force disabled (never enable accessibility): 1
|
||||
*/
|
||||
#define PREF_ACCESSIBILITY_FORCE_DISABLED "accessibility.force_disabled"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Statics
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -277,11 +269,6 @@ New_MaybeImageOrToolbarButtonAccessible(nsIContent* aContent,
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Cached value of the PREF_ACCESSIBILITY_FORCE_DISABLED preference.
|
||||
*/
|
||||
static int32_t sPlatformDisabledState = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Markup maps array.
|
||||
|
||||
@ -1983,39 +1970,17 @@ XPCApplicationAcc()
|
||||
EPlatformDisabledState
|
||||
PlatformDisabledState()
|
||||
{
|
||||
static bool platformDisabledStateCached = false;
|
||||
if (platformDisabledStateCached) {
|
||||
return static_cast<EPlatformDisabledState>(sPlatformDisabledState);
|
||||
static int disabledState = 0xff;
|
||||
|
||||
if (disabledState == 0xff) {
|
||||
disabledState = Preferences::GetInt("accessibility.force_disabled", 0);
|
||||
if (disabledState < ePlatformIsForceEnabled)
|
||||
disabledState = ePlatformIsForceEnabled;
|
||||
else if (disabledState > ePlatformIsDisabled)
|
||||
disabledState = ePlatformIsDisabled;
|
||||
}
|
||||
|
||||
platformDisabledStateCached = true;
|
||||
Preferences::RegisterCallback(PrefChanged, PREF_ACCESSIBILITY_FORCE_DISABLED);
|
||||
return ReadPlatformDisabledState();
|
||||
}
|
||||
|
||||
EPlatformDisabledState
|
||||
ReadPlatformDisabledState()
|
||||
{
|
||||
sPlatformDisabledState = Preferences::GetInt(PREF_ACCESSIBILITY_FORCE_DISABLED, 0);
|
||||
if (sPlatformDisabledState < ePlatformIsForceEnabled) {
|
||||
sPlatformDisabledState = ePlatformIsForceEnabled;
|
||||
} else if (sPlatformDisabledState > ePlatformIsDisabled){
|
||||
sPlatformDisabledState = ePlatformIsDisabled;
|
||||
}
|
||||
|
||||
return static_cast<EPlatformDisabledState>(sPlatformDisabledState);
|
||||
}
|
||||
|
||||
void
|
||||
PrefChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
if (ReadPlatformDisabledState() == ePlatformIsDisabled) {
|
||||
// Force shut down accessibility.
|
||||
nsAccessibilityService* accService = nsAccessibilityService::gAccessibilityService;
|
||||
if (accService && !accService->IsShutdown()) {
|
||||
accService->Shutdown();
|
||||
}
|
||||
}
|
||||
return (EPlatformDisabledState)disabledState;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
|
||||
#include "mozilla/a11y/DocManager.h"
|
||||
#include "mozilla/a11y/FocusManager.h"
|
||||
#include "mozilla/a11y/Platform.h"
|
||||
#include "mozilla/a11y/Role.h"
|
||||
#include "mozilla/a11y/SelectionManager.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
@ -75,16 +74,6 @@ struct XULMarkupMapInfo {
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* PREF_ACCESSIBILITY_FORCE_DISABLED preference change callback.
|
||||
*/
|
||||
void PrefChanged(const char* aPref, void* aClosure);
|
||||
|
||||
/**
|
||||
* Read and normalize PREF_ACCESSIBILITY_FORCE_DISABLED preference.
|
||||
*/
|
||||
EPlatformDisabledState ReadPlatformDisabledState();
|
||||
|
||||
} // namespace a11y
|
||||
} // namespace mozilla
|
||||
|
||||
@ -351,7 +340,6 @@ private:
|
||||
friend nsAccessibilityService* GetAccService();
|
||||
friend nsAccessibilityService* GetOrCreateAccService(uint32_t);
|
||||
friend void MaybeShutdownAccService(uint32_t);
|
||||
friend void mozilla::a11y::PrefChanged(const char*, void*);
|
||||
friend mozilla::a11y::FocusManager* mozilla::a11y::FocusMgr();
|
||||
friend mozilla::a11y::SelectionManager* mozilla::a11y::SelectionMgr();
|
||||
friend mozilla::a11y::ApplicationAccessible* mozilla::a11y::ApplicationAcc();
|
||||
|
@ -12,7 +12,6 @@ support-files =
|
||||
[browser_shutdown_multi_reference.js]
|
||||
[browser_shutdown_parent_own_reference.js]
|
||||
skip-if = !e10s || (os == 'win' && os_version == '5.1') # e10s specific test for a11y start/shutdown between parent and content.
|
||||
[browser_shutdown_pref.js]
|
||||
[browser_shutdown_proxy_acc_reference.js]
|
||||
skip-if = !e10s || (os == 'win') # e10s specific test for a11y start/shutdown between parent and content.
|
||||
[browser_shutdown_proxy_doc_acc_reference.js]
|
||||
|
@ -1,66 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const PREF_ACCESSIBILITY_FORCE_DISABLED = "accessibility.force_disabled";
|
||||
const NS_ERROR_SERVICE_NOT_AVAILABLE = "NS_ERROR_XPC_GS_RETURNED_FAILURE";
|
||||
|
||||
add_task(async function testForceDisable() {
|
||||
ok(!Services.appinfo.accessibilityEnabled, "Accessibility is disabled by default");
|
||||
|
||||
let accService;
|
||||
info("Force disabling a11y service via preference and trying to enable is via XPCOM");
|
||||
Services.prefs.setIntPref(PREF_ACCESSIBILITY_FORCE_DISABLED, 1);
|
||||
try {
|
||||
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
|
||||
Ci.nsIAccessibilityService);
|
||||
ok(false, "Getting accessibility service should've triggered an exception");
|
||||
} catch (e) {
|
||||
is(e.name, NS_ERROR_SERVICE_NOT_AVAILABLE, "Getting accessibility service triggered an exception as expected");
|
||||
}
|
||||
info("Reset force disabled preference");
|
||||
Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
|
||||
|
||||
info("Enable accessibility service via XPCOM");
|
||||
let a11yInit = initPromise();
|
||||
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
|
||||
Ci.nsIAccessibilityService);
|
||||
await a11yInit;
|
||||
ok(Services.appinfo.accessibilityEnabled, "Accessibility is enabled");
|
||||
|
||||
info("Force disable a11y service via preference");
|
||||
let a11yShutdown = shutdownPromise();
|
||||
Services.prefs.setIntPref(PREF_ACCESSIBILITY_FORCE_DISABLED, 1);
|
||||
await a11yShutdown;
|
||||
ok(!Services.appinfo.accessibilityEnabled, "Accessibility is disabled");
|
||||
|
||||
info("Attempt to get an instance of a11y service and call its method.");
|
||||
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
|
||||
Ci.nsIAccessibilityService);
|
||||
try {
|
||||
accService.getAccesssibleFor(document);
|
||||
ok(false, "getAccesssibleFor should've triggered an exception.");
|
||||
} catch (e) {
|
||||
ok(true, "getAccesssibleFor triggers an exception as a11y service is shutdown.");
|
||||
}
|
||||
ok(!Services.appinfo.accessibilityEnabled, "Accessibility is disabled");
|
||||
|
||||
info("Reset force disabled preference");
|
||||
Services.prefs.clearUserPref(PREF_ACCESSIBILITY_FORCE_DISABLED);
|
||||
|
||||
info("Create a11y service again");
|
||||
a11yInit = initPromise();
|
||||
accService = Cc["@mozilla.org/accessibilityService;1"].getService(
|
||||
Ci.nsIAccessibilityService);
|
||||
await a11yInit;
|
||||
ok(Services.appinfo.accessibilityEnabled, "Accessibility is enabled");
|
||||
|
||||
info("Remove all references to a11y service");
|
||||
a11yShutdown = shutdownPromise();
|
||||
accService = null;
|
||||
forceGC();
|
||||
await a11yShutdown;
|
||||
ok(!Services.appinfo.accessibilityEnabled, "Accessibility is disabled");
|
||||
});
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "nsAccessiblePivot.h"
|
||||
#include "nsAccessibilityService.h"
|
||||
#include "Platform.h"
|
||||
|
||||
#ifdef A11Y_LOG
|
||||
#include "Logging.h"
|
||||
@ -44,9 +43,7 @@ xpcAccessibilityService::AddRef(void)
|
||||
nsrefcnt count = ++mRefCnt;
|
||||
NS_LOG_ADDREF(this, count, "xpcAccessibilityService", sizeof(*this));
|
||||
|
||||
// We want refcount to be > 1 because one reference is added in the XPCOM
|
||||
// accessibility service getter.
|
||||
if (mRefCnt > 1 && PlatformDisabledState() != ePlatformIsDisabled) {
|
||||
if (mRefCnt > 1) {
|
||||
GetOrCreateAccService(nsAccessibilityService::eXPCOM);
|
||||
}
|
||||
|
||||
@ -117,12 +114,7 @@ xpcAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
DocAccessible* document = accService->GetDocAccessible(node->OwnerDoc());
|
||||
DocAccessible* document = GetAccService()->GetDocAccessible(node->OwnerDoc());
|
||||
if (document) {
|
||||
NS_IF_ADDREF(*aAccessible = ToXPC(document->GetAccessible(node)));
|
||||
}
|
||||
@ -133,12 +125,7 @@ xpcAccessibilityService::GetAccessibleFor(nsIDOMNode *aNode,
|
||||
NS_IMETHODIMP
|
||||
xpcAccessibilityService::GetStringRole(uint32_t aRole, nsAString& aString)
|
||||
{
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
accService->GetStringRole(aRole, aString);
|
||||
GetAccService()->GetStringRole(aRole, aString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -146,12 +133,7 @@ NS_IMETHODIMP
|
||||
xpcAccessibilityService::GetStringStates(uint32_t aState, uint32_t aExtraState,
|
||||
nsISupports **aStringStates)
|
||||
{
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
accService->GetStringStates(aState, aExtraState, aStringStates);
|
||||
GetAccService()->GetStringStates(aState, aExtraState, aStringStates);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -159,12 +141,7 @@ NS_IMETHODIMP
|
||||
xpcAccessibilityService::GetStringEventType(uint32_t aEventType,
|
||||
nsAString& aString)
|
||||
{
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
accService->GetStringEventType(aEventType, aString);
|
||||
GetAccService()->GetStringEventType(aEventType, aString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -172,12 +149,7 @@ NS_IMETHODIMP
|
||||
xpcAccessibilityService::GetStringRelationType(uint32_t aRelationType,
|
||||
nsAString& aString)
|
||||
{
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
accService->GetStringRelationType(aRelationType, aString);
|
||||
GetAccService()->GetStringRelationType(aRelationType, aString);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -196,18 +168,13 @@ xpcAccessibilityService::GetAccessibleFromCache(nsIDOMNode* aNode,
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsAccessibilityService* accService = GetAccService();
|
||||
if (!accService) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Search for an accessible in each of our per document accessible object
|
||||
// caches. If we don't find it, and the given node is itself a document, check
|
||||
// our cache of document accessibles (document cache). Note usually shutdown
|
||||
// document accessibles are not stored in the document cache, however an
|
||||
// "unofficially" shutdown document (i.e. not from DocManager) can still
|
||||
// exist in the document cache.
|
||||
Accessible* accessible = accService->FindAccessibleInCache(node);
|
||||
Accessible* accessible = GetAccService()->FindAccessibleInCache(node);
|
||||
if (!accessible) {
|
||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(node));
|
||||
if (document) {
|
||||
@ -268,11 +235,6 @@ NS_GetAccessibilityService(nsIAccessibilityService** aResult)
|
||||
NS_ENSURE_TRUE(aResult, NS_ERROR_NULL_POINTER);
|
||||
*aResult = nullptr;
|
||||
|
||||
// Do not initialize accessibility if it is force disabled.
|
||||
if (PlatformDisabledState() == ePlatformIsDisabled) {
|
||||
return NS_ERROR_SERVICE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
GetOrCreateAccService(nsAccessibilityService::eXPCOM);
|
||||
|
||||
xpcAccessibilityService* service = new xpcAccessibilityService();
|
||||
|
@ -3103,9 +3103,7 @@ nsChildView::GetDocumentAccessible()
|
||||
if (!mozilla::a11y::ShouldA11yBeEnabled())
|
||||
return nullptr;
|
||||
|
||||
// mAccessible might be dead if accessibility was previously disabled and is
|
||||
// now being enabled again.
|
||||
if (mAccessible && mAccessible->IsAlive()) {
|
||||
if (mAccessible) {
|
||||
RefPtr<a11y::Accessible> ret;
|
||||
CallQueryReferent(mAccessible.get(),
|
||||
static_cast<a11y::Accessible**>(getter_AddRefs(ret)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user