https://github.com/web-platform-tests/wpt
Raw File
Tip revision: e1321f59e821319d86425ee9027458ff9db35b05 authored by Jaewon Choi on 22 October 2018, 16:31:16 UTC
Add SameObject attribute to navigator xr with wpt
Tip revision: e1321f5
block-string-assignment-to-Element-outerHTML.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>
<div id="container"></div>
<script>
  var container = document.querySelector('#container')

  // TrustedHTML assignments do not throw.
  test(t => {
    let p = createHTML_policy(window, 1);
    let html = p.createHTML(INPUTS.HTML);

    var d = document.createElement('div');
    document.querySelector('#container').appendChild(d);
    d.outerHTML = html;
    assert_equals(container.innerText, RESULTS.HTML);

    while (container.firstChild)
      container.firstChild.remove();
  }, "outerHTML with html assigned via policy (successful HTML transformation).");

  // String assignments throw.
  test(t => {
    var d = document.createElement('div');
    container.appendChild(d);
    assert_throws(new TypeError(), _ => {
      d.outerHTML = "Fail.";
    });
    assert_equals(container.innerText, "");
    while (container.firstChild)
      container.firstChild.remove();
  }, "`outerHTML = string` throws.");

  // Null assignment throws.
  test(t => {
    var d = document.createElement('div');
    container.appendChild(d);
    assert_throws(new TypeError(), _ => {
      d.outerHTML = null;
    });
    assert_equals(container.innerText, "");
    while (container.firstChild)
      container.firstChild.remove();
  }, "`outerHTML = null` throws.");
</script>
</body>
</html>
back to top