diff --git a/testing/web-platform/tests/interfaces/virtual-keyboard.tentative.idl b/testing/web-platform/tests/interfaces/virtual-keyboard.tentative.idl new file mode 100644 index 000000000000..2991d242e6fc --- /dev/null +++ b/testing/web-platform/tests/interfaces/virtual-keyboard.tentative.idl @@ -0,0 +1,15 @@ +// Explainers: +// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardPolicy/explainer.md +// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardAPI/explainer.md + +partial interface Navigator { + [SecureContext, SameObject] readonly attribute VirtualKeyboard virtualKeyboard; +}; + +[SecureContext, Exposed=Window] interface VirtualKeyboard : EventTarget { + undefined show(); + undefined hide(); + readonly attribute DOMRect boundingRect; + attribute boolean overlaysContent; + attribute EventHandler ongeometrychange; +}; diff --git a/testing/web-platform/tests/virtual-keyboard/META.yml b/testing/web-platform/tests/virtual-keyboard/META.yml new file mode 100644 index 000000000000..eaefdd02a1e7 --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/META.yml @@ -0,0 +1,3 @@ +spec: https://github.com/w3c/editing/pull/309 +suggested_reviewers: + - snianu diff --git a/testing/web-platform/tests/virtual-keyboard/README.md b/testing/web-platform/tests/virtual-keyboard/README.md new file mode 100644 index 000000000000..9feb3204d10c --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/README.md @@ -0,0 +1,4 @@ +# VirtualKeyboard +This directory contains (tentative) tests for the [VirtualKeyboard policy](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardPolicy/explainer.md) & [VirtualKeyboard APIs](https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/main/VirtualKeyboardAPI/explainer.md) proposals. + +**This suite runs the tests with** `--enable-features=VirtualKeyboard` \ No newline at end of file diff --git a/testing/web-platform/tests/virtual-keyboard/idlharness.https.window.js b/testing/web-platform/tests/virtual-keyboard/idlharness.https.window.js new file mode 100644 index 000000000000..8a40e68575f0 --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/idlharness.https.window.js @@ -0,0 +1,17 @@ +// META: timeout=long +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +'use strict'; + +idl_test( + ['virtual-keyboard.tentative'], + ['html', 'dom'], + idl_array => { + idl_array.add_objects({ + Navigator: ['navigator'], + VirtualKeyboard: ['navigator.virtualKeyboard'], + GeometryChangeEvent: ['new GeometryChangeEvent("x")'], + }); + } +); diff --git a/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-css-env-manual.html b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-css-env-manual.html new file mode 100644 index 000000000000..fcddfc945362 --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-css-env-manual.html @@ -0,0 +1,114 @@ + + +This tests the new virtualKeyboard CSS environment variables + + + + + + + + + +

VirtualKeyboard: Virtual Keyboard show/hide Fires Event & updates CSS env variables

+

+ Test Description: This test checks that a geometry change event is + fired when show/hide APIs are called & also updates the CSS env variables for keyboard insets. + VK is only displayed on a touch device with tablet mode on or a mobile device where VK is the default + text input mechanism. +

+

THIS IS A MANUAL TEST

+
Manual policy show here.
+
Read-only region tap here.
+

+ +

+

+ +
+ + + diff --git a/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-policy.html b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-policy.html new file mode 100644 index 000000000000..67782020d3c8 --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-policy.html @@ -0,0 +1,60 @@ + + +This tests the new virtualKeyboardPolicy attribute + + + + +
+
+
+
+
+ + diff --git a/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-show-hide-manual.html b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-show-hide-manual.html new file mode 100644 index 000000000000..60e7a07affed --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-show-hide-manual.html @@ -0,0 +1,128 @@ + + +This tests the new virtualKeyboard show/hide APIs + + + + + + + + +

VirtualKeyboard: Virtual Keyboard show/hide Fires Event

+

+ Test Description: This test checks that a geometry change event is + fired when show/hide APIs are called. VK is only displayed on a touch + device with tablet mode on or a mobile device where VK is the default + text input mechanism. +

+

THIS IS A MANUAL TEST

+
Auto policy tap here.
+
Manual policy show here.
+
Manual policy hide here.
+
Read-only region tap here.
+

+ +

+

+ +
+ + + diff --git a/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-type.html b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-type.html new file mode 100644 index 000000000000..1ba71f501beb --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/virtual-keyboard-type.html @@ -0,0 +1,31 @@ + + + + VirtualKeyboard: navigator.virtualKeyboard type + + + + + + +

VirtualKeyboard: navigator.virtualKeyboard type

+

Test Description: This test checks that navigator.virtualKeyboard is an object of type VirtualKeyboard.

+ +
+

navigator.virtualKeyboard is of type: .

+
+
+ + diff --git a/testing/web-platform/tests/virtual-keyboard/vk_support.js b/testing/web-platform/tests/virtual-keyboard/vk_support.js new file mode 100644 index 000000000000..e40216dd4436 --- /dev/null +++ b/testing/web-platform/tests/virtual-keyboard/vk_support.js @@ -0,0 +1,71 @@ +// Ends a manual test. Must be called before any async tests are started. +function skipManualTest() { + test(function() { assert_true(false); }, "Manual Test Skipped"); + done(); +} + +var stepInstructions = []; +var testNames = []; +var stepFunctions = []; +var steps; +var curStep = 0; + +// Adds a manual test step to the test. A test will add a series of steps, +// along with instructions. Once all the tests steps are added, the test can +// be run by continually running the nextStep() function. All manual test steps +// must be added before calling nextStep. +// +// |func| A function to be executed at the given step. This function can include +// testharness assertions if |testName| is provided. If this is the last +// step, the |done()| function (used for manual testharness.js tests) +// will be called after |func| is executed. +// |testName| If provided, the |func| will be wrapped in a testharness.js +// async_test with this name. If null, |func| will be executed as a +// free function. +// |instructions| The text to display to the user. Note, these are shown after +// step is executed so these should be instructions to setup the +// checks in the next step. +function addManualTestStep(func, testName, instructions) { + stepFunctions.push(func); + testNames.push(testName); + stepInstructions.push(instructions); +} + +// Runs the next step of the test. This must be called only after all test steps +// have been added using |addManualTestStep|. +// +// |callbackFunc| If provided, will be called with a single argument being the +// instruction string for the current step. Use this to update +// any necessary UI. +function nextStep(callbackFunc) { + if (curStep == 0) + _startManualTest(); + + if (typeof(callbackFunc) === 'function') + callbackFunc(stepInstructions[curStep]); + + steps[curStep](); + curStep++; +} + +function _startManualTest() { + steps = []; + for (let i = 0; i < stepFunctions.length; ++i) { + var stepFunc = stepFunctions[i]; + var testName = testNames[i]; + if (testName) { + steps.push(async_test(testName).step_func(function() { + stepFunctions[i](); + this.done(); + if (i == stepFunctions.length - 1) + done(); + })); + } else { + steps.push(function() { + stepFunctions[i](); + if (i == stepFunctions.length - 1) + done(); + }); + } + } +}