mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 19:38:13 +00:00
68 lines
2.0 KiB
XML
68 lines
2.0 KiB
XML
<?xml version="1.0"?>
|
|
<!--
|
|
|
|
This test exercises creation of DOM elements from the XUL document. It
|
|
creates a bookmark element and tries to insert it.
|
|
|
|
-->
|
|
<?xml-stylesheet href="dom-test-1.css" type="text/css"?>
|
|
|
|
<window
|
|
xmlns:html="http://www.w3.org/TR/REC-html40"
|
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
xmlns:nc="http://home.netscape.com/NC-rdf#"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
|
|
|
<html:script>
|
|
function AddBookmark()
|
|
{
|
|
// get the personal toolbar folder, which'll be constructed
|
|
// automagically by RDF
|
|
var folder = document.getElementById("NC:PersonalToolbarFolder");
|
|
dump("folder = " + folder + "\n");
|
|
if (folder == null)
|
|
return;
|
|
|
|
var treechildren = null;
|
|
for (var i = folder.childNodes.length - 1; i >= 0; --i) {
|
|
dump('folder.childNodes[' + i + '].nodeName = ' + folder.childNodes[i].nodeName + '\n');
|
|
if (folder.childNodes[i].nodeName == 'treechildren') {
|
|
treechildren = folder.childNodes[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
dump("treechildren = " + treechildren + "\n");
|
|
if (treechildren == null) {
|
|
treechildren = document.createElement('treechildren');
|
|
folder.appendChild(treechildren);
|
|
}
|
|
|
|
var newItem = document.createElement('treeitem');
|
|
newItem.setAttribute('id', 'http://home.netscape.com/people/waterson');
|
|
newItem.setAttribute('type', 'http://home.netscape.com/NC-rdf#Bookmark');
|
|
newItem.setAttribute('nc:Name', 'My Home Page');
|
|
newItem.setAttribute('rdf:property', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#_5');
|
|
|
|
treechildren.appendChild(newItem);
|
|
}
|
|
</html:script>
|
|
|
|
<html:button onclick="AddBookmark();">Add Bookmark</html:button>
|
|
|
|
<tree id="tree" datasources="rdf:bookmarks" onclick="return OpenURL(event,event.target.parentNode);">
|
|
<treecol rdf:resource="http://home.netscape.com/NC-rdf#Name"/>
|
|
<treecol rdf:resource="http://home.netscape.com/NC-rdf#URL"/>
|
|
<treehead>
|
|
<treeitem>
|
|
<treecell>Name</treecell>
|
|
<treecell>URL</treecell>
|
|
</treeitem>
|
|
</treehead>
|
|
|
|
<treebody id="NC:BookmarksRoot">
|
|
</treebody>
|
|
</tree>
|
|
|
|
</window>
|