summaryrefslogtreecommitdiff
path: root/test/data/html
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2020-05-22 17:46:16 -0700
committerAlex Yatskov <alex@foosoft.net>2020-05-22 17:46:16 -0700
commit1480288561cb8b9fb87ad711d970c548329fea98 (patch)
tree87c2247f6d144407afcc6de316bbacc264582248 /test/data/html
parentf2186c51e4ef219d158735d30a32bbf3e49c4e1a (diff)
parentd0dcff765f740bf6f0f6523b09cb8b21eb85cd93 (diff)
Merge branch 'master' into testing
Diffstat (limited to 'test/data/html')
-rw-r--r--test/data/html/test-document1.html1
-rw-r--r--test/data/html/test-document2-frame1.html6
-rw-r--r--test/data/html/test-document2-script.js24
-rw-r--r--test/data/html/test-document2.html97
-rw-r--r--test/data/html/test-document3-frame1.html44
-rw-r--r--test/data/html/test-document3-frame2.html62
-rw-r--r--test/data/html/test-document3.html26
-rw-r--r--test/data/html/test-dom-text-scanner.html393
-rw-r--r--test/data/html/test-stylesheet.css15
9 files changed, 615 insertions, 53 deletions
diff --git a/test/data/html/test-document1.html b/test/data/html/test-document1.html
index 0754a314..98a6fb44 100644
--- a/test/data/html/test-document1.html
+++ b/test/data/html/test-document1.html
@@ -103,6 +103,7 @@
data-end-node-selector="img"
data-end-offset="0"
data-result-type="TextSourceElement"
+ data-sentence-extent="100"
data-sentence="よみちゃん"
>
<img src="data:image/gif;base64,R0lGODdhBwAHAIABAAAAAP///ywAAAAABwAHAAACDIRvEaC32FpCbEkKCgA7" alt="よみちゃん" title="よみちゃん" style="width: 70px; height: 70px; image-rendering: crisp-edges; image-rendering: pixelated; display: block;" />
diff --git a/test/data/html/test-document2-frame1.html b/test/data/html/test-document2-frame1.html
index 3b85cdc5..e572e3c4 100644
--- a/test/data/html/test-document2-frame1.html
+++ b/test/data/html/test-document2-frame1.html
@@ -33,10 +33,8 @@ a, a:visited {
ありがとう
</div>
<div>
- <a href="#" id="fullscreen-link">Toggle fullscreen</a>
- <script>
-document.querySelector('#fullscreen-link').addEventListener('click', () => toggleFullscreen(document.body), false);
- </script>
+ <a href="#" class="fullscreen-link">Toggle fullscreen</a>
+ <script>setup(document.body, document.body);</script>
</div>
</div></body>
</html> \ No newline at end of file
diff --git a/test/data/html/test-document2-script.js b/test/data/html/test-document2-script.js
index bd5a570d..ab516a4e 100644
--- a/test/data/html/test-document2-script.js
+++ b/test/data/html/test-document2-script.js
@@ -39,3 +39,27 @@ function toggleFullscreen(element) {
requestFullscreen(element);
}
}
+
+function setup(container, fullscreenElement=null) {
+ const fullscreenLink = container.querySelector('.fullscreen-link');
+ if (fullscreenLink !== null) {
+ if (fullscreenElement === null) {
+ fullscreenElement = container.querySelector('.fullscreen-element');
+ }
+ fullscreenLink.addEventListener('click', (e) => {
+ toggleFullscreen(fullscreenElement);
+ e.preventDefault();
+ return false;
+ }, false);
+ }
+
+ const template = container.querySelector('template');
+ const templateContentContainer = container.querySelector('.template-content-container');
+ if (template !== null && templateContentContainer !== null) {
+ const mode = container.dataset.shadowMode;
+ const shadow = templateContentContainer.attachShadow({mode});
+ const content = document.importNode(template.content, true);
+ setup(content);
+ shadow.appendChild(content);
+ }
+}
diff --git a/test/data/html/test-document2.html b/test/data/html/test-document2.html
index 3a22a5bf..6d174571 100644
--- a/test/data/html/test-document2.html
+++ b/test/data/html/test-document2.html
@@ -11,71 +11,78 @@
<body>
<h1>Yomichan Manual Tests</h1>
- <p class="description">Manual tests involving fullscreen elements, &lt;iframe&gt;s, and shadow DOMs.</p>
+ <y-description>Manual tests involving fullscreen elements, &lt;iframe&gt;s, and shadow DOMs.</y-description>
- <div class="test">
- <div class="description">Standard content.</div>
- <div id="fullscreen-element1" style="width: 100%; height: 200px; border: 1px solid #d8d8d8; position: relative;"><div style="background-color: #f8f8f8; padding: 0.5em; position: absolute; left: 0; top: 0; bottom: 0; right: 0;">
+ <y-test>
+ <y-description>Standard content.</y-description>
+ <div class="fullscreen-element" style="width: 100%; height: 200px; border: 1px solid #d8d8d8; position: relative;"><div style="background-color: #f8f8f8; padding: 0.5em; position: absolute; left: 0; top: 0; bottom: 0; right: 0;">
<div>
ありがとう
</div>
<div>
- <a href="#" id="fullscreen-link1">Toggle fullscreen</a>
+ <a href="#" class="fullscreen-link">Toggle fullscreen</a>
</div>
</div></div>
- <script>
-document.querySelector('#fullscreen-link1').addEventListener('click', () => toggleFullscreen(document.querySelector('#fullscreen-element1')), false);
- </script>
- </div>
+ </y-test>
- <div class="test">
- <div class="description">Content inside of a shadow DOM.</div>
- <div id="shadow-content-container"></div>
- <template id="shadow-content-container-content-template">
+ <y-test data-shadow-mode="open">
+ <y-description>Content inside of an open shadow DOM.</y-description>
+ <div class="template-content-container"></div>
+ <template>
<link rel="stylesheet" href="test-stylesheet.css" />
- <div id="fullscreen-element2" style="width: 100%; height: 200px; border: 1px solid #d8d8d8; position: relative;"><div style="background-color: #f8f8f8; padding: 0.5em; position: absolute; left: 0; top: 0; bottom: 0; right: 0;">
+ <div class="fullscreen-element" style="width: 100%; height: 200px; border: 1px solid #d8d8d8; position: relative;"><div style="background-color: #f8f8f8; padding: 0.5em; position: absolute; left: 0; top: 0; bottom: 0; right: 0;">
<div>
ありがとう
</div>
<div>
- <a href="#" id="fullscreen-link2">Toggle fullscreen</a>
+ <a href="#" class="fullscreen-link">Toggle fullscreen</a>
</div>
</div></div>
</template>
- <script>
-(() => {
- const shadowIframeContainer = document.querySelector('#shadow-content-container');
- const shadow = shadowIframeContainer.attachShadow({mode: 'closed'});
- const template = document.querySelector('#shadow-content-container-content-template').content;
- const content = document.importNode(template, true);
- const fullscreenElement = content.querySelector('#fullscreen-element2');
- content.querySelector('#fullscreen-link2').addEventListener('click', () => toggleFullscreen(fullscreenElement), false);
- shadow.appendChild(content);
-})();
- </script>
- </div>
+ </y-test>
- <div class="test">
- <div class="description">&lt;iframe&gt; element.</div>
+ <y-test data-shadow-mode="closed">
+ <y-description>Content inside of a closed shadow DOM.</y-description>
+ <div class="template-content-container"></div>
+ <template>
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ <div class="fullscreen-element" style="width: 100%; height: 200px; border: 1px solid #d8d8d8; position: relative;"><div style="background-color: #f8f8f8; padding: 0.5em; position: absolute; left: 0; top: 0; bottom: 0; right: 0;">
+ <div>
+ ありがとう
+ </div>
+ <div>
+ <a href="#" class="fullscreen-link">Toggle fullscreen</a>
+ </div>
+ </div></div>
+ </template>
+ </y-test>
+
+ <y-test>
+ <y-description>&lt;iframe&gt; element.</y-description>
<iframe src="test-document2-frame1.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
- </div>
+ </y-test>
+
+ <y-test data-shadow-mode="open">
+ <y-description>&lt;iframe&gt; element inside of an open shadow DOM.</y-description>
+ <div class="template-content-container"></div>
+ <template>
+ <iframe src="test-document2-frame1.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
+ </template>
+ </y-test>
- <div class="test">
- <div class="description">&lt;iframe&gt; element inside of a shadow DOM.</div>
- <div id="shadow-iframe-container"></div>
- <template id="shadow-iframe-container-content-template">
+ <y-test data-shadow-mode="closed">
+ <y-description>&lt;iframe&gt; element inside of a closed shadow DOM.</y-description>
+ <div class="template-content-container"></div>
+ <template>
<iframe src="test-document2-frame1.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
</template>
- <script>
-(() => {
- const shadowIframeContainer = document.querySelector('#shadow-iframe-container');
- const shadow = shadowIframeContainer.attachShadow({mode: 'closed'});
- const template = document.querySelector('#shadow-iframe-container-content-template').content;
- const content = document.importNode(template, true);
- shadow.appendChild(content);
-})();
- </script>
- </div>
+ </y-test>
+
+ <script>
+for (const element of document.querySelectorAll('y-test')) {
+ setup(element);
+}
+ </script>
</body>
-</html> \ No newline at end of file
+</html>
diff --git a/test/data/html/test-document3-frame1.html b/test/data/html/test-document3-frame1.html
new file mode 100644
index 00000000..2ae906d2
--- /dev/null
+++ b/test/data/html/test-document3-frame1.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan Manual Performance Tests</title>
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ </head>
+<body><div class="content">
+
+ <div class="description">Add elements</div>
+
+ <div>
+ <a href="#" id="add-elements-1000">1000</a>
+ <a href="#" id="add-elements-10000">10000</a>
+ <a href="#" id="add-elements-100000">100000</a>
+ <a href="#" id="add-elements-1000000">1000000</a>
+ <script>
+document.querySelector('#add-elements-1000').addEventListener('click', () => addElements(1000), false);
+document.querySelector('#add-elements-10000').addEventListener('click', () => addElements(10000), false);
+document.querySelector('#add-elements-100000').addEventListener('click', () => addElements(100000), false);
+document.querySelector('#add-elements-1000000').addEventListener('click', () => addElements(1000000), false);
+
+let counter = 0;
+
+function addElements(amount) {
+ const container = document.querySelector('#container');
+ for (let i = 0; i < amount; i++) {
+ const element = document.createElement('div');
+ element.textContent = 'ありがとう';
+ container.appendChild(element);
+ }
+
+ counter += amount;
+ document.querySelector('#counter').textContent = counter;
+}
+ </script>
+ </div>
+
+ <div id="counter"></div>
+ <div id="container"></div>
+
+</div></body>
+</html>
diff --git a/test/data/html/test-document3-frame2.html b/test/data/html/test-document3-frame2.html
new file mode 100644
index 00000000..c486e04b
--- /dev/null
+++ b/test/data/html/test-document3-frame2.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan Manual Performance Tests</title>
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ </head>
+<body><div class="content">
+
+ <div class="description">&lt;iframe&gt; element inside of an open shadow DOM.</div>
+
+ <div id="shadow-iframe-container-open"></div>
+ <template id="shadow-iframe-container-open-content-template">
+ <iframe src="test-document2-frame1.html" allowfullscreen="true" style="width: 100%; height: 50px; border: 1px solid #d8d8d8;"></iframe>
+ </template>
+ <script>
+(() => {
+ const shadowIframeContainer = document.querySelector('#shadow-iframe-container-open');
+ const shadow = shadowIframeContainer.attachShadow({mode: 'open'});
+ const template = document.querySelector('#shadow-iframe-container-open-content-template').content;
+ const content = document.importNode(template, true);
+ shadow.appendChild(content);
+})();
+ </script>
+
+ <div class="description">Add elements</div>
+
+ <div>
+ <a href="#" id="add-elements-1000">1000</a>
+ <a href="#" id="add-elements-10000">10000</a>
+ <a href="#" id="add-elements-100000">100000</a>
+ <a href="#" id="add-elements-1000000">1000000</a>
+ </div>
+
+ <div id="counter"></div>
+ <div id="container"></div>
+ <script>
+(() => {
+ document.querySelector('#add-elements-1000').addEventListener('click', () => addElements(1000), false);
+ document.querySelector('#add-elements-10000').addEventListener('click', () => addElements(10000), false);
+ document.querySelector('#add-elements-100000').addEventListener('click', () => addElements(100000), false);
+ document.querySelector('#add-elements-1000000').addEventListener('click', () => addElements(1000000), false);
+
+ let counter = 0;
+
+ function addElements(amount) {
+ const container = document.querySelector('#container');
+ for (let i = 0; i < amount; i++) {
+ const element = document.createElement('div');
+ element.textContent = 'ありがとう';
+ container.appendChild(element);
+ }
+
+ counter += amount;
+ document.querySelector('#counter').textContent = counter;
+ }
+})();
+ </script>
+
+</div></body>
+</html>
diff --git a/test/data/html/test-document3.html b/test/data/html/test-document3.html
new file mode 100644
index 00000000..3e7d5236
--- /dev/null
+++ b/test/data/html/test-document3.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan Manual Performance Tests</title>
+ <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODlhEAAQAKEBAAAAAP///////////yH5BAEKAAIALAAAAAAQABAAAAImFI6Zpt0B4YkS0TCpq07xbmEgcGVRUpLaI46ZG7ppalY0jDCwUAAAOw==" />
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ </head>
+<body>
+
+ <h1>Yomichan Manual Performance Tests</h1>
+ <p class="description">Testing Yomichan performance with artificially demanding cases in a real browser</p>
+
+ <div class="test">
+ <div class="description">&lt;iframe&gt; element.</div>
+ <iframe src="test-document3-frame1.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
+ </div>
+
+ <div class="test">
+ <div class="description">&lt;iframe&gt; element containing an &lt;iframe&gt; element inside of an open shadow DOM.</div>
+ <iframe src="test-document3-frame2.html" allowfullscreen="true" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
+ </div>
+
+</body>
+</html>
diff --git a/test/data/html/test-dom-text-scanner.html b/test/data/html/test-dom-text-scanner.html
new file mode 100644
index 00000000..dc06eb64
--- /dev/null
+++ b/test/data/html/test-dom-text-scanner.html
@@ -0,0 +1,393 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan DOMTextScanner Tests</title>
+ <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODlhEAAQAKEBAAAAAP///////////yH5BAEKAAIALAAAAAAQABAAAAImFI6Zpt0B4YkS0TCpq07xbmEgcGVRUpLaI46ZG7ppalY0jDCwUAAAOw==" />
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ </head>
+<body>
+
+ <h1>Yomichan DOMTextScanner Tests</h1>
+
+ <y-test
+ data-test-data='{
+ "node": "div:nth-of-type(1)",
+ "offset": 0,
+ "length": 15,
+ "expected": {
+ "node": "div:nth-of-type(2)>div::text",
+ "offset": 3,
+ "content": "小ぢん\nまり1\n小ぢん\nまり2"
+ }
+ }'
+ >
+ <y-description>Layout newlines expected due to entering and exiting display:block nodes.</y-description>
+<div><div>小ぢん</div>まり1</div>
+<div>小ぢん<div>まり2</div></div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 13,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Layout newline expected due to sequential display:block elements.</y-description>
+<div>小ぢんまり1</div><div>小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 13,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Layout newline expected due to sequential display:block elements separated by a newline.</y-description>
+<div>小ぢんまり1</div>
+<div>小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "span:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 12,
+ "expected": {
+ "node": "span:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>No newlines expected due to display:inline.</y-description>
+<span>小ぢんまり1</span><span>小ぢんまり2</span>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "span:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 13,
+ "expected": {
+ "node": "span:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1 小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>No newlines expected due to white-space:normal.</y-description>
+<span>小ぢんまり1</span>
+<span>小ぢんまり2</span>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "span:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 13,
+ "expected": {
+ "node": "span:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Newline expected due to white-space:pre.</y-description>
+<pre>
+<span>小ぢんまり1</span>
+<span>小ぢんまり2</span>
+</pre>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "span:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 12,
+ "expected": {
+ "node": "span:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>No newlines expected due to display:inline-block. Actual layout flow cannot be determined by DOM/CSS alone.</y-description>
+<span style="display: inline-block;">小ぢんまり1</span><span style="display: inline-block;">小ぢんまり2</span>
+ </y-test>
+
+ <y-test
+ style="position: relative;"
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 13,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Single newline expected due to display:block layout.</y-description>
+<div>小ぢんまり1</div><div style="position: relative;">小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ style="position: relative; overflow: hidden;"
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 14,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Two newlines expected due to position:absolute causing a significant layout change.</y-description>
+<div>小ぢんまり1</div><div style="position: absolute;">小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ style="position: relative; overflow: hidden;"
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 14,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Two newlines expected due to position:fixed causing a significant layout change.</y-description>
+<div>小ぢんまり1</div><div style="position: fixed;">小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ style="position: relative;"
+ data-test-data='{
+ "node": "div:nth-of-type(1)::text",
+ "offset": 0,
+ "length": 14,
+ "expected": {
+ "node": "div:nth-of-type(2)::text",
+ "offset": 6,
+ "content": "小ぢんまり1\n\n小ぢんまり2"
+ }
+ }'
+ >
+ <y-description>Two newlines expected due to position:sticky being able to cause a significant layout change.</y-description>
+<div>小ぢんまり1</div><div style="position: sticky;">小ぢんまり2</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "rt",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::text",
+ "offset": 5,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Scanning text starting in an &lt;rt&gt; element. Should start scanning at the start of the &lt;ruby&gt; tag instead.</y-description>
+<div><ruby>小<rp>(</rp><rt>こ</rt><rp>)</rp></ruby>ぢんまり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip &lt;script&gt; content.</y-description>
+<div>小ぢん<script>/*comment*/</script>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip &lt;style&gt; content.</y-description>
+<div>小ぢん<style>/*comment*/</style>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip &lt;textarea&gt; content.</y-description>
+<div>小ぢん<textarea>textarea content</textarea>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip &lt;input&gt; content.</y-description>
+<div>小ぢん<input value="content" />まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip &lt;button&gt; content.</y-description>
+<div>小ぢん<button>content</button>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip content with font-size:0.</y-description>
+<div>小ぢん<span style="font-size: 0;">content</span>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip content with opacity:0.</y-description>
+<div>小ぢん<span style="opacity: 0;">content</span>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip content with visibility:hidden.</y-description>
+<div>小ぢん<span style="visibility: hidden;">content</span>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip content with display:none.</y-description>
+<div>小ぢん<span style="display: none;">content</span>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Don't skip content with user-select:none.</y-description>
+<div>小ぢ<span style="user-select: none;">ん</span>まり1</div>
+ </y-test>
+
+ <y-test
+ data-test-data='{
+ "node": "div",
+ "offset": 0,
+ "length": 6,
+ "expected": {
+ "node": "div::nth-text(2)",
+ "offset": 3,
+ "content": "小ぢんまり1"
+ }
+ }'
+ >
+ <y-description>Skip content with user-select:none <em>and</em> a transparent color.</y-description>
+<div>小ぢん<span style="user-select: none; color: rgba(0, 0, 0, 0);">content</span>まり1</div>
+ </y-test>
+
+</body>
+</html> \ No newline at end of file
diff --git a/test/data/html/test-stylesheet.css b/test/data/html/test-stylesheet.css
index f63d2481..b4d2e255 100644
--- a/test/data/html/test-stylesheet.css
+++ b/test/data/html/test-stylesheet.css
@@ -19,7 +19,8 @@ p {
margin: 0.33em 0;
}
-h1+p {
+h1+p,
+h1+y-description {
margin-top: -0.67em;
}
@@ -28,7 +29,9 @@ a, a:visited {
text-decoration: underline;
}
-.test {
+.test,
+y-test {
+ display: block;
background-color: #ffffff;
margin: 1em 0;
padding: 0.5em;
@@ -36,7 +39,8 @@ a, a:visited {
border-radius: 4px;
}
-.test:before {
+.test:before,
+y-test:before {
content: "Test " counter(test-id);
display: block;
counter-increment: test-id;
@@ -45,7 +49,10 @@ a, a:visited {
font-weight: bold;
}
-.description {
+.description,
+y-description {
color: #444444;
font-style: italic;
+ display: block;
+ padding-bottom: 0.5em;
}