@@ -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
@@ -419,7 +419,7 @@ describe('browser', function() {
419
419
420
420
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
421
421
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
422
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
422
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
423
423
} ) ;
424
424
425
425
it ( 'should use history.replaceState when available' , function ( ) {
@@ -431,7 +431,7 @@ describe('browser', function() {
431
431
432
432
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
433
433
expect ( locationReplace ) . not . toHaveBeenCalled ( ) ;
434
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
434
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
435
435
} ) ;
436
436
437
437
it ( 'should set location.href when pushState not available' , function ( ) {
@@ -453,7 +453,7 @@ describe('browser', function() {
453
453
454
454
expect ( pushState ) . not . toHaveBeenCalled ( ) ;
455
455
expect ( replaceState ) . not . toHaveBeenCalled ( ) ;
456
- expect ( fakeWindow . location . href ) . toEqual ( 'http://server' ) ;
456
+ expect ( fakeWindow . location . href ) . toEqual ( 'http://server/ ' ) ;
457
457
} ) ;
458
458
459
459
it ( 'should return $browser to allow chaining' , function ( ) {
@@ -587,6 +587,7 @@ describe('browser', function() {
587
587
fakeWindow . fire ( 'hashchange' ) ;
588
588
expect ( callback ) . not . toHaveBeenCalled ( ) ;
589
589
} ) ;
590
+
590
591
} ) ;
591
592
592
593
@@ -620,4 +621,32 @@ describe('browser', function() {
620
621
expect ( browser . baseHref ( ) ) . toEqual ( '/base/path/' ) ;
621
622
} ) ;
622
623
} ) ;
624
+
625
+ describe ( 'integration tests with $location' , function ( ) {
626
+
627
+ beforeEach ( module ( function ( $provide , $locationProvider ) {
628
+ spyOn ( fakeWindow . history , 'pushState' ) . andCallFake ( function ( stateObj , title , newUrl ) {
629
+ fakeWindow . location . href = newUrl ;
630
+ } )
631
+ $provide . value ( '$browser' , browser ) ;
632
+ browser . pollFns = [ ] ;
633
+
634
+ $locationProvider . html5Mode ( true ) ;
635
+ } ) ) ;
636
+
637
+ it ( 'should update $location when it was changed outside of Angular in sync ' +
638
+ 'before $digest was called' , function ( ) {
639
+ inject ( function ( $rootScope , $location ) {
640
+ fakeWindow . history . pushState ( null , '' , 'http://server/someTestHash' ) ;
641
+
642
+ // Verify that infinite digest reported in #6976 no longer occurs
643
+ expect ( function ( ) {
644
+ $rootScope . $digest ( ) ;
645
+ } ) . not . toThrow ( ) ;
646
+
647
+ expect ( $location . path ( ) ) . toBe ( '/someTestHash' ) ;
648
+ } ) ;
649
+ } ) ;
650
+ } ) ;
651
+
623
652
} ) ;
0 commit comments