Bug 782991 - tab document should be a document load events target unconditionally (states/test_link.html intermittent failure), r=tbsaunde

This commit is contained in:
Alexander Surkov 2012-10-10 10:01:46 +09:00
parent 8f7a7fe9be
commit 92d72f2487
5 changed files with 63 additions and 15 deletions

View File

@ -196,7 +196,7 @@ LogDocParent(nsIDocument* aDocumentNode)
static void
LogDocInfo(nsIDocument* aDocumentNode, DocAccessible* aDocument)
{
printf(" DOM id: %p, acc id: %p\n ",
printf(" DOM document: %p, acc document: %p\n ",
static_cast<void*>(aDocumentNode), static_cast<void*>(aDocument));
// log document info
@ -322,6 +322,20 @@ LogRequest(nsIRequest* aRequest)
}
}
static void
LogDocAccState(DocAccessible* aDocument)
{
printf("document acc state: ");
if (aDocument->HasLoadState(DocAccessible::eCompletelyLoaded))
printf("completely loaded;");
else if (aDocument->HasLoadState(DocAccessible::eReady))
printf("ready;");
else if (aDocument->HasLoadState(DocAccessible::eDOMLoaded))
printf("DOM loaded;");
else if (aDocument->HasLoadState(DocAccessible::eTreeConstructed))
printf("tree constructed;");
}
static void
GetDocLoadEventType(AccEvent* aEvent, nsACString& aEventType)
{
@ -406,6 +420,30 @@ logging::DocLoad(const char* aMsg, nsIDocument* aDocumentNode)
MsgEnd();
}
void
logging::DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget)
{
MsgBegin(sDocLoadTitle, "document loaded *completely*");
nsIDocument* docNode = aDocument->GetDocumentNode();
printf(" DOM document: %p, acc document: %p\n",
static_cast<void*>(aDocument->GetDocumentNode()),
static_cast<void*>(aDocument));
printf(" ");
LogDocURI(aDocument->GetDocumentNode());
printf("\n");
printf(" ");
LogDocAccState(aDocument);
printf("\n");
printf(" document is load event target: %s\n",
(aIsLoadEventTarget ? "true" : "false"));
MsgEnd();
}
void
logging::DocLoadEventFired(AccEvent* aEvent)
{

View File

@ -56,6 +56,7 @@ bool IsEnabled(uint32_t aModules);
void DocLoad(const char* aMsg, nsIWebProgress* aWebProgress,
nsIRequest* aRequest, uint32_t aStateFlags);
void DocLoad(const char* aMsg, nsIDocument* aDocumentNode);
void DocCompleteLoad(DocAccessible* aDocument, bool aIsLoadEventTarget);
/**
* Log that document load event was fired.

View File

@ -1587,6 +1587,11 @@ DocAccessible::ProcessLoad()
{
mLoadState |= eCompletelyLoaded;
#ifdef A11Y_LOG
if (logging::IsEnabled(logging::eDocLoad))
logging::DocCompleteLoad(this, IsLoadEventTarget());
#endif
// Do not fire document complete/stop events for root chrome document
// accessibles and for frame/iframe documents because
// a) screen readers start working on focus event in the case of root chrome
@ -2072,25 +2077,31 @@ bool
DocAccessible::IsLoadEventTarget() const
{
nsCOMPtr<nsISupports> container = mDocument->GetContainer();
nsCOMPtr<nsIDocShellTreeItem> docShellTreeItem =
do_QueryInterface(container);
NS_ASSERTION(docShellTreeItem, "No document shell for document!");
nsCOMPtr<nsIDocShellTreeItem> treeItem = do_QueryInterface(container);
NS_ASSERTION(treeItem, "No document shell for document!");
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem));
treeItem->GetParent(getter_AddRefs(parentTreeItem));
// Return true if it's not a root document (either tab document or
// frame/iframe document) and its parent document is not in loading state.
// Note: we can get notifications while document is loading (and thus
// while there's no parent document yet).
// Not a root document.
if (parentTreeItem) {
// Return true if it's either:
// a) tab document;
nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem));
if (parentTreeItem == rootTreeItem)
return true;
// b) frame/iframe document and its parent document is not in loading state
// Note: we can get notifications while document is loading (and thus
// while there's no parent document yet).
DocAccessible* parentDoc = ParentDocument();
return parentDoc && parentDoc->HasLoadState(eCompletelyLoaded);
}
// It's content (not chrome) root document.
int32_t contentType;
docShellTreeItem->GetItemType(&contentType);
treeItem->GetItemType(&contentType);
return (contentType == nsIDocShellTreeItem::typeContent);
}

View File

@ -21,7 +21,7 @@
src="../events.js"></script>
<script type="application/javascript">
gA11yEventDumpToConsole = true; // debug stuff
//gA11yEventDumpToConsole = true; // debug stuff
function doTest()
{
@ -50,7 +50,7 @@
// a: traversal state
testStates("link_traversed", 0, 0, STATE_TRAVERSED);
enableLogging("docload");
//enableLogging("docload"); // debug stuff
registerA11yEventListener(EVENT_DOCUMENT_LOAD_COMPLETE,
traversedLinkTester);
@ -64,7 +64,7 @@
aEvent.accessible.rootDocument.window.close();
testStates("link_traversed", STATE_TRAVERSED);
disableLogging();
//disableLogging();
SimpleTest.finish();
}
};

View File

@ -20,8 +20,6 @@
<![CDATA[
function doTest()
{
disableLogging(); // a hack from failing test_link.html to stop logging.
// label with popup
testStates("labelWithPopup", STATE_HASPOPUP);