-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deal with not fully active documents #78
Comments
Thanks! I think this is already somewhat implicitly specified by step 4 of "request position", which waits for the document to become visible, and bfcached/non-fully active documents should not be visible. But I think it is better to make it more explicit (wait for the document to become fully active also). |
Ok, so, it might be worth checking if the document is still active as part of acquire position. I'll verify what browsers do there... if they silently ignore the request or error. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Did a little digging... both Chromium and WebKit simply do the following check:
But I couldn't find any other checks for when It's hard to test if the callbacks are invoked, as even Gecko unfortunately throws. I can probably fix that in Gecko easily enough though. |
@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. 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(); |
Filed Gecko bug https://bugzilla.mozilla.org/show_bug.cgi?id=1715482 |
Sent Gecko patch: https://phabricator.services.mozilla.com/D117273 |
Test file is here: https://marcoscaceres.github.io/playground/geo_test.html |
Thanks a lot @marcoscaceres! I think the test looks good, neat that you can test it with just iframes. CC-ing @hiroshige-g who is working on BFCache WPTs so that he can make a similar test but with BFCache involved (he's also currently working on a guide to write BFCache tests) and @fergald who is involved in BFCache WPT stuff as well. |
See guide - example using Geolocation, which is not covered in our spec I think.
Cc @rakina for review.
The text was updated successfully, but these errors were encountered: