Commit 15b8ee56 authored by Maja Kabus's avatar Maja Kabus Committed by Commit Bot

HTMLLinkElement::href modified to accept TrustedTypes

Existing implementation of setHref() changed,
older version is abandoned.
Added new function href() to accept URLString
as an argument.

Bug: 739170
Change-Id: Id57e361574c50b13df1876fe83e8693429b66fc8
Reviewed-on: https://chromium-review.googlesource.com/1136635
Commit-Queue: Maja Kabus <kabusm@google.com>
Reviewed-by: default avatarMike West <mkwst@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576466}
parent 61c03048
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<body>
<script>
//helper function for the tests
function testHref(str, url) {
var link = document.createElement('link');
link.href = url;
assert_equals(link.href, str);
}
test(t => {
testHref(URLS.safe, TrustedURL.create(URLS.safe));
}, "link.href = URLS.safe, TrustedURL.create");
test(t => {
testHref(URLS.safe, TrustedURL.unsafelyCreate(URLS.safe));
}, "link.href = URLS.safe, TrustedURL.unsafelyCreate");
</script>
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="support/helper.sub.js"></script>
<meta http-equiv="Content-Security-Policy" content="require-trusted-types">
</head>
<body>
<script>
//helper function for the tests
function testHref(str, url) {
var link = document.createElement('link');
link.href = url;
assert_equals(link.href, str);
}
//URL assignments do not throw.
test(t => {
testHref(URLS.safe, TrustedURL.create(URLS.safe));
}, "link.href = URLS.safe, TrustedURL.create");
test(t => {
testHref(URLS.safe, TrustedURL.unsafelyCreate(URLS.safe));
}, "link.href = URLS.safe, TrustedURL.unsafelyCreate");
// String assignments throw.
test(t => {
var link = document.createElement('link');
assert_throws(new TypeError(), _ => {
link.href = "A string";
});
}, "`link.href = string` throws");
//Null assignment throws.
test(t => {
var link = document.createElement('link');
assert_throws(new TypeError(), _ => {
link.href = null;
});
}, "`link.href = null` throws");
</script>
......@@ -25,7 +25,7 @@ interface HTMLLinkElement : HTMLElement {
// FIXME: The disabled attribute has been removed from the spec:
// https://www.w3.org/Bugs/Public/show_bug.cgi?id=14703
[Reflect, Measure] attribute boolean disabled;
[Reflect, URL] attribute USVString href;
[Reflect, URL, RaisesException=Setter] attribute URLString href;
[CEReactions, Reflect, ReflectOnly=("anonymous","use-credentials"), ReflectEmpty="anonymous", ReflectInvalid="anonymous"] attribute DOMString? crossOrigin;
[CEReactions, Reflect] attribute DOMString rel;
[SameObject, PutForwards=value] readonly attribute DOMTokenList relList;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment