Set rel="noopener" on gr-linked-text links and similar

Change-Id: Ibabc64b6b26bb9f6221f15eefec1cad14f80cbe0
This commit is contained in:
Wyatt Allen
2017-01-19 18:04:18 -08:00
parent 48d5c9b9aa
commit 3dde35502b
5 changed files with 7 additions and 0 deletions

View File

@@ -152,6 +152,7 @@
'height=' + SIGN_IN_HEIGHT_PX,
'left=' + left,
'top=' + top,
'noopener=yes',
];
window.open('/login/%3FcloseAfterLogin', '_blank', options.join(','));
},

View File

@@ -116,6 +116,8 @@ limitations under the License.
assert.isFalse(windowOpen.called);
toast.fire('action');
assert.isTrue(windowOpen.called);
assert.notEqual(windowOpen.lastCall.args[2].indexOf('noopener=yes'),
-1);
var hideToastSpy = sandbox.spy(toast, 'hide');

View File

@@ -57,6 +57,7 @@
a.href = href;
a.textContent = text;
a.target = '_blank';
a.rel = 'noopener';
output.appendChild(a);
} else if (fragment) {
output.appendChild(fragment);

View File

@@ -74,6 +74,7 @@ limitations under the License.
element.content = url;
var linkEl = element.$.output.childNodes[0];
assert.equal(linkEl.target, '_blank');
assert.equal(linkEl.rel, 'noopener');
assert.equal(linkEl.href, url);
assert.equal(linkEl.textContent, url);
});
@@ -91,6 +92,7 @@ limitations under the License.
element.content = 'Bug 3650';
linkEl = element.$.output.childNodes[0];
assert.equal(linkEl.target, '_blank');
assert.equal(linkEl.rel, 'noopener');
assert.equal(linkEl.href, url);
assert.equal(linkEl.textContent, 'Bug 3650');
});

View File

@@ -69,6 +69,7 @@ GrLinkTextParser.prototype.addItem =
a.href = href;
a.textContent = text;
a.target = '_blank';
a.rel = 'noopener';
htmlOutput = a;
} else if (html) {
var fragment = document.createDocumentFragment();