mirror of
https://github.com/servo/servo.git
synced 2025-08-29 17:18:23 +01:00
Update web-platform-tests to revision 60220357131c65146444da1f54624d5b54d0975d
This commit is contained in:
parent
c45192614c
commit
775b784f79
2144 changed files with 58115 additions and 29658 deletions
|
@ -1,5 +1,6 @@
|
|||
(function() {
|
||||
"use strict";
|
||||
var idCounter = 0;
|
||||
|
||||
function getInViewCenterPoint(rect) {
|
||||
var left = Math.max(0, rect.left);
|
||||
|
@ -46,6 +47,41 @@
|
|||
* @namespace
|
||||
*/
|
||||
window.test_driver = {
|
||||
/**
|
||||
* Trigger user interaction in order to grant additional privileges to
|
||||
* a provided function.
|
||||
*
|
||||
* https://html.spec.whatwg.org/#triggered-by-user-activation
|
||||
*
|
||||
* @param {String} intent - a description of the action which much be
|
||||
* triggered by user interaction
|
||||
* @param {Function} action - code requiring escalated privileges
|
||||
*
|
||||
* @returns {Promise} fulfilled following user interaction and
|
||||
* execution of the provided `action` function;
|
||||
* rejected if interaction fails or the provided
|
||||
* function throws an error
|
||||
*/
|
||||
bless: function(intent, action) {
|
||||
var button = document.createElement("button");
|
||||
button.innerHTML = "This test requires user interaction.<br />" +
|
||||
"Please click here to allow " + intent + ".";
|
||||
button.id = "wpt-test-driver-bless-" + (idCounter += 1);
|
||||
document.body.appendChild(button);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
button.addEventListener("click", resolve);
|
||||
|
||||
test_driver.click(button).catch(reject);
|
||||
}).then(function() {
|
||||
button.remove();
|
||||
|
||||
if (typeof action === "function") {
|
||||
return action();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers a user-initiated click
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue