-
Notifications
You must be signed in to change notification settings - Fork 27.4k
history.pushState is not available in packaged apps. #11932
Comments
This prevents the error message from appearing for me:
|
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 |
The decorator is not working anymore starting from Chrome 48.0.2564.97 (64-bit). Is there any workaround? |
It is strange, because this workaround shouldn't be affected by browser behavior. |
Here's a minimal working demo of the issue. It's a Chrome packaged app. |
Thx @raghavcreddy. I'll take a look. |
@raghavcreddy, indeed .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;
}); |
Thank you @gkalpak |
Although `window.history` is present in the context of Chrome Packaged Apps, it is not allowed to access `window.history.pushState` or `window.history.state`, resulting in errors when trying to "sniff" history support. This commit fixes it by detecting a Chrome Packaged App (through the presence of `window.chrome.app.runtime`). Note that `window.chrome.app` is present in the context of "normal" webpages as well, but it doesn't have the `runtime` property, which is only available to packaged apps (e.g. see https://developer.chrome.com/apps/api_index). Fixes angular#11932
I have a fix for this is #13945. If that gets merged, then the workaround won't be necessary. |
thanks a lot for sharing the workaround.
|
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 ! |
@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 |
@schellmax, that's good to know. Thx for trying it out 👍 |
@gkalpak I tried getting the files from that build but it's gone. I get error 404. |
Although `window.history` is present in the context of Chrome Packaged Apps, it is not allowed to access `window.history.pushState` or `window.history.state`, resulting in errors when trying to "sniff" history support. This commit fixes it by detecting a Chrome Packaged App (through the presence of `window.chrome.app.runtime`). Note that `window.chrome.app` is present in the context of "normal" webpages as well, but it doesn't have the `runtime` property, which is only available to packaged apps (e.g. see https://developer.chrome.com/apps/api_index). (It also also contains some style changes for making the structure and layout of `$sniffer` tests more consistent.) Fixes #11932 Closes #13945
It's in master and will be included in the upcoming 1.5.x release. |
Check in $sniffer if operating in a sandboxed Chrome app, which does not have access to chrome.app.runtime like other apps, but also does not have access to history.pushState. If inside a sandboxed Chrome app, do not try and use history.pushState, else an error will occur. See angular#11932 and angular#13945 for previous work.
…aged Apps While sandboxed Chrome Packaged Apps (CPAs) have the same restrictions wrt accessing `history.pushState` as "normal" CPAs, they can't be detected in the same way, as they do not have access to the same APIs. Previously, due to their differences from normal CPAs, `$sniffer` would fail to detect sandboxed CPAs and incorrectly assume `history.pushState` is available (which resulted in an error being thrown). This commit fixes the detection of sandboxed CPAs in `$sniffer`. See #11932 and #13945 for previous work. Closes #15021
…aged Apps While sandboxed Chrome Packaged Apps (CPAs) have the same restrictions wrt accessing `history.pushState` as "normal" CPAs, they can't be detected in the same way, as they do not have access to the same APIs. Previously, due to their differences from normal CPAs, `$sniffer` would fail to detect sandboxed CPAs and incorrectly assume `history.pushState` is available (which resulted in an error being thrown). This commit fixes the detection of sandboxed CPAs in `$sniffer`. See #11932 and #13945 for previous work. Closes #15021
…aged Apps While sandboxed Chrome Packaged Apps (CPAs) have the same restrictions wrt accessing `history.pushState` as "normal" CPAs, they can't be detected in the same way, as they do not have access to the same APIs. Previously, due to their differences from normal CPAs, `$sniffer` would fail to detect sandboxed CPAs and incorrectly assume `history.pushState` is available (which resulted in an error being thrown). This commit fixes the detection of sandboxed CPAs in `$sniffer`. See angular#11932 and angular#13945 for previous work. Closes angular#15021
…aged Apps While sandboxed Chrome Packaged Apps (CPAs) have the same restrictions wrt accessing `history.pushState` as "normal" CPAs, they can't be detected in the same way, as they do not have access to the same APIs. Previously, due to their differences from normal CPAs, `$sniffer` would fail to detect sandboxed CPAs and incorrectly assume `history.pushState` is available (which resulted in an error being thrown). This commit fixes the detection of sandboxed CPAs in `$sniffer`. See angular#11932 and angular#13945 for previous work. Closes angular#15021
I have the same problem in angular 9 |
I get this error message when I run my chrome apps since m43 of chrome. Seems related to this change. https://codereview.chromium.org/988293002
It doesn't have an negative effect on my apps so far, but I only get it when I use angular (3.15) in my chrome apps.
I saw a related closed issue.
#1358
I'm using the angular-csp.css file in my app.
The text was updated successfully, but these errors were encountered: