dom/tests/mochitest/bugs/test_protochains.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 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=817420
     5 -->
     6 <head>
     7   <meta charset="utf-8">
     8   <title>Test for Bug 817420</title>
     9   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    10   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    11 </head>
    12 <body>
    13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=817420">Mozilla Bug 817420</a>
    14 <p id="display"></p>
    15 <div id="content" style="display: none">
    17 </div>
    18 <pre id="test">
    19 <script type="application/javascript">
    21 /** Test for Bug 817420 **/
    22 is(Object.getPrototypeOf(HTMLElement.prototype), Element.prototype,
    23    "Must have correct proto chain for HTMLElement.prototype");
    24 is(Object.getPrototypeOf(document.createElementNS(null, "x")),
    25    Element.prototype,
    26    "Must have correct proto chain for random element");
    27 is(Object.getPrototypeOf(document.createElement("noSuchElementName")),
    28    HTMLUnknownElement.prototype,
    29    "Must have correct proto chain for random HTML element");
    31 // And check that it's really working as it should
    32 function checkPropPresent(propName, objList, expected)
    33 {
    34   for (obj of objList) {
    35     is(propName in obj,
    36        expected,
    37        obj + " should " + (expected ? "" : "not ") + "have the property");
    38   }
    39 }
    40 var objList = [ Element.prototype,
    41                 HTMLElement.prototype,
    42                 document.createElementNS(null, "x"),
    43                 document.createElement("noSuchElementName"),
    44                 document.body ]
    45 checkPropPresent("somePropertyThatBetterNeverExist", objList, false);
    46 Element.prototype.somePropertyThatBetterNeverExist = 1;
    47 checkPropPresent("somePropertyThatBetterNeverExist", objList, true);
    49 objList = [ HTMLElement.prototype,
    50             document.createElement("noSuchElementName"),
    51             document.body ]
    52 checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, false);
    53 HTMLElement.prototype.someOtherPropertyThatBetterNeverExist = 1;
    54 checkPropPresent("someOtherPropertyThatBetterNeverExist", objList, true);
    56 </script>
    57 </pre>
    58 </body>
    59 </html>

mercurial