mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-24 03:55:49 +08:00
@@ -184,6 +184,10 @@ function Browser(window, document, $log, $sniffer) {
|
|||||||
|
|
||||||
function fireUrlChange() {
|
function fireUrlChange() {
|
||||||
newLocation = null;
|
newLocation = null;
|
||||||
|
checkUrlChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkUrlChange() {
|
||||||
if (lastBrowserUrl == self.url()) return;
|
if (lastBrowserUrl == self.url()) return;
|
||||||
|
|
||||||
lastBrowserUrl = self.url();
|
lastBrowserUrl = self.url();
|
||||||
@@ -239,7 +243,7 @@ function Browser(window, document, $log, $sniffer) {
|
|||||||
* Needs to be exported to be able to check for changes that have been done in sync,
|
* Needs to be exported to be able to check for changes that have been done in sync,
|
||||||
* as hashchange/popstate events fire in async.
|
* as hashchange/popstate events fire in async.
|
||||||
*/
|
*/
|
||||||
self.$$checkUrlChange = fireUrlChange;
|
self.$$checkUrlChange = checkUrlChange;
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////
|
||||||
// Misc API
|
// Misc API
|
||||||
|
|||||||
@@ -641,6 +641,29 @@ describe('browser', function() {
|
|||||||
expect($location.path()).toBe('/someTestHash');
|
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