dom/tests/mochitest/bugs/test_bug529328.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=529328
     5 -->
     6 <head>
     7   <title>Test for Bug 529328</title>
     8   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     9   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    10 </head>
    11 <body>
    12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=529328">Mozilla Bug 529328</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    15 </div>
    16 <pre id="test">
    17 <script type="application/javascript">
    18 /** Test for Bug 529328 **/
    19 function testDOMTokenList() {
    20   is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    21   is(document.body.classList[0], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    22   is(document.body.classList[1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    23   is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    24   is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
    25   is(document.body.classList.item(0), null, "Wrong value for out of bounds access (DOMTokenList)");
    26   is(document.body.classList.item(1), null, "Wrong value for out of bounds access (DOMTokenList)");
    27   is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
    29   document.body.className = "a b";
    30   is(document.body.classList[-1], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    31   is(document.body.classList[0], "a", "Wrong value for in bounds access (DOMTokenList)");
    32   is(document.body.classList[1], "b", "Wrong value for in bounds access (DOMTokenList)");
    33   is(document.body.classList[2], undefined, "Wrong value for out of bounds access (DOMTokenList)");
    34   is(document.body.classList.item(-1), null, "Wrong value for out of bounds access (DOMTokenList)");
    35   is(document.body.classList.item(0), "a", "Wrong value for in bounds access (DOMTokenList)");
    36   is(document.body.classList.item(1), "b", "Wrong value for in bounds access (DOMTokenList)");
    37   is(document.body.classList.item(2), null, "Wrong value for out of bounds access (DOMTokenList)");
    38 }
    40 function testDOMStringList() {
    41   is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    42   is(document.styleSheetSets[0], undefined, "Wrong value for out of bounds access (DOMStringList)");
    43   is(document.styleSheetSets[1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    44   is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
    45   is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
    46   is(document.styleSheetSets.item(0), null, "Wrong value for out of bounds access (DOMStringList)");
    47   is(document.styleSheetSets.item(1), null, "Wrong value for out of bounds access (DOMStringList)");
    48   is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
    50   var s = document.createElement("style");
    51   s.title = "a";
    52   document.head.appendChild(s);
    53   s = document.createElement("style");
    54   s.title = "b";
    55   document.head.appendChild(s);
    57   is(document.styleSheetSets[-1], undefined, "Wrong value for out of bounds access (DOMStringList)");
    58   is(document.styleSheetSets[0], "a", "Wrong value for in bounds access (DOMStringList)");
    59   is(document.styleSheetSets[1], "b", "Wrong value for in bounds access (DOMStringList)");
    60   is(document.styleSheetSets[2], undefined, "Wrong value for out of bounds access (DOMStringList)");
    61   is(document.styleSheetSets.item(-1), null, "Wrong value for out of bounds access (DOMStringList)");
    62   is(document.styleSheetSets.item(0), "a", "Wrong value for in bounds access (DOMStringList)");
    63   is(document.styleSheetSets.item(1), "b", "Wrong value for in bounds access (DOMStringList)");
    64   is(document.styleSheetSets.item(2), null, "Wrong value for out of bounds access (DOMStringList)");
    65 }
    67 function testMediaList() {
    68   var s = document.createElement("style");
    69   document.head.appendChild(s);
    70   is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
    71   is(s.sheet.media[0], undefined, "Wrong value for out of bounds access (MediaList)");
    72   is(s.sheet.media[1], undefined, "Wrong value for out of bounds access (MediaList)");
    73   is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
    74   is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
    75   is(s.sheet.media.item(0), null, "Wrong value for out of bounds access (MediaList)");
    76   is(s.sheet.media.item(1), null, "Wrong value for out of bounds access (MediaList)");
    77   is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
    79   s.setAttribute("media", "a, b");
    81   is(s.sheet.media[-1], undefined, "Wrong value for out of bounds access (MediaList)");
    82   is(s.sheet.media[0], "a", "Wrong value for in bounds access (MediaList)");
    83   is(s.sheet.media[1], "b", "Wrong value for in bounds access (MediaList)");
    84   is(s.sheet.media[2], undefined, "Wrong value for out of bounds access (MediaList) (MediaList)");
    85   is(s.sheet.media.item(-1), null, "Wrong value for out of bounds access (MediaList)");
    86   is(s.sheet.media.item(0), "a", "Wrong value for in bounds access (MediaList)");
    87   is(s.sheet.media.item(1), "b", "Wrong value for in bounds access (MediaList)");
    88   is(s.sheet.media.item(2), null, "Wrong value for out of bounds access (MediaList) (MediaList)");
    89 }
    91 function testCSSStyleDeclaration() {
    92   var s = document.createElement("span");
    94   is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    95   is(s.style[0], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    96   is(s.style[1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    97   is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
    98   is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
    99   is(s.style.item(0), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   100   is(s.style.item(1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   101   is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   103   s.setAttribute("style", "color: blue; z-index: 42;");
   105   is(s.style[-1], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   106   is(s.style[0], "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
   107   is(s.style[1], "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
   108   is(s.style[2], undefined, "Wrong value for out of bounds access (CSSStyleDeclaration)");
   109   is(s.style.item(-1), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   110   is(s.style.item(0), "color", "Wrong value for in bounds access (CSSStyleDeclaration)");
   111   is(s.style.item(1), "z-index", "Wrong value for in bounds access (CSSStyleDeclaration)");
   112   is(s.style.item(2), "", "Wrong value for out of bounds access (CSSStyleDeclaration)");
   113 }
   115 testDOMTokenList();
   116 testDOMStringList();
   117 testMediaList();
   118 testCSSStyleDeclaration();
   119 </script>
   120 </pre>
   121 </body>
   122 </html>

mercurial