Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit c62f204

Browse files
committed
WIP: make mock $browser symmetrical with real $browser
1 parent 5ee60c9 commit c62f204

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/ng/location.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -752,9 +752,8 @@ function $LocationProvider(){
752752
* window events (or polling if events aren't supported), but those methods are
753753
* async. For this reason, $browser.url() will perform a comparison with each call
754754
* to the method as a getter.
755-
* NOTE: Method does not exist on mock $browser
756755
*/
757-
if ($browser.urlChangedOutsideAngular && $browser.urlChangedOutsideAngular()) {
756+
if ($browser.urlChangedOutsideAngular()) {
758757
$location.$$parse(browserUrl);
759758
$browser.urlChangedOutsideAngular(false);
760759
}

src/ngMock/angular-mocks.js

+15
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ angular.mock.$Browser = function() {
3535
self.$$url = "http://server/";
3636
self.$$lastUrl = self.$$url; // used by url polling fn
3737
self.pollFns = [];
38+
self.$$hasChangedOutside = false;
3839

3940
// TODO(vojta): remove this temporary api
4041
self.$$completeOutstandingRequest = angular.noop;
@@ -68,6 +69,16 @@ angular.mock.$Browser = function() {
6869
return self.deferredNextId++;
6970
};
7071

72+
self.urlChangedOutsideAngular = function (hasChanged) {
73+
if (isDefined(hasChanged)) {
74+
self.$$hasChangedOutside = hasChanged;
75+
return self;
76+
}
77+
else {
78+
return self.$$hasChangedOutside;
79+
}
80+
};
81+
7182

7283
/**
7384
* @name $browser#defer.now
@@ -148,6 +159,10 @@ angular.mock.$Browser.prototype = {
148159
return this;
149160
}
150161

162+
if (this.$$mockLocation && this.$$mockLocation.href && url !== (this.$$url = this.$$mockLocation.href.replace(/%27/g,"'"))) {
163+
this.hasChangedOutside = true;
164+
}
165+
151166
return this.$$url;
152167
},
153168

0 commit comments

Comments
 (0)