diff options
| author | Misko Hevery | 2012-06-13 15:37:52 -0700 |
|---|---|---|
| committer | Igor Minar | 2012-06-14 10:48:56 -0700 |
| commit | 6593a3e0823f3c08079f05010f9628fc4503cd43 (patch) | |
| tree | 9d8cd01b9c469e18d2b1d694cbc09eb80b1b7b22 /test/ng/locationSpec.js | |
| parent | 0f44964e5e0f7e37d7fa3216bb10fd61fbf52ae2 (diff) | |
| download | angular.js-6593a3e0823f3c08079f05010f9628fc4503cd43.tar.bz2 | |
fix($location): fix URL interception in hash-bang mode
Closes #1051
Diffstat (limited to 'test/ng/locationSpec.js')
| -rw-r--r-- | test/ng/locationSpec.js | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/test/ng/locationSpec.js b/test/ng/locationSpec.js index 91f3688c..88747dff 100644 --- a/test/ng/locationSpec.js +++ b/test/ng/locationSpec.js @@ -1029,6 +1029,64 @@ describe('$location', function() { expect($browser.url()).toEqual(base + '#!/view2'); }); }); + + + it('should not intercept link clicks outside the app base url space', function() { + var base, clickHandler; + module(function($provide) { + $provide.value('$rootElement', { + bind: function(event, handler) { + expect(event).toEqual('click'); + clickHandler = handler; + } + }); + return function($browser) { + $browser.url(base = 'http://server/'); + } + }); + inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) { + // make IE happy + jqLite(window.document.body).html('<a href="http://server/test.html">link</a>'); + + var event = { + target: jqLite(window.document.body).find('a')[0], + preventDefault: jasmine.createSpy('preventDefault') + }; + + + clickHandler(event); + expect(event.preventDefault).not.toHaveBeenCalled(); + }); + }); + + + it('should not intercept hash link clicks outside the app base url space', function() { + var base, clickHandler; + module(function($provide) { + $provide.value('$rootElement', { + bind: function(event, handler) { + expect(event).toEqual('click'); + clickHandler = handler; + } + }); + return function($browser) { + $browser.url(base = 'http://server/'); + } + }); + inject(function($rootScope, $compile, $browser, $rootElement, $document, $location) { + // make IE happy + jqLite(window.document.body).html('<a href="http://server/index.html#test">link</a>'); + + var event = { + target: jqLite(window.document.body).find('a')[0], + preventDefault: jasmine.createSpy('preventDefault') + }; + + + clickHandler(event); + expect(event.preventDefault).not.toHaveBeenCalled(); + }); + }); }); @@ -1111,7 +1169,7 @@ describe('$location', function() { ); - it('should listen on click events on href and prevent browser default in hasbang mode', function() { + it('should listen on click events on href and prevent browser default in hashbang mode', function() { module(function() { return function($rootElement, $compile, $rootScope) { $rootElement.html('<a href="http://server/#/somePath">link</a>'); @@ -1162,7 +1220,7 @@ describe('$location', function() { log += '$locationChangeStart'; }); $rootScope.$on('$locationChangeSuccess', function() { - throw new Error('after cancalation in html5 mode'); + throw new Error('after cancelation in html5 mode'); }); browserTrigger(link, 'click'); |
