https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 7b34dc7dc9f2ff8fbcf3445709fa7e517f2c6fb4 authored by Domenic Denicola on 06 April 2018, 22:15:02 UTC
WIP tests for text/css link quirk
Tip revision: 7b34dc7
insertAdjacentHTML.tentative.html
<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="./support/helper.js"></script>
<body>
<div id="container"></div>
<script>
  var container = document.querySelector('#container');

  test(t => {
    var html = TrustedHTML.escape(STRINGS.unescapedHTML);

    var d = document.createElement('div');
    container.appendChild(d);

    d.insertAdjacentHTML('beforebegin', html);
    assert_equals(d.previousSibling.nodeType, Node.TEXT_NODE);
    assert_equals(d.previousSibling.data, STRINGS.unescapedHTML);

    d.insertAdjacentHTML('afterbegin', html);
    assert_equals(d.firstChild.nodeType, Node.TEXT_NODE);
    assert_equals(d.firstChild.data, STRINGS.unescapedHTML);

    d.insertAdjacentHTML('beforeend', html);
    assert_equals(d.lastChild.nodeType, Node.TEXT_NODE);
    assert_equals(d.lastChild.data, STRINGS.unescapedHTML);

    d.insertAdjacentHTML('afterend', html);
    assert_equals(d.nextSibling.nodeType, Node.TEXT_NODE);
    assert_equals(d.nextSibling.data, STRINGS.unescapedHTML);

    while (container.firstChild)
      container.firstChild.remove();
  }, "insertAdjacentHTML = TrustedHTML.escape().");

  test(t => {
    var html = TrustedHTML.unsafelyCreate(STRINGS.unescapedHTML);

    var d = document.createElement('div');
    container.appendChild(d);

    d.insertAdjacentHTML('beforebegin', html);
    assert_equals(d.previousSibling.nodeType, Node.TEXT_NODE);
    assert_equals(d.previousSibling.data, STRINGS.unescapedText);

    d.insertAdjacentHTML('afterbegin', html);
    assert_equals(d.firstChild.nodeType, Node.TEXT_NODE);
    assert_equals(d.firstChild.data, STRINGS.unescapedText);

    d.insertAdjacentHTML('beforeend', html);
    assert_equals(d.lastChild.nodeType, Node.TEXT_NODE);
    assert_equals(d.lastChild.data, STRINGS.unescapedText);

    d.insertAdjacentHTML('afterend', html);
    assert_equals(d.nextSibling.nodeType, Node.TEXT_NODE);
    assert_equals(d.nextSibling.data, STRINGS.unescapedText);

    while (container.firstChild)
      container.firstChild.remove();
  }, "insertAdjacentHTML = TrustedHTML.unsafelyCreate().");
</script>
back to top