test_user_agent_updates_reset.html 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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">
  18. /** Test for Bug 942470 **/
  19. function getUA(host) {
  20. var url = location.pathname;
  21. url = host + url.slice(0, url.lastIndexOf('/')) + '/user_agent.sjs';
  22. var xhr = new XMLHttpRequest();
  23. xhr.open('GET', url, false); // sync request
  24. xhr.send();
  25. is(xhr.status, 200, 'request failed');
  26. is(typeof xhr.response, 'string', 'invalid response');
  27. return xhr.response;
  28. }
  29. const UA_OVERRIDE = "DummyUserAgent";
  30. info("User agent is " + navigator.userAgent);
  31. isnot(navigator.userAgent, UA_OVERRIDE,
  32. "navigator.userAgent is not reverted");
  33. isnot(getUA(location.origin), UA_OVERRIDE,
  34. "User-Agent is not reverted");
  35. </script>
  36. </pre>
  37. </body>
  38. </html>