test_geolocation.html (1970B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1372069 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1372069</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 11 <script type="application/javascript"> 12 13 const BASE_GEO_URL = "http://mochi.test:8888/tests/dom/geolocation/test/mochitest/network_geolocation.sjs"; 14 15 /** Test for Bug 1372069 */ 16 /** Modified for Bug 1441295 */ 17 SimpleTest.waitForExplicitFinish(); 18 window.onload = () => { 19 SimpleTest.waitForFocus(() => { 20 SpecialPowers.pushPrefEnv({"set": 21 [ 22 ["privacy.resistFingerprinting", true], 23 ["geo.prompt.testing", true], 24 ["geo.prompt.testing.allow", true], 25 ["geo.provider.network.url", BASE_GEO_URL], 26 ], 27 }, doTest_getCurrentPosition); 28 }, window); 29 }; 30 31 function doTest_getCurrentPosition() { 32 navigator.geolocation.getCurrentPosition( 33 () => { 34 ok(true, "Success callback is expected to be called"); 35 doTest_watchPosition(); 36 }, 37 (error) => { 38 ok(false, "Should be able to call success callback, Got error. code = " + error.code); 39 doTest_watchPosition(); 40 } 41 ); 42 } 43 44 function doTest_watchPosition() { 45 let wid = navigator.geolocation.watchPosition( 46 () => { 47 ok(true, "Success callback is expected to be called"); 48 navigator.geolocation.clearWatch(wid); 49 SimpleTest.finish(); 50 }, 51 (error) => { 52 ok(false, "Should be able to call success callback, Got error. code = " + error.code); 53 navigator.geolocation.clearWatch(wid); 54 SimpleTest.finish(); 55 } 56 ); 57 } 58 </script> 59 </head> 60 <body> 61 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a> 62 <p id="display"></p> 63 <div id="content" style="display: none"> 64 65 </div> 66 <pre id="test"></pre> 67 </body> 68 </html>