summaryrefslogtreecommitdiffstats
path: root/netwerk/test/mochitests/test_user_agent_updates_reset.html
blob: 5b51fc40d5bb41c0eea13a423ac21d25041dd5a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=942470
-->
<head>
  <title>Test for Bug 942470</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=942470">Mozilla Bug 942470</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">

/** Test for Bug 942470 **/

function getUA(host) {
  var url = location.pathname;
  url = host + url.slice(0, url.lastIndexOf('/')) + '/user_agent.sjs';

  var xhr = new XMLHttpRequest();
  xhr.open('GET', url, false); // sync request
  xhr.send();
  is(xhr.status, 200, 'request failed');
  is(typeof xhr.response, 'string', 'invalid response');
  return xhr.response;
}

const UA_OVERRIDE = "DummyUserAgent";

info("User agent is " + navigator.userAgent);
isnot(navigator.userAgent, UA_OVERRIDE,
  "navigator.userAgent is not reverted");
isnot(getUA(location.origin), UA_OVERRIDE,
  "User-Agent is not reverted");

</script>
</pre>
</body>
</html>