summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-04 16:56:06 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-04 16:56:06 -0400
commitae246093a98ab1386c4422306928091f30a27fda (patch)
tree6eb0481ec64dd20613154402e678db0b84a6d84f /test
parenta0c4ce779d35cab39c62ca42ad3fe58a82faa1bb (diff)
Create some tests for fullscreen elements, <iframe>s, and shadow DOMs
Diffstat (limited to 'test')
-rw-r--r--test/data/html/test-document2-frame1.html42
-rw-r--r--test/data/html/test-document2-script.js41
-rw-r--r--test/data/html/test-document2.html81
-rw-r--r--test/data/html/test-stylesheet.css19
4 files changed, 183 insertions, 0 deletions
diff --git a/test/data/html/test-document2-frame1.html b/test/data/html/test-document2-frame1.html
new file mode 100644
index 00000000..3b85cdc5
--- /dev/null
+++ b/test/data/html/test-document2-frame1.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan Tests</title>
+ <script src="test-document2-script.js"></script>
+ <style>
+body {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 14px;
+ padding: 0;
+ margin: 0;
+ background-color: #f8f8f8;
+}
+a, a:visited {
+ color: #1080c0;
+ text-decoration: underline;
+}
+.content {
+ position: absolute;
+ left: 0;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ padding: 0.5em;
+ background-color: #f8f8f8;
+}
+ </style>
+ </head>
+<body><div class="content">
+<div>
+ ありがとう
+</div>
+<div>
+ <a href="#" id="fullscreen-link">Toggle fullscreen</a>
+ <script>
+document.querySelector('#fullscreen-link').addEventListener('click', () => toggleFullscreen(document.body), false);
+ </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
new file mode 100644
index 00000000..bd5a570d
--- /dev/null
+++ b/test/data/html/test-document2-script.js
@@ -0,0 +1,41 @@
+function requestFullscreen(element) {
+ if (element.requestFullscreen) {
+ element.requestFullscreen();
+ } else if (element.mozRequestFullScreen) {
+ element.mozRequestFullScreen();
+ } else if (element.webkitRequestFullscreen) {
+ element.webkitRequestFullscreen();
+ } else if (element.msRequestFullscreen) {
+ element.msRequestFullscreen();
+ }
+}
+
+function exitFullscreen() {
+ if (document.exitFullscreen) {
+ document.exitFullscreen();
+ } else if (document.mozCancelFullScreen) {
+ document.mozCancelFullScreen();
+ } else if (document.webkitExitFullscreen) {
+ document.webkitExitFullscreen();
+ } else if (document.msExitFullscreen) {
+ document.msExitFullscreen();
+ }
+}
+
+function getFullscreenElement() {
+ return (
+ document.fullscreenElement ||
+ document.msFullscreenElement ||
+ document.mozFullScreenElement ||
+ document.webkitFullscreenElement ||
+ null
+ );
+}
+
+function toggleFullscreen(element) {
+ if (getFullscreenElement()) {
+ exitFullscreen();
+ } else {
+ requestFullscreen(element);
+ }
+}
diff --git a/test/data/html/test-document2.html b/test/data/html/test-document2.html
new file mode 100644
index 00000000..0561a176
--- /dev/null
+++ b/test/data/html/test-document2.html
@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <title>Yomichan Manual Tests</title>
+ <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODlhEAAQAKEBAAAAAP///////////yH5BAEKAAIALAAAAAAQABAAAAImFI6Zpt0B4YkS0TCpq07xbmEgcGVRUpLaI46ZG7ppalY0jDCwUAAAOw==" />
+ <link rel="stylesheet" href="test-stylesheet.css" />
+ <script src="test-document2-script.js"></script>
+ </head>
+<body>
+
+ <h1>Yomichan Manual Tests</h1>
+ <p class="description">Manual tests involving fullscreen elements, &lt;iframe&gt;s, and shadow DOMs.</p>
+
+ <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;">
+ <div>
+ ありがとう
+ </div>
+ <div>
+ <a href="#" id="fullscreen-link1">Toggle fullscreen</a>
+ </div>
+ </div></div>
+ <script>
+document.querySelector('#fullscreen-link1').addEventListener('click', () => toggleFullscreen(document.querySelector('#fullscreen-element1')), false);
+ </script>
+ </div>
+
+ <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">
+ <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>
+ ありがとう
+ </div>
+ <div>
+ <a href="#" id="fullscreen-link2">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>
+
+ <div class="test">
+ <div class="description">&lt;iframe&gt; element.</div>
+ <iframe src="test-document2-frame1.html" style="width: 100%; height: 200px; border: 1px solid #d8d8d8;"></iframe>
+ </div>
+
+ <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">
+ <iframe src="test-document2-frame1.html" 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>
+
+</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 ab25732e..f63d2481 100644
--- a/test/data/html/test-stylesheet.css
+++ b/test/data/html/test-stylesheet.css
@@ -7,6 +7,7 @@ body {
margin: 0 auto;
background-color: #f8f8f8;
counter-reset: test-id;
+ overflow-y: scroll;
}
h1 {
@@ -14,6 +15,19 @@ h1 {
margin: 0.67em 0;
}
+p {
+ margin: 0.33em 0;
+}
+
+h1+p {
+ margin-top: -0.67em;
+}
+
+a, a:visited {
+ color: #1080c0;
+ text-decoration: underline;
+}
+
.test {
background-color: #ffffff;
margin: 1em 0;
@@ -30,3 +44,8 @@ h1 {
border-bottom: 1px solid #d8d8d8;
font-weight: bold;
}
+
+.description {
+ color: #444444;
+ font-style: italic;
+}