mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 21:05:36 +00:00
Bug 393974 - Tree walkers leak with a non-null filter. r=smaug, sr=sicking, a=blocking1.9
This commit is contained in:
parent
dca0f40dcc
commit
c26dc0ef2c
@ -100,18 +100,22 @@ nsTreeWalker::~nsTreeWalker()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nsISupports stuff
|
* nsISupports and cycle collection stuff
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
NS_IMPL_CYCLE_COLLECTION_3(nsTreeWalker, mFilter, mCurrentNode, mRoot)
|
||||||
|
|
||||||
// QueryInterface implementation for nsTreeWalker
|
// QueryInterface implementation for nsTreeWalker
|
||||||
NS_INTERFACE_MAP_BEGIN(nsTreeWalker)
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsTreeWalker)
|
||||||
NS_INTERFACE_MAP_ENTRY(nsIDOMTreeWalker)
|
NS_INTERFACE_MAP_ENTRY(nsIDOMTreeWalker)
|
||||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTreeWalker)
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTreeWalker)
|
||||||
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(TreeWalker)
|
NS_INTERFACE_MAP_ENTRY_CONTENT_CLASSINFO(TreeWalker)
|
||||||
NS_INTERFACE_MAP_END
|
NS_INTERFACE_MAP_END
|
||||||
|
|
||||||
NS_IMPL_ADDREF(nsTreeWalker)
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsTreeWalker)
|
||||||
NS_IMPL_RELEASE(nsTreeWalker)
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsTreeWalker)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nsIDOMTreeWalker Getters/Setters
|
* nsIDOMTreeWalker Getters/Setters
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsVoidArray.h"
|
#include "nsVoidArray.h"
|
||||||
#include "nsJSUtils.h"
|
#include "nsJSUtils.h"
|
||||||
|
#include "nsCycleCollectionParticipant.h"
|
||||||
|
|
||||||
class nsINode;
|
class nsINode;
|
||||||
class nsIDOMNode;
|
class nsIDOMNode;
|
||||||
@ -56,7 +57,7 @@ class nsIDOMNodeFilter;
|
|||||||
class nsTreeWalker : public nsIDOMTreeWalker
|
class nsTreeWalker : public nsIDOMTreeWalker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
NS_DECL_NSIDOMTREEWALKER
|
NS_DECL_NSIDOMTREEWALKER
|
||||||
|
|
||||||
nsTreeWalker(nsINode *aRoot,
|
nsTreeWalker(nsINode *aRoot,
|
||||||
@ -64,7 +65,9 @@ public:
|
|||||||
nsIDOMNodeFilter *aFilter,
|
nsIDOMNodeFilter *aFilter,
|
||||||
PRBool aExpandEntityReferences);
|
PRBool aExpandEntityReferences);
|
||||||
virtual ~nsTreeWalker();
|
virtual ~nsTreeWalker();
|
||||||
/* additional members */
|
|
||||||
|
NS_DECL_CYCLE_COLLECTION_CLASS(nsTreeWalker)
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsINode> mRoot;
|
nsCOMPtr<nsINode> mRoot;
|
||||||
PRUint32 mWhatToShow;
|
PRUint32 mWhatToShow;
|
||||||
|
@ -55,6 +55,7 @@ _TEST_FILES = \
|
|||||||
test_bug370098.html \
|
test_bug370098.html \
|
||||||
test_bug377539.html \
|
test_bug377539.html \
|
||||||
test_bug384122.html \
|
test_bug384122.html \
|
||||||
|
test_bug393974.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_TEST_FILES)
|
libs:: $(_TEST_FILES)
|
||||||
|
70
dom/tests/mochitest/bugs/test_bug393974.html
Normal file
70
dom/tests/mochitest/bugs/test_bug393974.html
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html>
|
||||||
|
<!--
|
||||||
|
https://bugzilla.mozilla.org/show_bug.cgi?id=393974
|
||||||
|
-->
|
||||||
|
<head>
|
||||||
|
<title>Test for Bug 393974</title>
|
||||||
|
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
|
||||||
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=393974">Mozilla Bug 393974</a>
|
||||||
|
<p id="display"></p>
|
||||||
|
<div id="content" style="display: none">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<pre id="test">
|
||||||
|
<script class="testbody" type="text/javascript">
|
||||||
|
|
||||||
|
SimpleTest.waitForExplicitFinish();
|
||||||
|
|
||||||
|
function test()
|
||||||
|
{
|
||||||
|
// Create a tree walker with a filter which creates a cycle...
|
||||||
|
var tw = document.createTreeWalker(document, NodeFilter.SHOW_ALL,
|
||||||
|
function(n)
|
||||||
|
{
|
||||||
|
// force the closure to contain the
|
||||||
|
// global object, in case a future
|
||||||
|
// optimization might minimize the
|
||||||
|
// function's captured environment
|
||||||
|
if ("foo" + window == "fooPIRATES!")
|
||||||
|
return NodeFilter.FILTER_ACCEPT;
|
||||||
|
return NodeFilter.FILTER_REJECT;
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
|
||||||
|
// That should have been enough to create a leak, but we should do at least
|
||||||
|
// a couple tests while we're here so that this document doesn't show up as
|
||||||
|
// having no tests pass *or* fail.
|
||||||
|
|
||||||
|
ok(tw.firstChild() === null, "shouldn't be a first child");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.lastChild() === null, "shouldn't be a last child");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.nextNode() === null, "shouldn't be a next node");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.nextSibling() === null, "shouldn't be a next sibling");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.parentNode() === null, "shouldn't be a parent node");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.previousNode() === null, "shouldn't be a previous node");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
|
||||||
|
ok(tw.previousSibling() === null, "shouldn't be a previous sibling");
|
||||||
|
ok(tw.currentNode === document, "should be unchanged");
|
||||||
|
}
|
||||||
|
|
||||||
|
addLoadEvent(test);
|
||||||
|
addLoadEvent(SimpleTest.finish);
|
||||||
|
</script>
|
||||||
|
</pre>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user