netwerk/test/mochitests/test_user_agent_updates_reset.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=942470
     5 -->
     6 <head>
     7   <title>Test for Bug 942470</title>
     8   <script type="text/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=942470">Mozilla Bug 942470</a>
    13 <p id="display"></p>
    14 <div id="content" style="display: none">
    15 </div>
    16 <pre id="test">
    17 <script class="testbody" type="text/javascript">
    19 /** Test for Bug 942470 **/
    21 function getUA(host) {
    22   var url = location.pathname;
    23   url = host + url.slice(0, url.lastIndexOf('/')) + '/user_agent.sjs';
    25   var xhr = new XMLHttpRequest();
    26   xhr.open('GET', url, false); // sync request
    27   xhr.send();
    28   is(xhr.status, 200, 'request failed');
    29   is(typeof xhr.response, 'string', 'invalid response');
    30   return xhr.response;
    31 }
    33 const UA_OVERRIDE = "DummyUserAgent";
    35 info("User agent is " + navigator.userAgent);
    36 isnot(navigator.userAgent, UA_OVERRIDE,
    37   "navigator.userAgent is not reverted");
    38 isnot(getUA(location.origin), UA_OVERRIDE,
    39   "User-Agent is not reverted");
    41 </script>
    42 </pre>
    43 </body>
    44 </html>

mercurial