зеркало из https://github.com/mozilla/gecko-dev.git
Bug 583948, cache updaters before iterating, r=neil,a=dbaron
This commit is contained in:
Родитель
b9c241f5e4
Коммит
287ce9aa84
|
@ -404,6 +404,8 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsCOMArray<nsIContent> updaters;
|
||||||
|
|
||||||
for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) {
|
for (Updater* updater = mUpdaters; updater != nsnull; updater = updater->mNext) {
|
||||||
// Skip any nodes that don't match our 'events' or 'targets'
|
// Skip any nodes that don't match our 'events' or 'targets'
|
||||||
// filters.
|
// filters.
|
||||||
|
@ -418,6 +420,12 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||||
if (! content)
|
if (! content)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
|
updaters.AppendObject(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (PRUint32 u = 0; u < updaters.Count(); u++) {
|
||||||
|
nsIContent* content = updaters[u];
|
||||||
|
|
||||||
nsCOMPtr<nsIDocument> document = content->GetDocument();
|
nsCOMPtr<nsIDocument> document = content->GetDocument();
|
||||||
|
|
||||||
NS_ASSERTION(document != nsnull, "element has no document");
|
NS_ASSERTION(document != nsnull, "element has no document");
|
||||||
|
@ -430,7 +438,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||||
CopyUTF16toUTF8(aEventName, aeventnameC);
|
CopyUTF16toUTF8(aEventName, aeventnameC);
|
||||||
PR_LOG(gLog, PR_LOG_NOTICE,
|
PR_LOG(gLog, PR_LOG_NOTICE,
|
||||||
("xulcmd[%p] update %p event=%s",
|
("xulcmd[%p] update %p event=%s",
|
||||||
this, updater->mElement.get(),
|
this, content,
|
||||||
aeventnameC.get()));
|
aeventnameC.get()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -57,6 +57,8 @@ _TEST_FILES = \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
_CHROME_FILES = \
|
_CHROME_FILES = \
|
||||||
|
test_bug583948.xul \
|
||||||
|
window_bug583948.xul \
|
||||||
test_bug497875.xul \
|
test_bug497875.xul \
|
||||||
bug497875-iframe.xul \
|
bug497875-iframe.xul \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
Загрузка…
Ссылка в новой задаче