Fix bug 431833: fire DOMFrameContentLoaded on the immediate parent document of the frame. r=bent, sr=sicking, a=beltzner

This commit is contained in:
bzbarsky@mit.edu 2008-05-04 20:53:42 -07:00
parent 00cf6ae1f2
commit 3398f8db45
3 changed files with 54 additions and 7 deletions

View File

@ -2804,12 +2804,7 @@ nsDocument::DispatchContentLoadedEvents()
if (target_frame) {
nsCOMPtr<nsIDocument> parent = mParentDocument;
while (parent) {
parent = parent->GetParentDocument();
if (!parent) {
break;
}
do {
nsCOMPtr<nsIDOMDocumentEvent> document_event =
do_QueryInterface(parent);
@ -2851,7 +2846,9 @@ nsDocument::DispatchContentLoadedEvents()
}
}
}
}
parent = parent->GetParentDocument();
} while (parent);
}
UnblockOnload(PR_TRUE);

View File

@ -178,6 +178,7 @@ _TEST_FILES = test_bug5141.html \
file_bug428847-1.xhtml \
file_bug428847-2.xhtml \
test_bug425201.html \
test_bug431833.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,49 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=431833
-->
<head>
<title>Test for Bug 431833</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=431833">Mozilla Bug 431833</a>
<p id="display">
<iframe id="f1" src="data:text/html,1"></iframe>
<iframe id="f2" src="data:text/html,2"></iframe>
<iframe id="f3" src="data:text/html,<iframe id='f4' src='data:text/html,3'></iframe>"></iframe>
</p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 431833 **/
var str = "FAIL";
function test(e) {
if (str == "FAIL")
str = "";
str += "PASS: " + e.target.id + '. ';
}
window.addEventListener('DOMFrameContentLoaded',test,true);
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
is(str, "PASS: f1. PASS: f2. PASS: f3. PASS: f4. ",
"DOMFrameContentLoaded events didn't fire?");
});
addLoadEvent(SimpleTest.finish);
</script>
</pre>
</body>
</html>