blob: f43ec406e4b572e0abcca74284716e2cadcc0bd3 [file] [log] [blame]
Denis Ah-Kang1ddb3ba2014-01-27 09:43:181<!doctype html>
2<title>insertAdjacentHTML</title>
3<script src="/resources/testharness.js"></script>
4<script src="/resources/testharnessreport.js"></script>
5<style>
6#element {
7 display: none;
8}
9</style>
10
11<div id="element"></div>
12<div id="log"></div>
13
14<script>
15function wrap(text) {
16 return '<h3>' + text + '</h3>';
17}
18
19var possiblePositions = {
20 'beforebegin': 'previousSibling'
21 , 'afterbegin': 'firstChild'
22 , 'beforeend': 'lastChild'
23 , 'afterend': 'nextSibling'
24}
25
26var el = document.querySelector('#element');
27
28Object.keys(possiblePositions).forEach(function(position) {
29 var html = wrap(position);
30 test(function() {
31 el.insertAdjacentHTML(position, html);
32 var heading = document.createElement('h3');
33 heading.innerHTML = position;
34 assert_equals(el[possiblePositions[position]].nodeName, "H3");
35 assert_equals(el[possiblePositions[position]].firstChild.nodeType, Node.TEXT_NODE);
36 }, 'insertAdjacentHTML(' + position + ', ' + html + ' )');
37});
38</script>