test_toggling_performance_navigation_timing.html (2267B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 <title>Test for Bug 1511941 - Don't expose PerformanceNavigationTiming when it is disabled</title> 6 <script src="/tests/SimpleTest/SimpleTest.js"></script> 7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 8 </head> 9 <body> 10 <div id="content"> </div> 11 <script type="application/javascript"> 12 async function testWhetherExposed(resistFingerprinting, enable_performance_navigation_timing) { 13 await SpecialPowers.pushPrefEnv({ 14 "set": [["privacy.resistFingerprinting", resistFingerprinting], 15 ["dom.enable_performance_navigation_timing", enable_performance_navigation_timing]], 16 }); 17 var iframe = document.createElement("iframe"); 18 document.body.append(iframe); 19 var p = iframe.contentWindow.PerformanceNavigationTiming; 20 if (enable_performance_navigation_timing && resistFingerprinting) 21 isnot(p, undefined, "window.PerformanceNavigationTiming should be exposed when" 22 + " dom.enable_performance_navigation_timing=" + enable_performance_navigation_timing 23 + " and privacy.resistFingerprinting="+ resistFingerprinting +"."); 24 if (!enable_performance_navigation_timing) 25 is(p, undefined, "window.PerformanceNavigationTiming should not be exposed when" 26 + " dom.enable_performance_navigation_timing=" + enable_performance_navigation_timing 27 + " and privacy.resistFingerprinting="+ resistFingerprinting +"."); 28 if (enable_performance_navigation_timing && !resistFingerprinting) { 29 isnot(p, undefined, "window.PerformanceNavigationTiming should be exposed when" 30 + " dom.enable_performance_navigation_timing=" + enable_performance_navigation_timing 31 + " and privacy.resistFingerprinting="+ resistFingerprinting +"."); 32 } 33 } 34 35 async function start() { 36 await testWhetherExposed(true,true); 37 await testWhetherExposed(true,false); 38 await testWhetherExposed(false,true); 39 await testWhetherExposed(false,false); 40 SimpleTest.finish(); 41 } 42 43 SimpleTest.waitForExplicitFinish(); 44 start(); 45 </script> 46 </body> 47 </html>