Test DOM isolation for shadow trees

This commit is contained in:
Fernando Jiménez Moreno 2019-01-24 10:48:08 +01:00
parent ffdc9d255f
commit f3e707306f
3 changed files with 50 additions and 0 deletions

View file

@ -13515,6 +13515,12 @@
{}
]
],
"mozilla/partial_shadow_dom.html": [
[
"mozilla/partial_shadow_dom.html",
{}
]
],
"mozilla/postmessage_closed.html": [
[
"mozilla/postmessage_closed.html",
@ -20430,6 +20436,10 @@
"5aff666995fe6cd1d4e84e63a9f6019d04387f8e",
"testharness"
],
"mozilla/partial_shadow_dom.html": [
"d97f1422d20161e989f200d44be6e379f79410bd",
"testharness"
],
"mozilla/poster.png": [
"33834c3ef095fa9c0080017e1b65b2eb8413eac4",
"support"

View file

@ -0,0 +1,2 @@
[partial_shadow_dom.html]
prefs: [dom.shadowdom.enabled:true]

View file

@ -0,0 +1,38 @@
<!doctype html>
<head>
<meta charset="utf-8">
<title></title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1 class="header">Not in the shadows</h1>
<div id="host">
</div>
<script>
test(function() {
// Attach shadow.
var host = document.getElementById('host');
var shadowRoot = host.attachShadow();
assert_not_equals(shadowRoot, null);
assert_equals(shadowRoot.host, host);
assert_equals(shadowRoot.mode, 'closed');
assert_equals(document.body.getElementsByTagName('h1').length, 1);
assert_equals(document.body.getElementsByClassName('header').length, 1);
assert_equals(document.querySelectorAll('h1').length, 1);
assert_equals(document.body.childNodes.length, 6);
// Append child to shadow tree and check that its content is encapsulated.
var shadowChild = document.createElement('h1');
shadowChild.classList.add('header');
shadowChild.textContent = 'In the shadows';
shadowRoot.appendChild(shadowChild);
assert_equals(document.body.getElementsByTagName('h1').length, 1);
assert_equals(document.body.getElementsByClassName('header').length, 1);
assert_equals(document.querySelectorAll('h1').length, 1);
assert_equals(document.body.childNodes.length, 6);
assert_equals(shadowRoot.querySelectorAll('h1').length, 1);
});
</script>
</body>