chromium/third_party/blink/web_tests/fast/domurl/url-protocol.html

<!DOCTYPE HTML>
<link rel="help" href="http://url.spec.whatwg.org/#dom-url-protocol">
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script>

test(function() {
    var url = new URL('http://www.domain.com');
    assert_equals(url.protocol, 'http:');

    url.protocol = 'https';
    assert_equals(url.protocol, 'https:');

    url.protocol = 'https:';
    assert_equals(url.protocol, 'https:');

    url.protocol = 'invalid/protocol';
    assert_equals(url.protocol, 'https:');
}, 'protocol property');

test(function() {
    var url = new URL('http://www.domain.com');
    var expected = 'http:';
    assert_equals(url.protocol, expected);

    assert_throws_js(TypeError, () => { url.href = 'invalid'; });
    assert_equals(url.protocol, expected);

    url.protocol = 'https';
    assert_equals(url.protocol, 'https:');
    assert_equals(url.href, 'https://www.domain.com/');
}, 'protocol property invalid URL');

</script>