Bug 754165 - fire document load events on iframes too, r=tbsaunde, f=marcoz

This commit is contained in:
Alexander Surkov 2012-05-30 11:21:24 +09:00
parent 92fac6c13a
commit 8299869ee7
6 changed files with 74 additions and 25 deletions

View File

@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* 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/. */
#ifndef mozilla_a11y_DocAccessible_inl_h_
#define mozilla_a11y_DocAccessible_inl_h_
#include "DocAccessible.h"
#include "nsAccessibilityService.h"
inline DocAccessible*
DocAccessible::ParentDocument() const
{
return GetAccService()->GetDocAccessible(mDocument->GetParentDocument());
}
#endif

View File

@ -5,6 +5,7 @@
#include "Accessible-inl.h"
#include "AccIterator.h"
#include "DocAccessible-inl.h"
#include "nsAccCache.h"
#include "nsAccessibilityService.h"
#include "nsAccessiblePivot.h"
@ -2026,16 +2027,12 @@ DocAccessible::IsLoadEventTarget() const
nsCOMPtr<nsIDocShellTreeItem> parentTreeItem;
docShellTreeItem->GetParent(getter_AddRefs(parentTreeItem));
// It's not a root document.
if (parentTreeItem) {
nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
docShellTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
// 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.
if (parentTreeItem)
return ParentDocument()->HasLoadState(eCompletelyLoaded);
// It's not a sub document, i.e. a frame or iframe.
return (sameTypeRoot == docShellTreeItem);
}
// It's not chrome root document.
// It's content (not chrome) root document.
PRInt32 contentType;
docShellTreeItem->GetItemType(&contentType);
return (contentType == nsIDocShellTreeItem::typeContent);

View File

@ -149,8 +149,7 @@ public:
/**
* Return the parent document.
*/
DocAccessible* ParentDocument() const
{ return mParent ? mParent->Document() : nsnull; }
DocAccessible* ParentDocument() const;
/**
* Return the child document count.
@ -513,20 +512,13 @@ protected:
void ShutdownChildrenInSubtree(Accessible* aAccessible);
/**
* Return true if accessibility events accompanying document accessible
* loading should be fired.
* Return true if the document is a target of document loading events
* (for example, state busy change or document reload events).
*
* The rules are: do not fire events for root chrome document accessibles and
* for sub document accessibles (like HTML frame of iframe) of the loading
* document accessible.
*
* XXX: in general AT expect events for document accessible loading into
* tabbrowser, events from other document accessibles may break AT. We need to
* figure out what AT wants to know about loading page (for example, some of
* them have separate processing of iframe documents on the page and therefore
* they need a way to distinguish sub documents from page document). Ideally
* we should make events firing for any loaded document and provide additional
* info AT are needing.
* Rules: The root chrome document accessible is never an event target
* (for example, Firefox UI window). If the sub document is loaded within its
* parent document then the parent document is a target only (aka events
* coalescence).
*/
bool IsLoadEventTarget() const;

View File

@ -6,6 +6,7 @@
#include "AccessibleWrap.h"
#include "Compatibility.h"
#include "DocAccessible-inl.h"
#include "EnumVariant.h"
#include "nsAccUtils.h"
#include "nsCoreUtils.h"

View File

@ -27,7 +27,8 @@
this.DOMNode = getNode(aIdentifier);
this.eventSeq = [
new invokerChecker(EVENT_REORDER, getAccessible(this.DOMNode))
new invokerChecker(EVENT_REORDER, getAccessible(this.DOMNode)),
new asyncInvokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getIframeDoc)
];
this.invoke = function changeIframeSrc_invoke()
@ -54,6 +55,11 @@
{
return "change iframe src on " + aURL;
}
function getIframeDoc()
{
return getAccessible(getNode(aIdentifier).contentDocument);
}
}
const kHide = 1;
@ -308,6 +314,11 @@
title="The DOM document loaded before it's shown shouldn't have busy state">
Mozilla Bug 658185
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=754165"
title="Fire document load events on iframes too">
Mozilla Bug 754165
</a>
<p id="display"></p>
<div id="content" style="display: none"></div>

View File

@ -91,6 +91,25 @@
}
}
/**
* Load the document having sub document. No document loading events for
* nested document.
*/
function loadNestedDocURIInvoker(aNestedDocURI)
{
this.__proto__ = new loadURIInvoker(aNestedDocURI);
this.unexpectedEventSeq = [
new invokerChecker(EVENT_DOCUMENT_LOAD_COMPLETE, getNestedDoc),
new invokerChecker(EVENT_STATE_CHANGE, getNestedDoc)
];
function getNestedDoc()
{
return currentTabDocument().getElementsByTagName("iframe")[0].firstChild;
}
}
/**
* Reload the page by F5 (isFromUserInput flag is true).
*/
@ -170,6 +189,11 @@
function doTests()
{
gQueue = new eventQueue();
var dataURL =
"data:text/html,<html><body><iframe src='http://example.com'></iframe></body></html>";
gQueue.push(new loadNestedDocURIInvoker(dataURL));
gQueue.push(new loadURIInvoker("about:"));
gQueue.push(new userReloadInvoker());
gQueue.push(new loadURIInvoker("about:mozilla"));
@ -195,6 +219,11 @@
title=" reorganize accessible document handling">
Mozilla Bug 566103
</a>
<a target="_blank"
href="https://bugzilla.mozilla.org/show_bug.cgi?id=754165"
title="Fire document load events on iframes too">
Mozilla Bug 754165
</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>