dom/tests/js/write2.html

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 <HTML>
     2 <HEAD>
     3 <SCRIPT>
     4 var w = null;
     5 var count = 0;
     6 var isOpen = false;
     8 function newWin() {
     9   if ((w == null) || (w.closed == true)) {
    10     w = window.open("about:blank", "writetest");
    11   }
    12 }
    14 function incrWrite() {
    15   if (w != null) {
    16     if (!isOpen) {
    17       count = 0;
    18       isOpen = true;
    19       w.document.write("<p>Opening document and counting up....</p>");
    20     }
    22     w.document.write("<p>Counter at: " + count++ + "</p>");
    23   }
    24 }
    26 function closeDoc() {
    27   if ((w != null) && isOpen) {
    28     w.document.write("<p>Closing document!</p>");
    29     w.document.close();
    30     isOpen = false;
    31   }
    32 }
    33 </SCRIPT>
    34 </HEAD>
    35 <BODY>
    36 <h1>document.write (out-of-line) test</h1>
    37 <p>This test uses the open, write and close methods of a
    38 document to construct a document. It tests the "out-of-line"
    39 capabilities of document.write i.e. the ability to use 
    40 document.write to create an entirely new document.</p>
    42 <form>
    43 <p>Use this button to create a new window. If one already
    44 exists, we'll use it.
    45 <INPUT TYPE="button" NAME="newwin" VALUE="New Window" onClick="newWin(); return true;">
    46 </p>
    48 <p>Use this button to write the new value of a counter into
    49 the document. If the document was previously closed, it will be
    50 reopened (and the old contents will be destroyed.
    51 <INPUT TYPE="button" NAME="incrwrite" VALUE="Write" onClick="incrWrite(); return true;">
    52 </p>
    54 <p>Use this button to close the document. Subsequent writes will rewrite
    55 the document.
    56 <INPUT TYPE="button" NAME="closedoc" VALUE="Close Document" onClick="closeDoc(); return true;">
    57 <p>
    58 </FORM>
    59 </BODY>
    60 </HTML>

mercurial