https://github.com/web-platform-tests/wpt
Raw File
Tip revision: fe38104efc1fefb450302f42f157855f579d174c authored by Lan Wei on 15 December 2018, 01:20:34 UTC
Support multiple mouse pointers inputs
Tip revision: fe38104
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