Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
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

Closed

Description

@rpgobjects

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.

Activity

  1. jdiamond commented on May 24, 2015

    @jdiamond

    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;
            });
        })
    ;
    
  2. caitp commented on May 24, 2015

    @caitp
    Contributor

    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

  3. added this to the Purgatory milestone on Jun 11, 2015
  4. raghavcreddy commented on Feb 2, 2016

    @raghavcreddy

    The decorator is not working anymore starting from Chrome 48.0.2564.97 (64-bit).

    Is there any workaround?

  5. gkalpak commented on Feb 2, 2016

    @gkalpak
    Member

    It is strange, because this workaround shouldn't be affected by browser behavior.
    Do you have a (preferrably minimal) working demo of the issue ?

  6. raghavcreddy commented on Feb 3, 2016

    @raghavcreddy
  7. gkalpak commented on Feb 3, 2016

    @gkalpak
    Member

    Thx @raghavcreddy. I'll take a look.

  8. gkalpak commented on Feb 3, 2016

    @gkalpak
    Member

    @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;
    });
  9. raghavcreddy commented on Feb 4, 2016

    @raghavcreddy

    Thank you @gkalpak

  10. added a commit that references this issue on Feb 4, 2016
    87ace90
  11. gkalpak commented on Feb 4, 2016

    @gkalpak
    Member

    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.

  12. schellmax commented on Feb 4, 2016

    @schellmax

    thanks a lot for sharing the workaround.
    for those not familiar with ES6 yet (like me), here's the 'back-ported' version ;)

        .decorator('$window', function($delegate) {
            Object.defineProperty($delegate, 'history', {get: function(){ return null; }});
            return $delegate;
        })
    
  13. gkalpak commented on Feb 4, 2016

    @gkalpak
    Member

    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.)

  14. schellmax commented on Feb 6, 2016

    @schellmax

    @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

  15. gkalpak commented on Feb 6, 2016

    @gkalpak
    Member

    @schellmax, that's good to know. Thx for trying it out 👍
    All we need now is to get #13945 merged :)

  16. proofofvirtue commented on Mar 21, 2016

    @proofofvirtue

    @gkalpak I tried getting the files from that build but it's gone. I get error 404.

  17. gkalpak commented on Mar 21, 2016

    @gkalpak
    Member

    @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 😛)

  18. added a commit that references this issue on Mar 22, 2016
    457fd21
  19. gkalpak commented on Mar 22, 2016

    @gkalpak
    Member

    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/.

  20. husin-sajjadi commented on Oct 18, 2020

    @husin-sajjadi

    I have the same problem in angular 9
    How to fix that in angular 2+?
    Thank you

  21. added a commit that references this issue on Sep 28, 2024
    9f5526f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions