fix($browser): handle async href on url change in <=IE9

Closes #9235
This commit is contained in:
Chris Chua
2014-09-23 18:00:37 -07:00
committed by Brian Ford
parent d277641eec
commit 404b95fe30
2 changed files with 28 additions and 1 deletions

View File

@@ -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

View File

@@ -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);
});
});
});
});