netwerk/test/mochitests/test_user_agent_updates_reset.html

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=942470
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 942470</title>
michael@0 8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 10 </head>
michael@0 11 <body>
michael@0 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942470">Mozilla Bug 942470</a>
michael@0 13 <p id="display"></p>
michael@0 14 <div id="content" style="display: none">
michael@0 15 </div>
michael@0 16 <pre id="test">
michael@0 17 <script class="testbody" type="text/javascript">
michael@0 18
michael@0 19 /** Test for Bug 942470 **/
michael@0 20
michael@0 21 function getUA(host) {
michael@0 22 var url = location.pathname;
michael@0 23 url = host + url.slice(0, url.lastIndexOf('/')) + '/user_agent.sjs';
michael@0 24
michael@0 25 var xhr = new XMLHttpRequest();
michael@0 26 xhr.open('GET', url, false); // sync request
michael@0 27 xhr.send();
michael@0 28 is(xhr.status, 200, 'request failed');
michael@0 29 is(typeof xhr.response, 'string', 'invalid response');
michael@0 30 return xhr.response;
michael@0 31 }
michael@0 32
michael@0 33 const UA_OVERRIDE = "DummyUserAgent";
michael@0 34
michael@0 35 info("User agent is " + navigator.userAgent);
michael@0 36 isnot(navigator.userAgent, UA_OVERRIDE,
michael@0 37 "navigator.userAgent is not reverted");
michael@0 38 isnot(getUA(location.origin), UA_OVERRIDE,
michael@0 39 "User-Agent is not reverted");
michael@0 40
michael@0 41 </script>
michael@0 42 </pre>
michael@0 43 </body>
michael@0 44 </html>

mercurial