Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($snifferProvider): allow history for nwjs applications #15633

Closed
wants to merge 4 commits into from
Closed

fix($snifferProvider): allow history for nwjs applications #15633

wants to merge 4 commits into from

Conversation

frederikprijck
Copy link
Contributor

@frederikprijck frederikprijck commented Jan 20, 2017

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix

What is the current behavior? (You can also link to an open issue here)
sniffer incorrectly detects NW.js applications as chromePackagedApp disallowing them to make use of the history API.

What is the new behavior (if this is a feature change)?
Correctly detecting NW.js applications allowing them to make use of the History API.

Does this PR introduce a breaking change?
No

Please check if the PR fulfills these requirements

Other information:
#15474

@@ -29,7 +29,8 @@ function $SnifferProvider() {
$window.chrome &&
($window.chrome.app && $window.chrome.app.runtime ||
!$window.chrome.app && $window.chrome.runtime && $window.chrome.runtime.id),
hasHistoryPushState = !isChromePackagedApp && $window.history && $window.history.pushState,
isNw = $window.nw && $window.nw.process,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since isNw is actually part of detecting if it isChromePackagedApp, it is clearer to incorporate it in there:

isNw = ...;
isChromePackagedApp = !isNw && ...;

@@ -25,6 +25,25 @@ describe('$sniffer', function() {
});


it('should be true if running inside nw.js', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this test below should be false on Chrome Packaged Apps (or even incorporate it into that one).

Copy link
Contributor Author

@frederikprijck frederikprijck Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it there to make sure both tests verifying when history should be true are together. But I can move it a bit lower. However, I wouldn't incorporate it into the same test that verifies history being false.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://github.com/angular/angular.js/pull/15633/files#r97973838, isNw is just a subcase of detecting whether something is a Chrome Packaged App. In that sense, it makes sense to have it incorporated into the Chrome Packaged App test.

In other words, we are not doing anything special if it is NW. We have just refined our Chrome Packaged App-detection check.

Copy link
Contributor Author

@frederikprijck frederikprijck Jan 26, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the intend of this PR was to allow history in NW apps, I'd say it's a good idea to have a test that reflects that change and test it (despite the actual technical implementation).

Incorporate this into the test for Chromed Packaged App sounds odd to me, as NW apps are not actual Chromed Packaged Apps (correct me if I'm wrong here).

Apart from that, I'll be happy to change the test and try to incorporate it into the one you're talking about.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was just a suggestion - what makes more sense to me. But I don't feel too strongly about it, so feel free to do it the way it makes more sense to you.

As the intend of this PR was to allow history in NW apps

I see it more like restoring the previous behavior of not blocking history on NW apps, which was incorrectly changed while trying to disable it for Chrome PAckaged Apps.

But like I said, totally up to you. As long as the test is there (and is testing the correct thing), it doesn't have t be incorporated into the other one.

@gkalpak
Copy link
Member

gkalpak commented Jan 26, 2017

BTW, can you change the commit message to not have : after Fixes/Closes. I.e. Fixes: 12345 --> Fixes 12345. (The : prevents proper detection of the Fixes/Closes.)

Previously`sniffer` incorrectly detected NW.js applications as `chromePackagedApp` disallowing them to make use of the history API.

This commit does detect NW.js applications allowing them to make use of the History API.

Fixes #15474
@frederikprijck
Copy link
Contributor Author

frederikprijck commented Jan 26, 2017

I've changed the commit message. I wasn't aware of the issue with using :. Thanks for pointing it out.

@gkalpak gkalpak closed this in 7019d9f Jan 26, 2017
gkalpak pushed a commit that referenced this pull request Jan 26, 2017
Previously `$sniffer` incorrectly detected NW.js apps as Chrome Packaged Apps,
disallowing them to use the history API.

This commit correctly detects NW.js apps and allows them to use the History API.

Fixes #15474

Closes #15633
@frederikprijck frederikprijck deleted the fix/15474 branch January 27, 2017 21:23
ellimist pushed a commit to ellimist/angular.js that referenced this pull request Mar 15, 2017
Previously `$sniffer` incorrectly detected NW.js apps as Chrome Packaged Apps,
disallowing them to use the history API.

This commit correctly detects NW.js apps and allows them to use the History API.

Fixes angular#15474

Closes angular#15633
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants