Bug 990685: Dispatch document-element-inserted for XUL documents. r=bz

This commit is contained in:
Dave Townsend 2014-04-09 12:18:25 -07:00
Родитель 061c8169e6
Коммит 49af67b967
4 изменённых файлов: 50 добавлений и 0 удалений

Просмотреть файл

@ -2485,6 +2485,8 @@ XULDocument::PrepareToWalk()
// Block onload until we've finished building the complete
// document content model.
BlockOnload();
nsContentSink::NotifyDocElementCreated(this);
}
// There'd better not be anything on the context stack at this

Просмотреть файл

@ -5,6 +5,7 @@ support-files =
overlay2_bug335375.xul
window_bug583948.xul
window_bug757137.xul
window_documentnotification.xul
[test_bug199692.xul]
[test_bug311681.xul]
@ -20,3 +21,4 @@ support-files =
[test_bug583948.xul]
[test_bug640158_overlay_persist.xul]
[test_bug757137.xul]
[test_documentnotification.xul]

Просмотреть файл

@ -0,0 +1,40 @@
<?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/tests/SimpleTest/SimpleTest.js" />
<body xmlns="http://www.w3.org/1999/xhtml">
<div id="content" style="display: none"/>
</body>
<script>
SimpleTest.waitForExplicitFinish();
var seenNotification = false;
function notify(subject, topic, data) {
seenNotification = true;
is(topic, "document-element-inserted", "Should be the right notification");
is(subject, otherWindow.document, "Should have been notified about the right window");
ok(subject.documentElement, "documentElement should be defined");
}
var obs = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService)
obs.addObserver(notify, "document-element-inserted", false);
var otherWindow = window.open("window_documentnotification.xul", "_new", "chrome");
otherWindow.addEventListener("load", function() {
ok(seenNotification, "Should have seen the document-element-inserted")
obs.removeObserver(notify, "document-element-inserted");
window.close();
SimpleTest.waitForFocus(function() {
SimpleTest.finish();
});
});
</script>
</window>

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<label value="window_documentnotification.xul"/>
</window>