mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-01-12 22:45:52 +08:00
@@ -182,6 +182,10 @@ function Browser(window, document, $log, $sniffer) {
|
||||
|
||||
function fireUrlChange() {
|
||||
newLocation = null;
|
||||
checkUrlChange();
|
||||
}
|
||||
|
||||
function checkUrlChange() {
|
||||
if (lastBrowserUrl == self.url()) return;
|
||||
|
||||
lastBrowserUrl = self.url();
|
||||
@@ -237,7 +241,7 @@ function Browser(window, document, $log, $sniffer) {
|
||||
* Needs to be exported to be able to check for changes that have been done in sync,
|
||||
* as hashchange/popstate events fire in async.
|
||||
*/
|
||||
self.$$checkUrlChange = fireUrlChange;
|
||||
self.$$checkUrlChange = checkUrlChange;
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Misc API
|
||||
|
||||
@@ -646,6 +646,29 @@ describe('browser', function() {
|
||||
expect($location.path()).toBe('/someTestHash');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('integration test with $rootScope', function() {
|
||||
|
||||
beforeEach(module(function($provide, $locationProvider) {
|
||||
$provide.value('$browser', browser);
|
||||
browser.pollFns = [];
|
||||
}));
|
||||
|
||||
it('should not interfere with legacy browser url replace behavior', function() {
|
||||
inject(function($rootScope) {
|
||||
var current = fakeWindow.location.href;
|
||||
var newUrl = 'notyet';
|
||||
sniffer.history = false;
|
||||
browser.url(newUrl, true);
|
||||
expect(browser.url()).toBe(newUrl);
|
||||
$rootScope.$digest();
|
||||
expect(browser.url()).toBe(newUrl);
|
||||
expect(fakeWindow.location.href).toBe(current);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user