content/base/test/test_bug366944.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 <!doctype html>
     2 <!--
     3 https://bugzilla.mozilla.org/show_bug.cgi?id=366944
     4 -->
     5 <title>Test for Bug 366944</title>
     6 <script src="/tests/SimpleTest/SimpleTest.js"></script>
     7 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
     8 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=366944">Mozilla Bug 366944</a>
     9 <script>
    11 /** Test for Bug 366944 **/
    12 var testNodes = [document, document.doctype, document.createDocumentFragment()];
    13 for (var i = 0; i < testNodes.length; i++) {
    14   var range = document.createRange();
    15   // If a non-Text node is partially contained, we expect to throw for that
    16   // first
    17   range.setStart(document.head, 0);
    18   range.setEnd(document.body, 0);
    19   var threw = false;
    20   var desc = " (surrounding a range with partially-contained Element "
    21     + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")";
    22   try {
    23     range.surroundContents(testNodes[i]);
    24   } catch(e) {
    25     threw = true;
    26     is(Object.getPrototypeOf(e), DOMException.prototype,
    27        "Must throw DOMException" + desc);
    28     is(e.name, "InvalidStateError", "Must throw InvalidStateError" + desc);
    29   }
    30   ok(threw, "Must throw" + desc);
    32   range.setStart(document.body, 0);
    33   range.setEnd(document.body, 1);
    34   threw = false;
    35   desc = " (surrounding a regular range "
    36     + "with " + (i == 0 ? "document" : i == 1 ? "doctype" : "docfrag") + ")";
    37   try {
    38     range.surroundContents(testNodes[i]);
    39   } catch(e) {
    40     threw = true;
    41     is(Object.getPrototypeOf(e), DOMException.prototype,
    42        "Must throw DOMException" + desc);
    43     is(e.name, "InvalidNodeTypeError",
    44        "Must throw InvalidNodeTypeError" + desc);
    45   }
    46   ok(threw, "Must throw" + desc);
    47 }
    49 </script>

mercurial