summaryrefslogtreecommitdiffstats
path: root/remote/test/puppeteer/test/assets/input
diff options
context:
space:
mode:
Diffstat (limited to 'remote/test/puppeteer/test/assets/input')
-rw-r--r--remote/test/puppeteer/test/assets/input/button.html16
-rw-r--r--remote/test/puppeteer/test/assets/input/checkbox.html42
-rw-r--r--remote/test/puppeteer/test/assets/input/drag-and-drop.html43
-rw-r--r--remote/test/puppeteer/test/assets/input/fileupload.html9
-rw-r--r--remote/test/puppeteer/test/assets/input/keyboard.html42
-rw-r--r--remote/test/puppeteer/test/assets/input/mouse-helper.js74
-rw-r--r--remote/test/puppeteer/test/assets/input/rotatedButton.html21
-rw-r--r--remote/test/puppeteer/test/assets/input/scrollable.html37
-rw-r--r--remote/test/puppeteer/test/assets/input/select.html70
-rw-r--r--remote/test/puppeteer/test/assets/input/textarea.html15
-rw-r--r--remote/test/puppeteer/test/assets/input/touchscreen.html122
-rw-r--r--remote/test/puppeteer/test/assets/input/wheel.html43
12 files changed, 534 insertions, 0 deletions
diff --git a/remote/test/puppeteer/test/assets/input/button.html b/remote/test/puppeteer/test/assets/input/button.html
new file mode 100644
index 0000000000..d4c6e13fd2
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/button.html
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Button test</title>
+ </head>
+ <body>
+ <script src="mouse-helper.js"></script>
+ <button onclick="clicked();">Click target</button>
+ <script>
+ window.result = 'Was not clicked';
+ function clicked() {
+ result = 'Clicked';
+ }
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/remote/test/puppeteer/test/assets/input/checkbox.html b/remote/test/puppeteer/test/assets/input/checkbox.html
new file mode 100644
index 0000000000..ca56762e2b
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/checkbox.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Selection Test</title>
+ </head>
+ <body>
+ <label for="agree">Remember Me</label>
+ <input id="agree" type="checkbox">
+ <script>
+ window.result = {
+ check: null,
+ events: [],
+ };
+
+ let checkbox = document.querySelector('input');
+
+ const events = [
+ 'change',
+ 'click',
+ 'dblclick',
+ 'input',
+ 'mousedown',
+ 'mouseenter',
+ 'mouseleave',
+ 'mousemove',
+ 'mouseout',
+ 'mouseover',
+ 'mouseup',
+ ];
+
+ for (let event of events) {
+ checkbox.addEventListener(event, () => {
+ if (['change', 'click', 'dblclick', 'input'].includes(event) === true) {
+ result.check = checkbox.checked;
+ }
+
+ result.events.push(event);
+ }, false);
+ }
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/drag-and-drop.html b/remote/test/puppeteer/test/assets/input/drag-and-drop.html
new file mode 100644
index 0000000000..b77870c4ad
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/drag-and-drop.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Drag-and-drop test</title>
+ <style>
+ #drop {
+ width: 5em;
+ height: 5em;
+ border: 1px solid black;
+ }
+ </style>
+ </head>
+ <body>
+ <div id="drag" draggable="true">drag me</div>
+ <div id="drop"></div>
+ <div id="drag-state">0</div>
+ <script>
+ const drag = document.getElementById('drag');
+ const drop = document.getElementById('drop');
+ drag.addEventListener('dragstart', function(event) {
+ event.dataTransfer.setData('id', event.target.id);
+ document.getElementById('drag-state').textContent += '1';
+ });
+ drop.addEventListener('dragenter', function(event) {
+ event.preventDefault();
+ document.getElementById('drag-state').textContent += '2';
+ });
+ drop.addEventListener('dragover', function(event) {
+ event.preventDefault();
+ document.getElementById('drag-state').textContent += '3';
+ });
+ drop.addEventListener('drop', function(event) {
+ event.preventDefault();
+ const id = event.dataTransfer.getData('id');
+ const el = document.getElementById(id);
+ if (el) {
+ event.target.appendChild(el);
+ document.getElementById('drag-state').textContent += '4';
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/fileupload.html b/remote/test/puppeteer/test/assets/input/fileupload.html
new file mode 100644
index 0000000000..55fd7c5006
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/fileupload.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>File upload test</title>
+ </head>
+ <body>
+ <input type="file">
+ </body>
+</html> \ No newline at end of file
diff --git a/remote/test/puppeteer/test/assets/input/keyboard.html b/remote/test/puppeteer/test/assets/input/keyboard.html
new file mode 100644
index 0000000000..2f4b7d33c2
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/keyboard.html
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Keyboard test</title>
+ </head>
+ <body>
+ <textarea></textarea>
+ <script>
+ window.result = "";
+ let textarea = document.querySelector('textarea');
+ textarea.focus();
+ textarea.addEventListener('keydown', event => {
+ log('Keydown:', event.key, event.code, modifiers(event));
+ });
+ textarea.addEventListener('input', event => {
+ log('input:', event.data, event.inputType, event.isComposing);
+ });
+ textarea.addEventListener('keyup', event => {
+ log('Keyup:', event.key, event.code, modifiers(event));
+ });
+ function modifiers(event) {
+ let m = [];
+ if (event.altKey)
+ m.push('Alt')
+ if (event.ctrlKey)
+ m.push('Control');
+ if (event.shiftKey)
+ m.push('Shift')
+ return '[' + m.join(' ') + ']';
+ }
+ function log(...args) {
+ console.log.apply(console, args);
+ result += args.join(' ') + '\n';
+ }
+ function getResult() {
+ let temp = result.trim();
+ result = "";
+ return temp;
+ }
+ </script>
+ </body>
+</html> \ No newline at end of file
diff --git a/remote/test/puppeteer/test/assets/input/mouse-helper.js b/remote/test/puppeteer/test/assets/input/mouse-helper.js
new file mode 100644
index 0000000000..97a764aa80
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/mouse-helper.js
@@ -0,0 +1,74 @@
+// This injects a box into the page that moves with the mouse;
+// Useful for debugging
+(function () {
+ const box = document.createElement('div');
+ box.classList.add('mouse-helper');
+ const styleElement = document.createElement('style');
+ styleElement.innerHTML = `
+ .mouse-helper {
+ pointer-events: none;
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 20px;
+ height: 20px;
+ background: rgba(0,0,0,.4);
+ border: 1px solid white;
+ border-radius: 10px;
+ margin-left: -10px;
+ margin-top: -10px;
+ transition: background .2s, border-radius .2s, border-color .2s;
+ }
+ .mouse-helper.button-1 {
+ transition: none;
+ background: rgba(0,0,0,0.9);
+ }
+ .mouse-helper.button-2 {
+ transition: none;
+ border-color: rgba(0,0,255,0.9);
+ }
+ .mouse-helper.button-3 {
+ transition: none;
+ border-radius: 4px;
+ }
+ .mouse-helper.button-4 {
+ transition: none;
+ border-color: rgba(255,0,0,0.9);
+ }
+ .mouse-helper.button-5 {
+ transition: none;
+ border-color: rgba(0,255,0,0.9);
+ }
+ `;
+ document.head.appendChild(styleElement);
+ document.body.appendChild(box);
+ document.addEventListener(
+ 'mousemove',
+ (event) => {
+ box.style.left = event.pageX + 'px';
+ box.style.top = event.pageY + 'px';
+ updateButtons(event.buttons);
+ },
+ true
+ );
+ document.addEventListener(
+ 'mousedown',
+ (event) => {
+ updateButtons(event.buttons);
+ box.classList.add('button-' + event.which);
+ },
+ true
+ );
+ document.addEventListener(
+ 'mouseup',
+ (event) => {
+ updateButtons(event.buttons);
+ box.classList.remove('button-' + event.which);
+ },
+ true
+ );
+ function updateButtons(buttons) {
+ for (let i = 0; i < 5; i++)
+ {box.classList.toggle('button-' + i, buttons & (1 << i));}
+ }
+})();
diff --git a/remote/test/puppeteer/test/assets/input/rotatedButton.html b/remote/test/puppeteer/test/assets/input/rotatedButton.html
new file mode 100644
index 0000000000..1bce66cf5e
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/rotatedButton.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Rotated button test</title>
+ </head>
+ <body>
+ <script src="mouse-helper.js"></script>
+ <button onclick="clicked();">Click target</button>
+ <style>
+ button {
+ transform: rotateY(180deg);
+ }
+ </style>
+ <script>
+ window.result = 'Was not clicked';
+ function clicked() {
+ result = 'Clicked';
+ }
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/scrollable.html b/remote/test/puppeteer/test/assets/input/scrollable.html
new file mode 100644
index 0000000000..75757824a4
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/scrollable.html
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Scrollable test</title>
+ </head>
+ <body>
+ <script src='mouse-helper.js'></script>
+ <script>
+ for (let i = 0; i < 100; i++) {
+ let button = document.createElement('button');
+ button.textContent = i + ': not clicked';
+ button.id = 'button-' + i;
+ button.onclick = () => button.textContent = 'clicked';
+ button.oncontextmenu = event => {
+ if (![2].includes(event.button)) {
+ return;
+ }
+ event.preventDefault();
+ button.textContent = 'context menu';
+ }
+ button.onmouseup = event => {
+ if (![1,3,4].includes(event.button)) {
+ return;
+ }
+ event.preventDefault();
+ button.textContent = {
+ 3: 'back click',
+ 4: 'forward click',
+ 1: 'aux click',
+ }[event.button];
+ }
+ document.body.appendChild(button);
+ document.body.appendChild(document.createElement('br'));
+ }
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/select.html b/remote/test/puppeteer/test/assets/input/select.html
new file mode 100644
index 0000000000..026d48e328
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/select.html
@@ -0,0 +1,70 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Selection Test</title>
+ </head>
+ <body>
+ <select>
+ <option value="">Empty</option>
+ <option value="black">Black</option>
+ <option value="blue">Blue</option>
+ <option value="brown">Brown</option>
+ <option value="cyan">Cyan</option>
+ <option value="gray">Gray</option>
+ <option value="green">Green</option>
+ <option value="indigo">Indigo</option>
+ <option value="magenta">Magenta</option>
+ <option value="orange">Orange</option>
+ <option value="pink">Pink</option>
+ <option value="purple">Purple</option>
+ <option value="red">Red</option>
+ <option value="violet">Violet</option>
+ <option value="white">White</option>
+ <option value="yellow">Yellow</option>
+ </select>
+ <script>
+ window.result = {
+ onInput: null,
+ onChange: null,
+ onBubblingChange: null,
+ onBubblingInput: null,
+ };
+
+ let select = document.querySelector('select');
+
+ function makeEmpty() {
+ for (let i = select.options.length - 1; i >= 0; --i) {
+ select.remove(i);
+ }
+ }
+
+ function makeMultiple() {
+ select.setAttribute('multiple', true);
+ }
+
+ select.addEventListener('input', () => {
+ result.onInput = Array.from(select.querySelectorAll('option:checked')).map((option) => {
+ return option.value;
+ });
+ }, false);
+
+ select.addEventListener('change', () => {
+ result.onChange = Array.from(select.querySelectorAll('option:checked')).map((option) => {
+ return option.value;
+ });
+ }, false);
+
+ document.body.addEventListener('input', () => {
+ result.onBubblingInput = Array.from(select.querySelectorAll('option:checked')).map((option) => {
+ return option.value;
+ });
+ }, false);
+
+ document.body.addEventListener('change', () => {
+ result.onBubblingChange = Array.from(select.querySelectorAll('option:checked')).map((option) => {
+ return option.value;
+ });
+ }, false);
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/textarea.html b/remote/test/puppeteer/test/assets/input/textarea.html
new file mode 100644
index 0000000000..66fdc40304
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/textarea.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Textarea test</title>
+ </head>
+ <body>
+ <textarea rows="5" cols="20"></textarea>
+ <script src='mouse-helper.js'></script>
+ <script>
+ globalThis.result = '';
+ globalThis.textarea = document.querySelector('textarea');
+ textarea.addEventListener('input', () => result = textarea.value, false);
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/touchscreen.html b/remote/test/puppeteer/test/assets/input/touchscreen.html
new file mode 100644
index 0000000000..76e31c97f9
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/touchscreen.html
@@ -0,0 +1,122 @@
+<!doctype html>
+<html>
+ <head>
+ <title>Touch test</title>
+ </head>
+
+ <body>
+ <style>
+ button {
+ box-sizing: border-box;
+ position: absolute;
+ left: 0;
+ top: 0;
+ width: 10px;
+ height: 10px;
+ padding: 0;
+ margin: 0;
+ }
+ </style>
+ <button>Click target</button>
+ <script>
+ var allEvents = [];
+ globalThis.addEventListener(
+ "touchstart",
+ (event) => {
+ allEvents.push({
+ type: "touchstart",
+ touches: [...event.changedTouches].map((touch) => [
+ touch.clientX,
+ touch.clientY,
+ touch.radiusX,
+ touch.radiusY,
+ ]),
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "touchmove",
+ (event) => {
+ allEvents.push({
+ type: "touchmove",
+ touches: [...event.changedTouches].map((touch) => [
+ touch.clientX,
+ touch.clientY,
+ touch.radiusX,
+ touch.radiusY,
+ ]),
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "touchend",
+ (event) => {
+ allEvents.push({
+ type: "touchend",
+ touches: [...event.changedTouches].map((touch) => [
+ touch.clientX,
+ touch.clientY,
+ touch.radiusX,
+ touch.radiusY,
+ ])
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "pointerdown",
+ (event) => {
+ allEvents.push({
+ type: "pointerdown",
+ x: event.x,
+ y: event.y,
+ width: event.width,
+ height: event.height,
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "pointermove",
+ (event) => {
+ allEvents.push({
+ type: "pointermove",
+ x: event.x,
+ y: event.y,
+ width: event.width,
+ height: event.height,
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "pointerup",
+ (event) => {
+ allEvents.push({
+ type: "pointerup",
+ x: event.x,
+ y: event.y,
+ width: event.width,
+ height: event.height,
+ });
+ },
+ true,
+ );
+ globalThis.addEventListener(
+ "click",
+ (event) => {
+ allEvents.push({
+ type: "click",
+ x: event.x,
+ y: event.y,
+ width: event.width,
+ height: event.height,
+ });
+ },
+ true,
+ );
+ </script>
+ </body>
+</html>
diff --git a/remote/test/puppeteer/test/assets/input/wheel.html b/remote/test/puppeteer/test/assets/input/wheel.html
new file mode 100644
index 0000000000..3d093a993e
--- /dev/null
+++ b/remote/test/puppeteer/test/assets/input/wheel.html
@@ -0,0 +1,43 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <style>
+ body {
+ min-height: 100vh;
+ margin: 0;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+
+ div {
+ width: 105px;
+ height: 105px;
+ background: #cdf;
+ padding: 5px;
+ }
+ </style>
+ <title>Element: wheel event - Scaling_an_element_via_the_wheel - code sample</title>
+ </head>
+ <body>
+ <div>Scale me with your mouse wheel.</div>
+ <script>
+ function zoom(event) {
+ event.preventDefault();
+
+ scale += event.deltaY * -0.01;
+
+ // Restrict scale
+ scale = Math.min(Math.max(.125, scale), 4);
+
+ // Apply scale transform
+ el.style.transform = `scale(${scale})`;
+ }
+
+ let scale = 1;
+ const el = document.querySelector('div');
+ el.onwheel = zoom;
+ </script>
+ </body>
+</html>