diff options
| author | Sebastian K | 2013-11-22 14:33:19 +0100 |
|---|---|---|
| committer | Igor Minar | 2014-01-02 21:30:25 -0800 |
| commit | cf686285c22d528440e173fdb65ad1052d96df3c (patch) | |
| tree | 41d34fe7644ee82d80399101696f4b996ec8ebf1 /test | |
| parent | 7dfedb732dad5ba1f1f21ff611a82ecf8327916c (diff) | |
| download | angular.js-cf686285c22d528440e173fdb65ad1052d96df3c.tar.bz2 | |
fix($location): $location.path() behaviour when $locationChangeStart is triggered by the browser
Fixed inconsistency in $location.path() behaviour on the $locationChangeStart event when using
back/forward buttons in the browser or manually changing the url in the address bar.
$location.path() now returns the target url in these cases.
Closes #4989
Closes #5089
Closes #5118
Closes #5580
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/locationSpec.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index f23965f8..ff823d30 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -4,6 +4,8 @@ describe('$location', function() { var url; + beforeEach(module(provideLog)); + afterEach(function() { // link rewriting used in html5 mode on legacy browsers binds to document.onClick, so we need // to clean this up after each test. @@ -1401,6 +1403,32 @@ describe('$location', function() { dealoc($rootElement); }); }); + + it('should always return the new url value via path() when $locationChangeStart event occurs regardless of cause', + inject(function($location, $rootScope, $browser, log) { + var base = $browser.url(); + + $rootScope.$on('$locationChangeStart', function() { + log($location.path()); + }); + + // change through $location service + $rootScope.$apply(function() { + $location.path('/myNewPath'); + }); + + // reset location + $rootScope.$apply(function() { + $location.path(''); + }); + + // change through $browser + $browser.url(base + '#/myNewPath'); + $browser.poll(); + + expect(log).toEqual(['/myNewPath', '/', '/myNewPath']); + }) + ); }); describe('LocationHtml5Url', function() { |
