Bug 733848 - log accessible/name/test_markup.html on stack enabled builds, r=ehsan, tbsaunde

This commit is contained in:
Alexander Surkov 2012-11-04 11:19:56 +09:00
parent 3fe21da497
commit 242fe5953e
6 changed files with 72 additions and 26 deletions

View File

@ -18,7 +18,7 @@ interface nsIAccessiblePivot;
* nsIAccessible for a given DOM node. More documentation at:
* http://www.mozilla.org/projects/ui/accessibility
*/
[scriptable, uuid(aed712cb-708b-4caa-981d-767be0fba984)]
[scriptable, uuid(17f86615-1a3d-4021-b227-3a2ef5cbffd8)]
interface nsIAccessibleRetrieval : nsISupports
{
/**
@ -94,6 +94,11 @@ interface nsIAccessibleRetrieval : nsISupports
* @see Logging.cpp for list of possible values.
*/
void setLogging(in ACString aModules);
/**
* Return true if the given module is logged.
*/
boolean isLogged(in AString aModule);
};

View File

@ -35,6 +35,24 @@ struct ModuleRep {
logging::EModules mModule;
};
static ModuleRep sModuleMap[] = {
{ "docload", logging::eDocLoad },
{ "doccreate", logging::eDocCreate },
{ "docdestroy", logging::eDocDestroy },
{ "doclifecycle", logging::eDocLifeCycle },
{ "events", logging::eEvents },
{ "platforms", logging::ePlatforms },
{ "stack", logging::eStack },
{ "text", logging::eText },
{ "tree", logging::eTree },
{ "DOMEvents", logging::eDOMEvents },
{ "focus", logging::eFocus },
{ "selection", logging::eSelection },
{ "notifications", logging::eNotifications }
};
static void
EnableLogging(const char* aModulesStr)
{
@ -42,31 +60,18 @@ EnableLogging(const char* aModulesStr)
if (!aModulesStr)
return;
static ModuleRep modules[] = {
{ "docload", logging::eDocLoad },
{ "doccreate", logging::eDocCreate },
{ "docdestroy", logging::eDocDestroy },
{ "doclifecycle", logging::eDocLifeCycle },
{ "events", logging::eEvents },
{ "platforms", logging::ePlatforms },
{ "stack", logging::eStack },
{ "text", logging::eText },
{ "tree", logging::eTree },
{ "DOMEvents", logging::eDOMEvents },
{ "focus", logging::eFocus },
{ "selection", logging::eSelection },
{ "notifications", logging::eNotifications }
};
const char* token = aModulesStr;
while (*token != '\0') {
size_t tokenLen = strcspn(token, ",");
for (unsigned int idx = 0; idx < ArrayLength(modules); idx++) {
if (strncmp(token, modules[idx].mStr, tokenLen) == 0) {
sModules |= modules[idx].mModule;
printf("\n\nmodule enabled: %s\n", modules[idx].mStr);
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
if (strncmp(token, sModuleMap[idx].mStr, tokenLen) == 0) {
#if !defined(MOZ_PROFILING) && (!defined(MOZ_DEBUG) || defined(MOZ_OPTIMIZE))
// Stack tracing on profiling enabled or debug not optimized builds.
if (strncmp(token, "stack", tokenLen) == 0)
break;
#endif
sModules |= sModuleMap[idx].mModule;
printf("\n\nmodule enabled: %s\n", sModuleMap[idx].mStr);
break;
}
}
@ -803,6 +808,17 @@ logging::IsEnabled(uint32_t aModules)
return sModules & aModules;
}
bool
logging::IsEnabled(const nsAString& aModuleStr)
{
for (unsigned int idx = 0; idx < ArrayLength(sModuleMap); idx++) {
if (aModuleStr.EqualsASCII(sModuleMap[idx].mStr))
return sModules & sModuleMap[idx].mModule;
}
return false;
}
void
logging::Enable(const nsAFlatCString& aModules)
{

View File

@ -50,6 +50,11 @@ enum EModules {
*/
bool IsEnabled(uint32_t aModules);
/**
* Return true if the given module is logged.
*/
bool IsEnabled(const nsAString& aModules);
/**
* Log the document loading progress.
*/

View File

@ -250,6 +250,7 @@ nsAccessibilityService::ContentRangeInserted(nsIPresShell* aPresShell,
logging::Node("content", child);
}
logging::MsgEnd();
logging::Stack();
}
#endif
@ -269,6 +270,7 @@ nsAccessibilityService::ContentRemoved(nsIPresShell* aPresShell,
logging::Node("container", aContainer);
logging::Node("content", aChild);
logging::MsgEnd();
logging::Stack();
}
#endif
@ -620,6 +622,19 @@ nsAccessibilityService::SetLogging(const nsACString& aModules)
return NS_OK;
}
NS_IMETHODIMP
nsAccessibilityService::IsLogged(const nsAString& aModule, bool* aIsLogged)
{
NS_ENSURE_ARG_POINTER(aIsLogged);
*aIsLogged = false;
#ifdef A11Y_LOG
*aIsLogged = logging::IsEnabled(aModule);
#endif
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////
// nsAccessibilityService public

View File

@ -102,6 +102,10 @@ function disableLogging()
{
gAccRetrieval.setLogging("");
}
function isLogged(aModule)
{
return gAccRetrieval.isLogged(aModule);
}
/**
* Invokes the given function when document is loaded and focused. Preferable

View File

@ -14,7 +14,7 @@ var gDumpToConsole = false;
*/
function testNames()
{
//enableLogging("tree"); // debugging
enableLogging("tree,stack"); // debugging
var request = new XMLHttpRequest();
request.open("get", gNameRulesFileURL, false);
@ -141,8 +141,9 @@ function testNamesForMarkupRules(aMarkupElm, aContainer)
gTestIterator.iterateRules.bind(gTestIterator, elm, aContainer, ruleElms);
// Images may be recreated after we append them into subtree. We need to wait
// in this case.
if (isAccessible(elm))
// in this case. If we are on profiling enabled build then stack tracing
// works and thus let's log instead.
if (isAccessible(elm) || isLogged("stack"))
processMarkupRules();
else
waitForEvent(EVENT_SHOW, elm, processMarkupRules);