summaryrefslogtreecommitdiff
path: root/test/data/html/test-document2-script.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-05-10 14:09:04 -0400
committerGitHub <noreply@github.com>2020-05-10 14:09:04 -0400
commitf85508a25edb49de96bebb77a5832931f0819eff (patch)
treec3b7d6a441eeae7d5026ecf05374e4c415aa795b /test/data/html/test-document2-script.js
parentc38cd70e91214a6f3510d78433653c85bf4d2df9 (diff)
Simplify shadow test and add an open shadow DOM test (#533)
Diffstat (limited to 'test/data/html/test-document2-script.js')
-rw-r--r--test/data/html/test-document2-script.js24
1 files changed, 24 insertions, 0 deletions
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);
+ }
+}