You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
history.pushState is not available in packaged apps. #11932
This prevents the error message from appearing for me:
angular
.module('app', [], function($provide) {
// Prevent Angular from sniffing for the history API
// since it's not supported in packaged apps.
$provide.decorator('$window', function($delegate) {
$delegate.history = null;
return $delegate;
});
})
;
well judging from the history of this, it seems like this feature has been disabled in chrome platform apps for a very long time (the bug is about getting rid of an extended IDL attribute and making the bindings layer simpler --- was this working for you during some window in packaged apps before M43?)
At any rate, @jdiamond's decorator trick will work for now, so maybe we can close this? I don't think we have a reliable way of detecting whether we're running in crippled API mode or not
@raghavcreddy, indeed window.history isn't writable in Chrome 48.
I tried defining a new history getter on window and it seemed to work (see below). It achieves the same effect as the original workaround.
.config(function($provide){$provide.decorator('$window',function($delegate){Object.defineProperty($delegate,'history',{get: ()=>null});return$delegate;});});// Or using the `.decorator()` helper:.decorator('$window',function($delegate){Object.defineProperty($delegate,'history',{get: ()=>null});return$delegate;});
I have a fix for this is #13945. If that gets merged, then the workaround won't be necessary. @raghavcreddy, btw, I think in Chrome Packaged Apps you should be running in CSP mode.
BTW, if someone could try a (preferrably non-trivial Chrome Packaged App) with the files from this build and let me know if it logs any errors and if everything works as expected, that would awesome !
(Make sure NOT to include the workaround.)
Activity
jdiamond commentedon May 24, 2015
This prevents the error message from appearing for me:
caitp commentedon May 24, 2015
well judging from the history of this, it seems like this feature has been disabled in chrome platform apps for a very long time (the bug is about getting rid of an extended IDL attribute and making the bindings layer simpler --- was this working for you during some window in packaged apps before M43?)
At any rate, @jdiamond's decorator trick will work for now, so maybe we can close this? I don't think we have a reliable way of detecting whether we're running in crippled API mode or not
raghavcreddy commentedon Feb 2, 2016
The decorator is not working anymore starting from Chrome 48.0.2564.97 (64-bit).
Is there any workaround?
gkalpak commentedon Feb 2, 2016
It is strange, because this workaround shouldn't be affected by browser behavior.
Do you have a (preferrably minimal) working demo of the issue ?
raghavcreddy commentedon Feb 3, 2016
Here's a minimal working demo of the issue. It's a Chrome packaged app.
https://github.com/raghavcreddy/ChromeAppAngular
gkalpak commentedon Feb 3, 2016
Thx @raghavcreddy. I'll take a look.
gkalpak commentedon Feb 3, 2016
@raghavcreddy, indeed
window.historyisn't writable in Chrome 48.I tried defining a new
historygetter onwindowand it seemed to work (see below). It achieves the same effect as the original workaround.raghavcreddy commentedon Feb 4, 2016
Thank you @gkalpak
fix($sniffer): fix history sniffing in Chrome Packaged Apps
gkalpak commentedon Feb 4, 2016
I have a fix for this is #13945. If that gets merged, then the workaround won't be necessary.
@raghavcreddy, btw, I think in Chrome Packaged Apps you should be running in CSP mode.
schellmax commentedon Feb 4, 2016
thanks a lot for sharing the workaround.
for those not familiar with ES6 yet (like me), here's the 'back-ported' version ;)
gkalpak commentedon Feb 4, 2016
BTW, if someone could try a (preferrably non-trivial Chrome Packaged App) with the files from this build and let me know if it logs any errors and if everything works as expected, that would awesome !
(Make sure NOT to include the workaround.)
schellmax commentedon Feb 6, 2016
@gkalpak i've removed the workaround in my project and replaced angular.js by the one from your build, works just fine, no more errors in chrome app
gkalpak commentedon Feb 6, 2016
@schellmax, that's good to know. Thx for trying it out 👍
All we need now is to get #13945 merged :)
proofofvirtue commentedon Mar 21, 2016
@gkalpak I tried getting the files from that build but it's gone. I get error 404.
gkalpak commentedon Mar 21, 2016
@donkonstante, yeah orlder builds get deleted after some time. You can always checkout #13945 and build it yourself if you need it.
(I'll go lobby to get #13945 merged 😛)
fix($sniffer): fix history sniffing in Chrome Packaged Apps
gkalpak commentedon Mar 22, 2016
It's in master and will be included in the upcoming 1.5.x release.
@donkonstante, until then, you can grab the latest code from https://code.angularjs.org/snapshot/.
fix($sniffer): don't use history.pushState for sandboxed Chrome apps
fix($sniffer): don't use `history.pushState` in sandboxed Chrome Pack…
fix($sniffer): don't use `history.pushState` in sandboxed Chrome Pack…
fix($sniffer): don't use `history.pushState` in sandboxed Chrome Pack…
fix($sniffer): don't use `history.pushState` in sandboxed Chrome Pack…
husin-sajjadi commentedon Oct 18, 2020
I have the same problem in angular 9
How to fix that in angular 2+?
Thank you
fix($sniffer): fix history sniffing in Chrome Packaged Apps