@@ -36,7 +36,7 @@ function MockWindow() {
36
36
} ;
37
37
38
38
this . location = {
39
- href : 'http://server' ,
39
+ href : 'http://server/ ' ,
40
40
replace : noop
41
41
} ;
42
42
@@ -414,7 +414,7 @@ describe('browser', function() {
414
414
415
415
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
416
416
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
417
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
417
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
418
418
} ) ;
419
419
420
420
it ( 'should use history.replaceState when available' , function ( ) {
@@ -426,7 +426,7 @@ describe('browser', function() {
426
426
427
427
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
428
428
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
429
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
429
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
430
430
} ) ;
431
431
432
432
it ( 'should set location.href when pushState not available' , function ( ) {
@@ -448,7 +448,7 @@ describe('browser', function() {
448
448
449
449
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
450
450
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
451
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
451
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
452
452
} ) ;
453
453
454
454
it ( 'should return $browser to allow chaining' , function ( ) {
@@ -615,4 +615,32 @@ describe('browser', function() {
615
615
expect ( browser . baseHref ( ) ) . toEqual ( '/base/path/' ) ;
616
616
} ) ;
617
617
} ) ;
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
+
618
646
} ) ;
0 commit comments