- From: Marcos Cáceres via GitHub <sysbot+gh@w3.org>
- Date: Wed, 09 Jun 2021 09:41:55 +0000
- To: public-device-apis-log@w3.org
@rakina ok, below is a simple test case... I'll covert it to a WPT, but would like your feedback before I do.
The neat thing in all browsers is that removal and reattachment does indeed kill the geolocation service for the frame.
```JS
async function runTest() {
const iframe = document.createElement("iframe");
iframe.src = "empty.html";
document.body.appendChild(iframe);
console.log("loading iframe");
await new Promise((r) => {
iframe.onload = r;
});
// steal geolocation
const geo = win.navigator.geolocation;
// queue up some position watchers...
console.log(geo.watchPosition(console.log, console.error));
console.log(geo.watchPosition(console.log, console.error));
console.log(geo.watchPosition(console.log, console.error));
geo.getCurrentPosition(console.log, console.error)
geo.getCurrentPosition(console.log, console.error)
geo.getCurrentPosition(console.log, console.error)
// make doc no longer fully active
iframe.remove();
// try to use geolocation
try {
console.log("watchPosition", geo.watchPosition(console.log, console.error));
} catch (err) {
console.log(err);
}
try {
console.log(
"getCurrentPosition",
geo.getCurrentPosition(console.log, console.error)
);
} catch (err) {
console.log(err);
}
// re-attach
console.log("reattach");
document.body.appendChild(iframe);
// And we are back! But dead...
iframe.contentWindow.navigator.geolocation.getCurrentPosition(
console.log,
console.error
);
iframe.contentWindow.navigator.geolocation.watchPosition(
console.log,
console.error
);
console.log("done");
}
runTest();
```
--
GitHub Notification of comment by marcoscaceres
Please view or discuss this issue at https://github.com/w3c/geolocation-api/issues/78#issuecomment-857549097 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Wednesday, 9 June 2021 09:42:23 UTC