dom/tests/mochitest/dom-level0/test_location_setters.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=639720
     5 -->
     6 <head>
     7   <title>Test for Bug 639720</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=639720">Mozilla Bug 639720</a>
    13 <p id="display">
    14   <iframe id="f"></iframe>
    15 </p>
    16 <div id="content" style="display: none">
    18 </div>
    19 <pre id="test">
    20 <script type="application/javascript">
    22 /** Test for Bug 639720 **/
    23 SimpleTest.waitForExplicitFinish();
    25 var tests = [
    26  { url: "data:text/plain,1" },
    27  { url: "data:text/plain,2",
    28    useDocument: true },
    29  { prepURL: "http://www.example.com",
    30    url: "data:text/plain,3" }
    31 ];
    33 var currentTest = 0;
    35 function checkTest() {
    36   is($("f").contentWindow.location.href, tests[currentTest].url,
    37      "href of content window's location should match url of current test");
    38   ++currentTest;
    39   runNextTest();
    40 }
    42 function runCurrentTest() {
    43   var test = tests[currentTest];
    44   $("f").onload = checkTest;
    45   if (test.useDocument) {
    46     $("f").contentDocument.location = test.url;
    47   } else {
    48     $("f").contentWindow.location = test.url;
    49   }
    50   is(typeof($("f").contentWindow.location), "object",
    51      "Location should not have become string");
    52 }
    54 function prepComplete() {
    55   runCurrentTest();
    56 }
    58 function runNextTest() {
    59   if (currentTest == tests.length) {
    60     SimpleTest.finish();
    61     return;
    62   }
    64   var test = tests[currentTest];
    65   if ("prepURL" in test) {
    66     $("f").onload = prepComplete;
    67     $("f").src = test.prepURL;
    68     return;
    69   }
    71   runCurrentTest();
    72 }
    74 addLoadEvent(runNextTest);
    75 </script>
    76 </pre>
    77 </body>
    78 </html>

mercurial