@@ -36,7 +36,7 @@ function MockWindow() {
3636 } ;
3737
3838 this . location = {
39- href : 'http://server' ,
39+ href : 'http://server/ ' ,
4040 replace : noop
4141 } ;
4242
@@ -419,7 +419,7 @@ describe('browser', function() {
419419
420420 expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
421421 expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
422- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
422+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
423423 } ) ;
424424
425425 it ( 'should use history.replaceState when available' , function ( ) {
@@ -431,7 +431,7 @@ describe('browser', function() {
431431
432432 expect ( pushState ) . not . toHaveBeenCalled ( ) ;
433433 expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
434- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
434+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
435435 } ) ;
436436
437437 it ( 'should set location.href when pushState not available' , function ( ) {
@@ -453,7 +453,7 @@ describe('browser', function() {
453453
454454 expect ( pushState ) . not . toHaveBeenCalled ( ) ;
455455 expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
456- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
456+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
457457 } ) ;
458458
459459 it ( 'should return $browser to allow chaining' , function ( ) {
@@ -620,4 +620,32 @@ describe('browser', function() {
620620 expect ( browser . baseHref ( ) ) . toEqual ( '/base/path/' ) ;
621621 } ) ;
622622 } ) ;
623+
624+ describe ( 'integration tests with $location' , function ( ) {
625+
626+ beforeEach ( module ( function ( $provide , $locationProvider ) {
627+ spyOn ( fakeWindow . history , 'pushState' ) . andCallFake ( function ( stateObj , title , newUrl ) {
628+ fakeWindow . location . href = newUrl ;
629+ } ) ;
630+ $provide . value ( '$browser' , browser ) ;
631+ browser . pollFns = [ ] ;
632+
633+ $locationProvider . html5Mode ( true ) ;
634+ } ) ) ;
635+
636+ it ( 'should update $location when it was changed outside of Angular in sync ' +
637+ 'before $digest was called' , function ( ) {
638+ inject ( function ( $rootScope , $location ) {
639+ fakeWindow . history . pushState ( null , '' , 'http://server/someTestHash' ) ;
640+
641+ // Verify that infinite digest reported in #6976 no longer occurs
642+ expect ( function ( ) {
643+ $rootScope . $digest ( ) ;
644+ } ) . not . toThrow ( ) ;
645+
646+ expect ( $location . path ( ) ) . toBe ( '/someTestHash' ) ;
647+ } ) ;
648+ } ) ;
649+ } ) ;
650+
623651} ) ;
0 commit comments