зеркало из https://github.com/mozilla/pjs.git
Bug 571459 - add a test to check shutdown document accessible in cache, r=davidb
This commit is contained in:
Родитель
74f11b1c9e
Коммит
326f917ce1
|
@ -56,7 +56,7 @@ interface nsIDOMDOMStringList;
|
|||
*
|
||||
* @status UNDER_REVIEW
|
||||
*/
|
||||
[scriptable, uuid(3e5cbd5c-dbab-4ea3-b82b-4cd6201d6fe0)]
|
||||
[scriptable, uuid(420f0f49-27c1-4ac1-b509-5aba4353909b)]
|
||||
interface nsIAccessibleRetrieval : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -128,6 +128,16 @@ interface nsIAccessibleRetrieval : nsISupports
|
|||
* @return - accessible relation type presented as human readable string
|
||||
*/
|
||||
AString getStringRelationType(in unsigned long aRelationType);
|
||||
|
||||
/**
|
||||
* Return an accessible for the given DOM node from the cache.
|
||||
* @note the method is intended for testing purposes
|
||||
*
|
||||
* @param aNode [in] the DOM node to get an accessible for
|
||||
*
|
||||
* @return cached accessible for the given DOM node if any
|
||||
*/
|
||||
nsIAccessible getAccessibleFromCache(in nsIDOMNode aNode);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -93,6 +93,11 @@ protected:
|
|||
*/
|
||||
void Shutdown();
|
||||
|
||||
inline nsDocAccessible* GetDocAccessibleFromCache(nsIDocument* aDocument) const
|
||||
{
|
||||
return mDocAccessibleCache.GetWeak(static_cast<void*>(aDocument));
|
||||
}
|
||||
|
||||
private:
|
||||
nsAccDocManager(const nsAccDocManager&);
|
||||
nsAccDocManager& operator =(const nsAccDocManager&);
|
||||
|
|
|
@ -997,6 +997,30 @@ nsAccessibilityService::GetStringRelationType(PRUint32 aRelationType,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAccessibilityService::GetAccessibleFromCache(nsIDOMNode* aNode,
|
||||
nsIAccessible** aAccessible)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccessible);
|
||||
|
||||
// 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 nsAccDocManager) can still
|
||||
// exist in the document cache.
|
||||
nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
|
||||
nsAccessible* accessible = FindAccessibleInCache(static_cast<void*>(node));
|
||||
if (!accessible) {
|
||||
nsCOMPtr<nsIDocument> document(do_QueryInterface(node));
|
||||
if (document)
|
||||
accessible = GetDocAccessibleFromCache(document);
|
||||
}
|
||||
|
||||
NS_IF_ADDREF(*aAccessible = accessible);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// nsIAccesibilityService
|
||||
nsAccessible*
|
||||
nsAccessibilityService::GetAccessibleInShell(nsIDOMNode *aNode,
|
||||
|
|
|
@ -222,6 +222,8 @@ function getAccessible(aAccOrElmOrID, aInterfaces, aElmObj, aDoNotFailIf)
|
|||
}
|
||||
}
|
||||
|
||||
acc.QueryInterface(nsIAccessNode);
|
||||
|
||||
if (!aInterfaces)
|
||||
return acc;
|
||||
|
||||
|
@ -394,6 +396,15 @@ function testAccessibleTree(aAccOrElmOrID, aAccTree)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if accessible for the given node is in cache.
|
||||
*/
|
||||
function isAccessibleInCache(aNodeOrId)
|
||||
{
|
||||
var node = getNode(aNodeOrId);
|
||||
return gAccRetrieval.getAccessibleFromCache(node) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test accessible tree for defunct accessible.
|
||||
*
|
||||
|
|
|
@ -46,6 +46,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_TEST_FILES =\
|
||||
docload_wnd.html \
|
||||
docload_wnd.xul \
|
||||
focus.html \
|
||||
scroll.html \
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Accessible events testing for document</title>
|
||||
<script>
|
||||
function hideIFrame()
|
||||
{
|
||||
var iframe = document.getElementById("iframe");
|
||||
|
||||
var accRetrieval = Components.classes["@mozilla.org/accessibleRetrieval;1"].
|
||||
getService(Components.interfaces.nsIAccessibleRetrieval);
|
||||
accRetrieval.getAccessibleFor(iframe.contentDocument);
|
||||
|
||||
iframe.style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body onload="hideIFrame();">
|
||||
<iframe id="iframe"></iframe>
|
||||
</body>
|
||||
</html>
|
|
@ -114,7 +114,7 @@
|
|||
return "remove iframe";
|
||||
|
||||
return "change display style of iframe to " +
|
||||
(aAction == kHide) ? "none" : "block";
|
||||
((aAction == kHide) ? "none" : "block");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,6 +142,11 @@
|
|||
}
|
||||
|
||||
this.finalCheck = function openDialogWnd_finalCheck()
|
||||
{
|
||||
this.finalCheckImpl();
|
||||
}
|
||||
|
||||
this.finalCheckImpl = function openDialogWnd_finalCheckImpl()
|
||||
{
|
||||
var accTree = {
|
||||
role: ROLE_APP_ROOT,
|
||||
|
@ -157,7 +162,14 @@
|
|||
|
||||
testAccessibleTree(this.mRootAcc, accTree);
|
||||
|
||||
var dlgDoc = this.mDialog.document;
|
||||
ok(isAccessibleInCache(dlgDoc),
|
||||
"The document accessible for '" + aURL + "' is not in cache!");
|
||||
|
||||
this.mDialog.close();
|
||||
|
||||
ok(!isAccessibleInCache(dlgDoc),
|
||||
"The document accessible for '" + aURL + "' is in cache still!");
|
||||
}
|
||||
|
||||
this.getID = function openDialogWnd_getID()
|
||||
|
@ -166,12 +178,49 @@
|
|||
}
|
||||
}
|
||||
|
||||
function openWndShutdownDoc()
|
||||
{
|
||||
this.__proto__ =
|
||||
new openDialogWnd("chrome://mochikit/content/a11y/accessible/events/docload_wnd.html");
|
||||
|
||||
var thisObj = this;
|
||||
var docChecker = {
|
||||
type: EVENT_HIDE,
|
||||
get target()
|
||||
{
|
||||
var iframe = this.invoker.mDialog.document.getElementById("iframe");
|
||||
this.invoker.iframeDoc = iframe.contentDocument;
|
||||
return iframe;
|
||||
},
|
||||
invoker: thisObj
|
||||
};
|
||||
|
||||
this.eventSeq.push(docChecker);
|
||||
|
||||
this.finalCheck = function openWndShutdownDoc_finalCheck()
|
||||
{
|
||||
// After timeout after event hide for iframe was handled the document
|
||||
// accessible for iframe's document is in cache still.
|
||||
ok(!isAccessibleInCache(this.iframeDoc),
|
||||
"The document accessible for iframe is in cache still after iframe hide!");
|
||||
|
||||
this.finalCheckImpl();
|
||||
|
||||
// After the window is closed all alive subdocument accessibles should
|
||||
// be shut down.
|
||||
ok(!isAccessibleInCache(this.iframeDoc),
|
||||
"The document accessible for iframe is in cache still!");
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Do tests
|
||||
|
||||
var gQueue = null;
|
||||
|
||||
// var gA11yEventDumpID = "eventdump"; // debug stuff
|
||||
// Debug stuff.
|
||||
// gA11yEventDumpID = "eventdump";
|
||||
// gA11yEventDumpToConsole = true;
|
||||
|
||||
function doTests()
|
||||
{
|
||||
|
@ -183,6 +232,7 @@
|
|||
gQueue.push(new morphIFrame("iframe", kShow));
|
||||
gQueue.push(new morphIFrame("iframe", kRemove));
|
||||
gQueue.push(new openDialogWnd("about:"));
|
||||
gQueue.push(new openWndShutdownDoc());
|
||||
|
||||
gQueue.invoke(); // Will call SimpleTest.finish();
|
||||
}
|
||||
|
@ -208,6 +258,11 @@
|
|||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=566103"
|
||||
title="Reorganize accessible document handling">
|
||||
Mozilla Bug 566103
|
||||
</a><br>
|
||||
<a target="_blank"
|
||||
href="https://bugzilla.mozilla.org/show_bug.cgi?id=571459"
|
||||
title="Shutdown document accessible when presshell goes away">
|
||||
Mozilla Bug 571459
|
||||
</a>
|
||||
|
||||
<p id="display"></p>
|
||||
|
|
Загрузка…
Ссылка в новой задаче