mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(e2eRunner): $browser.location should delegate to apps $location
previously it would create a new instance which wasn't configured as the one in the app, which resulted in incorrect values being returned in html5 mode with base url set
This commit is contained in:
parent
c4f6ccb065
commit
df72852f34
3 changed files with 13 additions and 23 deletions
|
|
@ -91,8 +91,7 @@ angular.scenario.Application.prototype.executeAction = function(action) {
|
|||
return action.call(this, $window, _jQuery($window.document));
|
||||
}
|
||||
angularInit($window.document, function(element) {
|
||||
element = $window.angular.element(element);
|
||||
var $injector = element.inheritedData('$injector');
|
||||
var $injector = $window.angular.element(element).injector();
|
||||
$injector.invoke(function($browser){
|
||||
$browser.notifyWhenNoOutstandingRequests(function() {
|
||||
action.call(self, $window, _jQuery($window.document));
|
||||
|
|
|
|||
|
|
@ -103,25 +103,25 @@ angular.scenario.dsl('browser', function() {
|
|||
|
||||
api.url = function() {
|
||||
return this.addFutureAction('$location.url()', function($window, $document, done) {
|
||||
done(null, $window.angular.injector(['ng']).get('$location').url());
|
||||
done(null, $window.angular.element($window.document).injector().get('$location').url());
|
||||
});
|
||||
};
|
||||
|
||||
api.path = function() {
|
||||
return this.addFutureAction('$location.path()', function($window, $document, done) {
|
||||
done(null, $window.angular.injector(['ng']).get('$location').path());
|
||||
done(null, $window.angular.element($window.document).injector().get('$location').path());
|
||||
});
|
||||
};
|
||||
|
||||
api.search = function() {
|
||||
return this.addFutureAction('$location.search()', function($window, $document, done) {
|
||||
done(null, $window.angular.injector(['ng']).get('$location').search());
|
||||
done(null, $window.angular.element($window.document).injector().get('$location').search());
|
||||
});
|
||||
};
|
||||
|
||||
api.hash = function() {
|
||||
return this.addFutureAction('$location.hash()', function($window, $document, done) {
|
||||
done(null, $window.angular.injector(['ng']).get('$location').hash());
|
||||
done(null, $window.angular.element($window.document).injector().get('$location').hash());
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -168,23 +168,14 @@ describe("angular.scenario.dsl", function() {
|
|||
});
|
||||
|
||||
describe('location', function() {
|
||||
beforeEach(function() {
|
||||
$window.angular.injector = function() {
|
||||
return {
|
||||
get: function(serviceId) {
|
||||
if (serviceId == '$location') {
|
||||
return {
|
||||
url: function() {return '/path?search=a#hhh';},
|
||||
path: function() {return '/path';},
|
||||
search: function() {return {search: 'a'};},
|
||||
hash: function() {return 'hhh';}
|
||||
};
|
||||
}
|
||||
throw new Error('unknown service id ' + serviceId);
|
||||
}
|
||||
};
|
||||
};
|
||||
});
|
||||
beforeEach(inject(function($injector) {
|
||||
angular.extend($injector.get('$location'), {
|
||||
url: function() {return '/path?search=a#hhh';},
|
||||
path: function() {return '/path';},
|
||||
search: function() {return {search: 'a'};},
|
||||
hash: function() {return 'hhh';}
|
||||
});
|
||||
}));
|
||||
|
||||
it('should return full url', function() {
|
||||
$root.dsl.browser().location().url();
|
||||
|
|
|
|||
Loading…
Reference in a new issue