https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e7517084404fca126c4f89eb69217206689adf17 authored by jgraham on 20 December 2018, 17:24:15 UTC
Update range-percent-intrinsic-size-1.html
Tip revision: e751708
block-string-assignment-to-Location-replace.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="trusted-types *">
</head>
<body>
<script>
  // TrustedURL replacements do not throw.
  test(t => {
    let p = createURL_policy(window, 1);
    let url = p.createURL(location.href + "#xxx");
    location.replace(url);
    assert_equals("" + url, location.href, "location href");
  }, "location.replace via policy (successful URL transformation).");

  // String replacements throw.
  test(t => {
    let href = location.href;
    assert_throws(new TypeError(), _ => {
      location.replace("A string");
    });
    assert_equals(location.href, href);
  }, "`location.replace = string` throws");

  // Null replacement throws.
  test(t => {
    let href = location.href;
    assert_throws(new TypeError(), _ => {
      location.replace(null);
    });
    assert_equals(location.href, href);
  }, "`location.replace = null` throws");

  // Create default policy. Applies to all subsequent tests.
  let p = window.TrustedTypes.createPolicy("default",
      { createURL: createLocationURLJS }, true);

  // After default policy creation string assignment implicitly calls createURL.
  test(t => {
    location.replace("potato");
    assert_true(location.href.endsWith("#potato"));
  }, "`location.replace = string` via default policy (successful URL transformation).");

  // After default policy creation null assignment implicitly calls createURL.
  test(t => {
    location.replace(null);
    assert_true(location.href.endsWith("#null"));
  }, "`location.replace = null` via default policy (successful URL transformation).");
</script>
back to top