-
Notifications
You must be signed in to change notification settings - Fork 3k
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
History API unavailable for URLs with 'file:' protocol #1592
History API unavailable for URLs with 'file:' protocol #1592
Conversation
Browsers that usually support the History API will disable it when the current URL is served off the filesystem with the 'file:' protocol. By including this protocol check, this becomes a more accurate test for apps running in Cordova/PhoneGap/similar, as HTML files in these scenarios are served locally off the device filesystem (so with location.protocol === 'file:'). Although the browser used by the Cordova app may support the history API, it doesn't with the 'file:' protocol.
If this is accepted, I'd like to add a test for this feature detect, though I'll need a nudge in the right direction please! Many thanks :-) |
Tests failed. Automated cross-browser testing via Sauce Labs and Travis CI shows that the JavaScript changes in this pull request are: BUSTED Commit: 56d0c21 (Please note that this is a fully automated comment.) |
I'm unsure how to proceed debugging this test failure on Travis, advice very much welcome:
|
Ok, it looks like that CI failure is acceptable. |
A test would be great. I am not sure if we can have one that will work on sauce, but we can get one that should work in at least phantom and when run locally via a redirect in the Would you happen to be able to find if this is just the standard behavior, or is it spec`ed as a standards behavior? |
Thanks @patrickkettner, In my excitement to get this fixed, I'd wrongly and naively assumed all browsers with the History API would disable it on Turns out that isn't the case - sorry...
There's nothing in the spec about the It appears Chrome has never fully supported the history API for Firefox 37.0.2 does not support the history API on Safari 7.1.6 and Opera 12 support the history API on For both Chrome and Firefox, with the Address Bar URL: Worked in console:
Bearing all of this in mind, I'm not sure where to take this next. Options include:
Or add (some of) these to the history feature detect:
Feedback, ideas welcome |
So I think the way we would do this would be to change the url then change it back to what it was previously, but that feels really dangerous. I have always been of the opinion that we shouldn't try to update the url, but in theory that operation should be safe - it would either break before the first change or never. @ryanseddon @stucox @SlexAxton - what do yall think? |
@patrickkettner this earlier PR is relevant, about various (potentially intrusive) history detect methods: #1270 Also starting to wonder if there's scope for finer-grained detects here, such as:
Are you aware of any other detects that have been broken down to support finer-grained detects? Regarding the potentially dangerous history test, where modernizr performs a |
ehhhhhh....... put yourself in the shoes of Joe Developer, who has no idea about all of these edge cases. Having that many detects would almost certainly just cause more confusion. Ideally those things are contained within the detect itself. The closest thing to being broken down in a kindof sort of not really way is the flexbox detects, which have separate tests for the separate versions of flexbox that shipped over the years.
all the tests are opt in - the issue is how do we let users know we are mucking about with their history. I am pretty sure it would be ok to do this, since it should either work in the switch and switch back, or won't work at all. I would just like some input from other memebers of the @Modernizr/modernizr-commit team |
Browsers that usually support the History API will disable it when the current URL is served off the filesystem with the
file:
protocol.By including this protocol check, this becomes a more accurate test for apps running in Cordova/PhoneGap/similar, as HTML files in these scenarios are served locally off the device filesystem (so with
location.protocol === 'file:'
). Although the browser used by the Cordova app may support the history API, it doesn't with thefile:
protocol.