Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested shadow dom test #143

Closed
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<title>ShadowRoot Object: Apply author style</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="ShadowRoot Object: attribute bool applyAuthorStyles attribute. If true, the author styles are applied">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../../testcommon.js"></script>
</head>
<body>
<h1>ShadowRoot Object: Apply author style</h1>

<style>
#shadow {
display: none;
}
</style>
<div id="wrap"></div>
<template id="shadow-template">
<style>
#shadow {
width: 100px;
height: 100px;
background: #ff0000;
}
</style>
<div id="shadow">
</div>
</template>

<div id="log"></div>

<script>
test(function() {
var wrap = document.getElementById('wrap'),
shadowRoot = createSR(wrap),
shadow = document.getElementById('shadow-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowRoot.applyAuthorStyle = true;

shadowRoot.appendChild(shadow);

assert_equals(getComputedStyle(shadowRoot.querySelector('#shadow')).display, 'none');

}, 'apply author style to shadow dom');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!DOCTYPE HTML>
<html>
<head>
<title>ShadowRoot Object: Don`t apply author style</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="ShadowRoot Object: attribute bool applyAuthorStyles attribute. If true, the author styles are not applied">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../../testcommon.js"></script>
</head>
<body>
<h1>ShadowRoot Object: Don`t apply author style</h1>

<style>
#shadow {
display: none;
}
</style>
<div id="wrap"></div>
<template id="shadow-template">
<style>
#shadow {
width: 100px;
height: 100px;
background: #00ff00;
}
</style>
<div id="shadow">
</div>
</template>

<div id="log"></div>

<script>
test(function() {
var wrap = document.getElementById('wrap'),
shadowRoot = createSR(wrap),
shadow = document.getElementById('shadow-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowRoot.applyAuthorStyle = false;

shadowRoot.appendChild(shadow);

assert_equals(getComputedStyle(shadowRoot.querySelector('#shadow')).display, 'block');

}, 'apply author style to shadow dom');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>ShadowRoot Object: Don't reset style inheritance</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="ShadowRoot Object: attribute bool resetStyleInheritance. If true, the properties don`t continue to inherit CSS styles">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../../testcommon.js"></script>
</head>
<body>
<h1>ShadowRoot Object: Don`t reset style inheritance</h1>

<style>
#wrap {
font-size: 50px;
}
</style>
<div id="wrap"></div>
<template id="shadow-template">
<div id="shadow">
</div>
</template>

<div id="log"></div>
<script>
test(function() {
var wrap = document.getElementById('wrap'),
shadowRoot = createSR(wrap),
shadow = document.getElementById('shadow-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowRoot.appendChild(shadow);

shadowRoot.resetStyleInheritance = false;

assert_equals(getComputedStyle(shadowRoot.querySelector('#shadow')).fontSize, '50px');

}, 'reset style inheritance');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE HTML>
<html>
<head>
<title>ShadowRoot Object: Reset style inheritance</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="ShadowRoot Object: attribute bool resetStyleInheritance. If true, the properties don`t continue to inherit CSS styles">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../../testcommon.js"></script>
</head>
<body>
<h1>ShadowRoot Object: Reset style inheritance</h1>

<style>
#wrap {
font-size: 50px;
}
</style>
<div id="wrap"></div>
<template id="shadow-template">
<div id="shadow">
</div>
</template>

<div id="log"></div>
<script>
test(function() {
var wrap = document.getElementById('wrap'),
shadowRoot = createSR(wrap),
shadow = document.getElementById('shadow-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowRoot.appendChild(shadow);

shadowRoot.resetStyleInheritance = true;

assert_not_equals(getComputedStyle(shadowRoot.querySelector('#shadow')).fontSize, '50px');

}, 'reset style inheritance');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Nested tree: Apply author style</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="Nested tree: attribute bool applyAuthorStyles attribute. If true, the author styles are applied">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
</head>
<body>
<h1>Nested tree: Apply author style</h1>

<style>
#level2-red {
width: 100px;
height: 100px;
background: #ff0000;
}
</style>
<div id="level0"></div>

<div id="log"></div>
<template id="level1-template">
<style>
#level2-blue {
width: 100px;
height: 100px;
background: #0000ff;
}
</style>

<div id="level1">
<div id="level2-root"></div>
</div>

</template>
<template id="level2-template">
<style>
#level2-green {
width: 100px;
height: 100px;
background: #00ff00;
}
</style>
<div id="level2-red">
</div>
<div id="level2-blue">
</div>
<div id="level2-green">
</div>
</template>
<script>
test(function() {
var level0 = document.getElementById('level0'),
shadowLevel1 = createSR(level0),
shadowLevel2,
level1 = document.getElementById('level1-template').content,
level2 = document.getElementById('level2-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowLevel1.applyAuthorStyle = true;

shadowLevel1.appendChild(level1);

shadowLevel2 = shadowLevel1.getElementById('level2-root').webkitCreateShadowRoot();

shadowLevel2.applyAuthorStyle = true;

shadowLevel2.appendChild(level2);

assert_equals(getComputedStyle(shadowLevel2.querySelector('#level2-red')).backgroundColor, 'rgb(255, 0, 0)');
assert_equals(getComputedStyle(shadowLevel2.querySelector('#level2-blue')).backgroundColor, 'rgb(0, 0, 255)');
assert_equals(getComputedStyle(shadowLevel2.querySelector('#level2-green')).backgroundColor, 'rgb(0, 255, 0)');

}, 'apply author style on nested tree');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Nested tree: nested shadow tree cannot be accessed from external dom</title>
<link rel="author" title="thujikun" href="tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="Nested tree: cannot be accessed from external dom. if true, not be accessed">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
</head>
<body>
<h1>Nested tree: nested shadow tree cannot be accessed from external dom</h1>
<div id="level0"></div>
<div id="log"></div>
<template id="level1-template">
<div id="level1">
<div id="level2-root"></div>
</div>

</template>
<template id="level2-template">
<div id="level2">
</div>
</template>
<script>
test(function() {
var level0 = document.getElementById('level0'),
shadowLevel1 = createSR(level0),
shadowLevel2,
level1 = document.getElementById('level1-template').content,
level2 = document.getElementById('level2-template').content;

shadowLevel1.appendChild(level1);

shadowLevel2 = createSR(shadowLevel1.getElementById('level2-root'));

shadowLevel2.appendChild(level2);

assert_equals(level0.querySelector('#level1'), null);
assert_equals(level0.querySelector('#level2'), null);
assert_equals(shadowLevel1.querySelector('#level2'), null);
assert_not_equals(shadowLevel1.querySelector('#level1'), null);
assert_not_equals(shadowLevel2.querySelector('#level2'), null);
}, 'nested shadow tree cannot be accessed from external dom');
</script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Nested tree: Don`t apply author style</title>
<link rel="author" title="thujikun" href="mailto:tsuji.0107@gmail.com">
<link rel="help" href="http://www.w3.org/TR/shadow-dom/">
<meta name="assert" content="Nested tree: attribute bool applyAuthorStyle attribute. If true, the author styles are not applied">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../testcommon.js"></script>
</head>
<body>
<h1>Nested tree: Don`t apply author style</h1>

<style>
#level2-red {
width: 100px;
height: 100px;
background: #ff0000;
}
</style>
<div id="level0"></div>

<div id="log"></div>
<template id="level1-template">
<style>
#level2-blue {
width: 100px;
height: 100px;
background: #0000ff;
}
</style>

<div id="level1">
<div id="level2-root"></div>
</div>

</template>
<template id="level2-template">
<style>
#level2-green {
width: 100px;
height: 100px;
background: #00ff00;
}
</style>
<div id="level2-red">
</div>
<div id="level2-blue">
</div>
<div id="level2-green">
</div>
</template>
<script>
test(function() {
var level0 = document.getElementById('level0'),
shadowLevel1 = createSR(level0),
shadowLevel2,
level1 = document.getElementById('level1-template').content,
level2 = document.getElementById('level2-template').content,
getComputedStyle = document.defaultView.getComputedStyle;

shadowLevel1.appendChild(level1);

shadowLevel2 = shadowLevel1.getElementById('level2-root').webkitCreateShadowRoot();

shadowLevel2.appendChild(level2);

assert_not_equals(getComputedStyle(shadowLevel2.querySelector('#level2-red')).backgroundColor, 'rgb(255, 0, 0)');
assert_not_equals(getComputedStyle(shadowLevel2.querySelector('#level2-blue')).backgroundColor, 'rgb(0, 0, 255)');
assert_equals(getComputedStyle(shadowLevel2.querySelector('#level2-green')).backgroundColor, 'rgb(0, 255, 0)');

}, 'do not apply author style on nested tree');
</script>
</body>
</html>
Loading