summaryrefslogtreecommitdiff
path: root/test/data/html/test-document2-script.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-04-04 22:42:48 -0400
committerGitHub <noreply@github.com>2020-04-04 22:42:48 -0400
commit167e83c14794437e43b7df2017efab1e7e060a99 (patch)
treec3ea69779daee88be9c371785e78aedca996a94f /test/data/html/test-document2-script.js
parenta0c4ce779d35cab39c62ca42ad3fe58a82faa1bb (diff)
parenta4c7d243f4cddfc4e2b29132fe65fe07ff86bc36 (diff)
Merge pull request #430 from toasted-nutbread/manual-dom-tests
Create some tests for fullscreen elements, <iframe>s, and shadow DOMs
Diffstat (limited to 'test/data/html/test-document2-script.js')
-rw-r--r--test/data/html/test-document2-script.js41
1 files changed, 41 insertions, 0 deletions
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);
+ }
+}