mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 583948, cache updaters before iterating, r=neil,a=dbaron
This commit is contained in:
parent
b9c241f5e4
commit
287ce9aa84
@ -404,6 +404,8 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
nsCOMArray<nsIContent> updaters;
|
||||
|
||||
for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) {
|
||||
// Skip any nodes that don't match our 'events' or 'targets'
|
||||
// filters.
|
||||
@ -418,6 +420,12 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||
if (! content)
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
|
||||
updaters.AppendObject(content);
|
||||
}
|
||||
|
||||
for (PRUint32 u = 0; u < updaters.Count(); u++) {
|
||||
nsIContent* content = updaters[u];
|
||||
|
||||
nsCOMPtr<nsIDocument> document = content->GetDocument();
|
||||
|
||||
NS_ASSERTION(document != nsnull, "element has no document");
|
||||
@ -430,7 +438,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||
CopyUTF16toUTF8(aEventName, aeventnameC);
|
||||
PR_LOG(gLog, PR_LOG_NOTICE,
|
||||
("xulcmd[%p] update %p event=%s",
|
||||
this, updater->mElement.get(),
|
||||
this, content,
|
||||
aeventnameC.get()));
|
||||
}
|
||||
#endif
|
||||
|
@ -57,6 +57,8 @@ _TEST_FILES = \
|
||||
$(NULL)
|
||||
|
||||
_CHROME_FILES = \
|
||||
test_bug583948.xul \
|
||||
window_bug583948.xul \
|
||||
test_bug497875.xul \
|
||||
bug497875-iframe.xul \
|
||||
$(NULL)
|
||||
|
41
content/xul/document/test/test_bug583948.xul
Normal file
41
content/xul/document/test/test_bug583948.xul
Normal file
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<div id="content" style="display: none"/>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
var attempts = 0;
|
||||
|
||||
function update() {
|
||||
setTimeout(function() {
|
||||
if (otherWindow.location)
|
||||
otherWindow.location.reload()
|
||||
}, 1);
|
||||
otherWindow.document.commandDispatcher.updateCommands('');
|
||||
// without the crash fix, this usually crashes after 2 to 4 reloads
|
||||
if (++attempts == 6) {
|
||||
ok(true, "didn't crash after 6 attempts");
|
||||
otherWindow.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
else {
|
||||
setTimeout(update, 100);
|
||||
}
|
||||
}
|
||||
|
||||
var otherWindow = window.open("window_bug583948.xul", "_new", "chrome");
|
||||
setTimeout(update, 100);
|
||||
</script>
|
||||
|
||||
</window>
|
8
content/xul/document/test/window_bug583948.xul
Normal file
8
content/xul/document/test/window_bug583948.xul
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml-stylesheet href="chrome://browser/skin/" type="text/css"?>
|
||||
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<command oncommandupdate="document.removeChild(document.documentElement)" commandupdater="true"/>
|
||||
<box command="c"/>
|
||||
<iframe/>
|
||||
|
||||
</window>
|
Loading…
Reference in New Issue
Block a user