Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/semantics/links/links-created-by-a-and-area-elements/html-hyperlink-element-utils-href.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<title>HTMLHyperlinkElementUtils href setter</title>
<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
const a = document.createElement("a");
a.setAttribute("href", "mycustomprotocol:abc");
assert_equals(a.protocol, "mycustomprotocol:");
a.href = "otherprot:test.js";
assert_equals(a.protocol, "otherprot:");
}, "setting href IDL attribute also resets protocol on URLs with non-relative flag set");
test(() => {
const a = document.createElement("a");
a.setAttribute("href", "mycustomprotocol:abc");
assert_equals(a.protocol, "mycustomprotocol:");
a.setAttribute("href", "otherprot:test.js");
assert_equals(a.protocol, "otherprot:");
}, "setting href content attribute also resets protocol on URLs with non-relative flag set");
</script>