summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/html_content_in_foreign_context.html
blob: 7efafb4fceb44f1564dbb47522a01447459ac2db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<!DOCTYPE html>
<title>Foreign contexts with HTML tag children</title>
<link rel="author" href="mailto:masonf@chromium.org">
<link rel="help" href="https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inbody">
<link rel="help" href="https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inforeign">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<script>
test(function() {
  const contexts = ["svg", "math"];
  const elements = ["/p", "/br", "b", "big", "blockquote", "br", "center", "code", "dd", "div", "dl", "dt", "em", "embed", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i", "img", "li", "listing", "menu", "meta", "nobr", "ol", "p", "pre", "ruby", "s", "small", "span", "strong", "strike", "sub", "sup", "table", "tt", "u", "ul", "var"];
  contexts.forEach(c => {
  	elements.forEach(e => {
  	  const wrapper = document.createElement('div');
  	  const html = `<${c}><${e}></${c}`
  	  wrapper.innerHTML = html;
  	  assert_not_equals(wrapper.innerHTML, html, "The inner HTML should get mutated");

  	  const tagname = e[0]=='/' ? e.substr(1) : e;
  	  const element = wrapper.getElementsByTagName(tagname)[0];
  	  assert_not_equals(element, undefined,`Unable to locate the ${e} node in ${c}`)
  	  const parent = element.parentNode
  	  assert_equals(element.parentNode, wrapper,`The ${e} tag did not exit the ${c}`)
  	});
  });
}, "HTML namespace nodes should exit foreign contexts");

</script>