https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 66f1ce9def6c201aaebed7feefe12c7a68513a53 authored by Nicolas Pena on 12 December 2018, 18:54:14 UTC
[EventTiming] Ship First Input Timing
Tip revision: 66f1ce9
block-string-assignment-to-Document-write.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 assignments do not throw.
  test(t => {
    document.body.innerText = '';
    let p = createHTML_policy(window, 1);
    let html = p.createHTML(INPUTS.HTML);
    document.write(html);
    assert_equals(document.body.innerText, RESULTS.HTML);
  }, "document.write with html assigned via policy (successful URL transformation).");

  // String assignments throw.
  test(t => {
    const old = document.body.innerText;
    assert_throws(new TypeError(), _ => {
      document.write('A string');
    });
    assert_equals(document.body.innerText, old);
  }, "`document.write(string)` throws");

  // Null assignment throws.
  test(t => {
    const old = document.body.innerText;
    assert_throws(new TypeError(), _ => {
      document.write(null);
    });
    assert_equals(document.body.innerText, old);
  }, "`document.write(null)` throws");
</script>
back to top