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

Commit df72852

Browse files
committed
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
1 parent c4f6ccb commit df72852

File tree

3 files changed

+13
-23
lines changed

3 files changed

+13
-23
lines changed

src/ngScenario/Application.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@ angular.scenario.Application.prototype.executeAction = function(action) {
9191
return action.call(this, $window, _jQuery($window.document));
9292
}
9393
angularInit($window.document, function(element) {
94-
element = $window.angular.element(element);
95-
var $injector = element.inheritedData('$injector');
94+
var $injector = $window.angular.element(element).injector();
9695
$injector.invoke(function($browser){
9796
$browser.notifyWhenNoOutstandingRequests(function() {
9897
action.call(self, $window, _jQuery($window.document));

src/ngScenario/dsl.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,25 @@ angular.scenario.dsl('browser', function() {
103103

104104
api.url = function() {
105105
return this.addFutureAction('$location.url()', function($window, $document, done) {
106-
done(null, $window.angular.injector(['ng']).get('$location').url());
106+
done(null, $window.angular.element($window.document).injector().get('$location').url());
107107
});
108108
};
109109

110110
api.path = function() {
111111
return this.addFutureAction('$location.path()', function($window, $document, done) {
112-
done(null, $window.angular.injector(['ng']).get('$location').path());
112+
done(null, $window.angular.element($window.document).injector().get('$location').path());
113113
});
114114
};
115115

116116
api.search = function() {
117117
return this.addFutureAction('$location.search()', function($window, $document, done) {
118-
done(null, $window.angular.injector(['ng']).get('$location').search());
118+
done(null, $window.angular.element($window.document).injector().get('$location').search());
119119
});
120120
};
121121

122122
api.hash = function() {
123123
return this.addFutureAction('$location.hash()', function($window, $document, done) {
124-
done(null, $window.angular.injector(['ng']).get('$location').hash());
124+
done(null, $window.angular.element($window.document).injector().get('$location').hash());
125125
});
126126
};
127127

test/ngScenario/dslSpec.js

+8-17
Original file line numberDiff line numberDiff line change
@@ -168,23 +168,14 @@ describe("angular.scenario.dsl", function() {
168168
});
169169

170170
describe('location', function() {
171-
beforeEach(function() {
172-
$window.angular.injector = function() {
173-
return {
174-
get: function(serviceId) {
175-
if (serviceId == '$location') {
176-
return {
177-
url: function() {return '/path?search=a#hhh';},
178-
path: function() {return '/path';},
179-
search: function() {return {search: 'a'};},
180-
hash: function() {return 'hhh';}
181-
};
182-
}
183-
throw new Error('unknown service id ' + serviceId);
184-
}
185-
};
186-
};
187-
});
171+
beforeEach(inject(function($injector) {
172+
angular.extend($injector.get('$location'), {
173+
url: function() {return '/path?search=a#hhh';},
174+
path: function() {return '/path';},
175+
search: function() {return {search: 'a'};},
176+
hash: function() {return 'hhh';}
177+
});
178+
}));
188179

189180
it('should return full url', function() {
190181
$root.dsl.browser().location().url();

0 commit comments

Comments
 (0)