test_bug1062920.html 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <!DOCTYPE HTML>
  6. <html>
  7. <head>
  8. <title>Test for navigator property override</title>
  9. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  10. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  11. </head>
  12. <body>
  13. <p id="display"></p>
  14. <div id="content" style="display: none"></div>
  15. <pre id="test"></pre>
  16. <script class="testbody" type="text/javascript">
  17. function checkValues() {
  18. var worker = new Worker("bug1062920_worker.js");
  19. worker.onmessage = function(event) {
  20. var ifr = document.createElement('IFRAME');
  21. ifr.src = "about:blank";
  22. ifr.addEventListener('load', function() {
  23. var nav = ifr.contentWindow.navigator;
  24. is(event.data.appCodeName, nav.appCodeName, "appCodeName should match");
  25. is(event.data.appName, nav.appName, "appName should match");
  26. is(event.data.appVersion, nav.appVersion, "appVersion should match");
  27. is(event.data.platform, nav.platform, "platform should match");
  28. is(event.data.userAgent, nav.userAgent, "userAgent should match");
  29. is(event.data.product, nav.product, "product should match");
  30. runTests();
  31. }, false);
  32. document.getElementById('content').appendChild(ifr);
  33. };
  34. }
  35. function replaceAndCheckValues() {
  36. SpecialPowers.pushPrefEnv({"set": [
  37. ["general.appname.override", "appName overridden"],
  38. ["general.appversion.override", "appVersion overridden"],
  39. ["general.platform.override", "platform overridden"],
  40. ["general.useragent.override", "userAgent overridden"]
  41. ]}, checkValues);
  42. }
  43. var tests = [
  44. checkValues,
  45. replaceAndCheckValues
  46. ];
  47. function runTests() {
  48. if (tests.length == 0) {
  49. SimpleTest.finish();
  50. return;
  51. }
  52. var test = tests.shift();
  53. test();
  54. }
  55. SimpleTest.waitForExplicitFinish();
  56. runTests();
  57. </script>
  58. </pre>
  59. </body>
  60. </html>