@@ -36,7 +36,7 @@ function MockWindow() {
3636 } ;
3737
3838 this . location = {
39- href : 'http://server' ,
39+ href : 'http://server/ ' ,
4040 replace : noop
4141 } ;
4242
@@ -414,7 +414,7 @@ describe('browser', function() {
414414
415415 expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
416416 expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
417- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
417+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
418418 } ) ;
419419
420420 it ( 'should use history.replaceState when available' , function ( ) {
@@ -426,7 +426,7 @@ describe('browser', function() {
426426
427427 expect ( pushState ) . not . toHaveBeenCalled ( ) ;
428428 expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
429- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
429+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
430430 } ) ;
431431
432432 it ( 'should set location.href when pushState not available' , function ( ) {
@@ -448,7 +448,7 @@ describe('browser', function() {
448448
449449 expect ( pushState ) . not . toHaveBeenCalled ( ) ;
450450 expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
451- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
451+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
452452 } ) ;
453453
454454 it ( 'should return $browser to allow chaining' , function ( ) {
@@ -615,4 +615,32 @@ describe('browser', function() {
615615 expect ( browser . baseHref ( ) ) . toEqual ( '/base/path/' ) ;
616616 } ) ;
617617 } ) ;
618+
619+ describe ( 'integration tests with $location' , function ( ) {
620+
621+ beforeEach ( module ( function ( $provide , $locationProvider ) {
622+ spyOn ( fakeWindow . history , 'pushState' ) . andCallFake ( function ( stateObj , title , newUrl ) {
623+ fakeWindow . location . href = newUrl ;
624+ } ) ;
625+ $provide . value ( '$browser' , browser ) ;
626+ browser . pollFns = [ ] ;
627+
628+ $locationProvider . html5Mode ( true ) ;
629+ } ) ) ;
630+
631+ it ( 'should update $location when it was changed outside of Angular in sync ' +
632+ 'before $digest was called' , function ( ) {
633+ inject ( function ( $rootScope , $location ) {
634+ fakeWindow . history . pushState ( null , '' , 'http://server/someTestHash' ) ;
635+
636+ // Verify that infinite digest reported in #6976 no longer occurs
637+ expect ( function ( ) {
638+ $rootScope . $digest ( ) ;
639+ } ) . not . toThrow ( ) ;
640+
641+ expect ( $location . path ( ) ) . toBe ( '/someTestHash' ) ;
642+ } ) ;
643+ } ) ;
644+ } ) ;
645+
618646} ) ;
0 commit comments