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

Commit 9a9fce0

Browse files
test($location): ensure that link rewriting is actually being tested
If the link URL is not within the given base URL then the link would not be rewritten anyway. See https://github.com/angular/angular.js/pull/9906/files#r19813651
1 parent 939ca37 commit 9a9fce0

File tree

1 file changed

+38
-4
lines changed

1 file changed

+38
-4
lines changed

test/ng/locationSpec.js

+38-4
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ describe('$location', function() {
12721272

12731273

12741274
it('should not rewrite links with target="_blank"', function() {
1275-
configureService({linkHref: '/a?b=c', html5Mode: true, supportHist: true, attrs: 'target="_blank"'});
1275+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true, attrs: 'target="_blank"'});
12761276
inject(
12771277
initBrowser(),
12781278
initLocation(),
@@ -1285,7 +1285,7 @@ describe('$location', function() {
12851285

12861286

12871287
it('should not rewrite links with target specified', function() {
1288-
configureService({linkHref: '/a?b=c', html5Mode: true, supportHist: true, attrs: 'target="some-frame"'});
1288+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true, attrs: 'target="some-frame"'});
12891289
inject(
12901290
initBrowser(),
12911291
initLocation(),
@@ -1480,7 +1480,7 @@ describe('$location', function() {
14801480
});
14811481

14821482
it('should not rewrite when clicked with ctrl pressed', function() {
1483-
configureService({linkHref: '/a?b=c', html5Mode: true, supportHist: true});
1483+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true});
14841484
inject(
14851485
initBrowser(),
14861486
initLocation(),
@@ -1493,7 +1493,7 @@ describe('$location', function() {
14931493

14941494

14951495
it('should not rewrite when clicked with meta pressed', function() {
1496-
configureService({linkHref: '/a?b=c', html5Mode: true, supportHist: true});
1496+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true});
14971497
inject(
14981498
initBrowser(),
14991499
initLocation(),
@@ -1504,6 +1504,40 @@ describe('$location', function() {
15041504
);
15051505
});
15061506

1507+
it('should not rewrite when right click pressed', function() {
1508+
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true});
1509+
inject(
1510+
initBrowser(),
1511+
initLocation(),
1512+
function($browser) {
1513+
var rightClick;
1514+
if (document.createEvent) {
1515+
rightClick = document.createEvent('MouseEvents');
1516+
rightClick.initMouseEvent('click', true, true, window, 1, 10, 10, 10, 10, false,
1517+
false, false, false, 2, null);
1518+
1519+
link.dispatchEvent(rightClick);
1520+
} else if (document.createEventObject) { // for IE
1521+
rightClick = document.createEventObject();
1522+
rightClick.type = 'click';
1523+
rightClick.cancelBubble = true;
1524+
rightClick.detail = 1;
1525+
rightClick.screenX = 10;
1526+
rightClick.screenY = 10;
1527+
rightClick.clientX = 10;
1528+
rightClick.clientY = 10;
1529+
rightClick.ctrlKey = false;
1530+
rightClick.altKey = false;
1531+
rightClick.shiftKey = false;
1532+
rightClick.metaKey = false;
1533+
rightClick.button = 2;
1534+
link.fireEvent('onclick', rightClick);
1535+
}
1536+
expectNoRewrite($browser);
1537+
}
1538+
);
1539+
});
1540+
15071541

15081542
it('should not rewrite when clicked with shift pressed', function() {
15091543
configureService({linkHref: 'base/a?b=c', html5Mode: true, supportHist: true});

0 commit comments

Comments
 (0)