<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../../resources/js-test-pre.js"></script>
</head>
<body>
<script>

description('Test getting the username attribute of a URL object.');

var a = new URL("about:blank");

debug("Default username is empty");
shouldBe("a.username", "''");

debug("Unspecified username should return empty string");
a.href = "http://example.com/";
shouldBe("a.username", "''");

debug("Empty username should be empty");
a.href = "http://@example.com/";
shouldBe("a.username", "''");

debug("Regular username retrieval");
a.href = "http://joebob1@example.com/";
shouldBe("a.username", "'joebob1'");

debug("Username with empty password");
a.href = "http://joebob2:@example.com/";
shouldBe("a.username", "'joebob2'");

debug("Username with non-empty password");
a.href = "http://joebob3:abc123@example.com/";
shouldBe("a.username", "'joebob3'");

debug("Setting username");
a.href = "http://example.com/";
a.username = "joebob4";
shouldBe("a.href", "'http://joebob4@example.com/'");

</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
