mirror of
https://github.com/servo/servo.git
synced 2025-08-15 02:15:33 +01:00
Update web-platform-tests to revision 21461a83c51b72bcff82476c1b79a26a194e7bab
This commit is contained in:
parent
ea206034ad
commit
f96f9a1b78
61 changed files with 1372 additions and 376 deletions
|
@ -199,25 +199,68 @@
|
|||
|
||||
window.test_driver_internal = {
|
||||
/**
|
||||
* Triggers a user-initiated click
|
||||
* This flag should be set to `true` by any code which implements the
|
||||
* internal methods defined below for automation purposes. Doing so
|
||||
* allows the library to signal failure immediately when an automated
|
||||
* implementation of one of the methods is not available.
|
||||
*/
|
||||
in_automation: false,
|
||||
|
||||
/**
|
||||
* Waits for a user-initiated click
|
||||
*
|
||||
* @param {Element} element - element to be clicked
|
||||
* @param {{x: number, y: number} coords - viewport coordinates to click at
|
||||
* @returns {Promise} fulfilled after click occurs or rejected if click fails
|
||||
* @returns {Promise} fulfilled after click occurs
|
||||
*/
|
||||
click: function(element, coords) {
|
||||
return Promise.reject(new Error("unimplemented"));
|
||||
if (this.in_automation) {
|
||||
return Promise.reject(new Error('Not implemented'));
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
element.addEventListener("click", resolve);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers a user-initiated click
|
||||
* Waits for an element to receive a series of key presses
|
||||
*
|
||||
* @param {Element} element - element to be clicked
|
||||
* @param {String} keys - keys to send to the element
|
||||
* @returns {Promise} fulfilled after keys are sent or rejected if click fails
|
||||
* @param {Element} element - element which should receve key presses
|
||||
* @param {String} keys - keys to expect
|
||||
* @returns {Promise} fulfilled after keys are received or rejected if
|
||||
* an incorrect key sequence is received
|
||||
*/
|
||||
send_keys: function(element, keys) {
|
||||
return Promise.reject(new Error("unimplemented"));
|
||||
if (this.in_automation) {
|
||||
return Promise.reject(new Error('Not implemented'));
|
||||
}
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
var seen = "";
|
||||
|
||||
function remove() {
|
||||
element.removeEventListener("keydown", onKeyDown);
|
||||
}
|
||||
|
||||
function onKeyDown(event) {
|
||||
if (event.key.length > 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
seen += event.key;
|
||||
|
||||
if (keys.indexOf(seen) !== 0) {
|
||||
reject(new Error("Unexpected key sequence: " + seen));
|
||||
remove();
|
||||
} else if (seen === keys) {
|
||||
resolve();
|
||||
remove();
|
||||
}
|
||||
}
|
||||
|
||||
element.addEventListener("keydown", onKeyDown);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue