test_navigatorPrefOverride.html (1727B)
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 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 18 ok(navigator.appVersion, "This is used just to populate the cache"); 19 ok(navigator.platform, "This is used just to populate the cache"); 20 ok(navigator.userAgent, "This is used just to populate the cache"); 21 ok(navigator.buildID, "This is used just to populate the cache"); 22 23 SpecialPowers.pushPrefEnv({"set": [ 24 ["general.appversion.override", "appVersion overridden"], 25 ["general.platform.override", "platform overridden"], 26 ["general.useragent.override", "userAgent overridden"], 27 ["general.buildID.override", "buildID overridden"], 28 ]}, 29 function() { 30 var ifr = document.createElement('IFRAME'); 31 ifr.src = "about:blank"; 32 33 ifr.addEventListener('load', function() { 34 var nav = ifr.contentWindow.navigator; 35 isnot(navigator.appVersion, nav.appVersion, "appVersion should match"); 36 isnot(navigator.platform, nav.platform, "platform should match"); 37 isnot(navigator.userAgent, nav.userAgent, "userAgent should match"); 38 isnot(navigator.buildID, nav.buildID, "buildID should match"); 39 SimpleTest.finish(); 40 }); 41 42 document.getElementById('content').appendChild(ifr); 43 } 44 ); 45 46 SimpleTest.waitForExplicitFinish(); 47 48 </script> 49 </pre> 50 </body> 51 </html>