Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: os == 'android'
- Manifest: dom/tests/mochitest/chrome/chrome.toml
<?xml version="1.0"?>
<!--
Test for Geolocation in chrome
-->
<window
id="sample-window"
width="400"
height="400"
>
<script
></script>
<script>
SimpleTest.waitForExplicitFinish();
async function test() {
/** @type {Geolocation} */
const geolocation = Cc["@mozilla.org/geolocation;1"].getService(
Ci.nsISupports
);
try {
// Watch position
let watchId;
let position = await new Promise((resolve, reject) => {
watchId = geolocation.watchPosition(resolve, reject, { timeout: 0 });
});
ok(position, "watchPosition() callable from chrome");
geolocation.clearWatch(watchId);
// Get position
position = await new Promise((resolve, reject) =>
geolocation.getCurrentPosition(resolve, reject)
);
ok(position, "getCurrentPosition() callable from chrome");
} catch (err) {
ok(
false,
"error occurred trying to get geolocation from chrome: " + err.message
);
} finally {
SimpleTest.finish();
}
}
</script>
<body
style="height: 300px; overflow: auto;"
onload="test()"
/>
</window>