<?xml version="1.0"?>
<?xml-stylesheet href="chrome://communicator/skin/" type="text/css"?>

<!-- taken from dom/tests/js/write2.html -->

<window
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  id="documentwrite" orient="vertical"
  script-type="application/x-python"
  title="document.write test">

  <script>
    <![CDATA[

w = None
count = 0
isOpen = False

def newWin():
    global w
    if w is None or w.closed:
        w = window.open("about:blank", "writetest")
        print "doc is", w.document

def incrWrite():
    global count, isOpen
    if w is not None:
        if not isOpen:
            count = 0
            isOpen = True
            w.document.nsIDOMHTMLDocument.write("<p>Opening document and counting up....</p>")
        w.document.nsIDOMHTMLDocument.write("<p>Counter at: " + count++ + "</p>")

def closeDoc():
    global isOpen
    if w is not None and isOpen:
        w.document.write("<p>Closing document!</p>")
        w.document.close()
        isOpen = false;

    ]]>
  </script>

    <description>
        This test uses the open, write and close methods of a
        document to construct a document. It tests the 'out-of-line'
        capabilities of document.write i.e. the ability to use 
        document.write to create an entirely new document.
    </description>>

    <box>
        <text class="label" value="
            Use this button to create a new window. If one already
            exists, we'll use it."/>
        <button label="New Window" onclick="newWin(); return True"/>
    </box>
    
    <box>
        <description>
            Use this button to write the new value of a
            counter into the document. If the document was previously closed, it will be
            reopened (and the old contents will be destroyed.)
        </description>
        <button label="Write" onclick="incrWrite(); return True"/>
    </box>

    <box>
        <description>
            Use this button to close the document. Subsequent writes will
            rewrite the document.
        </description>
        <button label="Close Document" onclick="closeDoc(); return True"/>
    </box>
</window>
