angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

fix(Angular.js): use cookie instead of window.name to load with debug…

Open klaascuvelier opened this issue 11 years ago • 12 comments

… info

Use cookie to store a check if the application needs to be loaded with debug info, instead of using window.name. As window.name can be used alread (and be overwritten on page load) Fixes issue #13031

klaascuvelier avatar Oct 07 '15 15:10 klaascuvelier

Apparently SauceLabs complains about page reload, which indeed happens. I was not able to spy on window.location.reload which indeed triggers a page reload when calling the reloadWithDebugInfo(). I am not sure how to fix this.

  • Don't test the calling of reloadWithDebugInfo()? (it was not tested before)
  • Stub window somehow? (I've seen some article talking about doing it with sinon)
  • Other options?

klaascuvelier avatar Oct 07 '15 16:10 klaascuvelier

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

googlebot avatar Dec 10 '15 15:12 googlebot

CLAs look good, thanks!

googlebot avatar Dec 10 '15 15:12 googlebot

@juliemr do you remember why we used window.name rather than a cookie?

petebacondarwin avatar Jan 25 '16 18:01 petebacondarwin

If I recall correctly, we can't set a cookie on the site without navigating to a different site on its domain first. So, if we would like to be able to mock out modules before they are ever loaded, we need a different strategy.

juliemr avatar Jan 25 '16 18:01 juliemr

Oh, I missed the updates on this PR, my apologies. Other options would be a query string parameter or localstorage. But those are not optimal either. Can you let me know if you'd want me to do something here, @petebacondarwin @juliemr

klaascuvelier avatar Feb 25 '16 17:02 klaascuvelier

I don't think that localStorage would work either, since it is locked to a domain, right?

petebacondarwin avatar Feb 26 '16 08:02 petebacondarwin

Any other ideas @juliemr ?

petebacondarwin avatar Feb 26 '16 08:02 petebacondarwin

So what's left is a query string parameter, @petebacondarwin? Or would there be any other solutions?

cc @juliemr

klaascuvelier avatar Mar 11 '16 10:03 klaascuvelier

Sorry for the slow response here. I'll think about it more, but when we first designed this it was a toss-up between query string and window.name and we decided that window.name looked cleaner to the user and had less chance of interfering with something custom. Before changing to query params we would have to think carefully about what that could possibly break.

juliemr avatar Mar 18 '16 19:03 juliemr

It might look cleaner, but it can break some functionality (like it did for me). Not sure if having it look cleaner is a real selling point here, it's something that is only visible when a developer reloads the page to do some debugging ...

Anyway looking forward to some possible solution. Happy to contribute if I can.

klaascuvelier avatar Mar 21 '16 09:03 klaascuvelier

@klaascuvelier - of course changing the query string could break apps too. It is a bit of a stone or a hard place. Perhaps the idea solution would be for it to be configurable in the projector config. That way, the default would continue to be changing the window name (no BC) but developers could explicitly choose a query parameter to use instead if they wished?

petebacondarwin avatar Mar 21 '16 10:03 petebacondarwin