https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 8409a38ef8d57d6fdad447adef206f17d1ecf9fb authored by James Graham on 14 August 2018, 18:17:53 UTC
WIP
Tip revision: 8409a38
block-string-assignment-to-location-assign.tentative.html
<!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>
  //TrustedURL assignments work
  test(t => {
    var url = TrustedURL.create(location.href + "#xxx");
    location.assign(url);
    assert_equals("" + url, location.href, "location href");
  }, "Basic processing: safe URL, safe construction.");

  test(t => {
    var url = TrustedURL.unsafelyCreate(location.href + "#xxx");
    location.assign(url);
    assert_equals("" + url, location.href, "location href");
  }, "Basic processing: safe URL, unsafe construction.");

  // String assignments throw.
  test(t => {
    assert_throws(new TypeError(), _ => {
      location.assign("A string");
    });
  }, "`location.assign = string` throws");

  //Null assignment throws
  test(t => {
    assert_throws(new TypeError(), _ => {
      location.assign(null);
    });
  }, "`location.assign = null` throws");
</script>
back to top