mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-09 21:00:42 +02:00
Automatic update from web-platform-testsSupport promises for fullscreen API. Add ability to store the promises in the pending requests and exits. Adjust tests to ensure they work correctly with promises. BUG=383813 Change-Id: I81e4780d5ea25b3a1ac7fef54b1fbc9c0d31897a Reviewed-on: https://chromium-review.googlesource.com/1075711 Commit-Queue: Dave Tapuska <dtapuska@chromium.org> Reviewed-by: Philip Jägenstedt <foolip@chromium.org> Cr-Commit-Position: refs/heads/master@{#562946} -- wpt-commits: 0fae4aa0c51c6193ef1b2b74a61352b832d95cfa wpt-pr: 11207
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
// Invokes callback from a trusted click event, to satisfy
|
|
// https://html.spec.whatwg.org/#triggered-by-user-activation
|
|
function trusted_click(test, callback, container)
|
|
{
|
|
var document = container.ownerDocument;
|
|
var button = document.createElement("button");
|
|
button.textContent = "click to continue test";
|
|
button.style.display = "block";
|
|
button.style.fontSize = "20px";
|
|
button.style.padding = "10px";
|
|
button.onclick = test.step_func(function()
|
|
{
|
|
callback();
|
|
container.removeChild(button);
|
|
});
|
|
container.appendChild(button);
|
|
}
|
|
|
|
// Invokes element.requestFullscreen() from a trusted click.
|
|
function trusted_request(test, element, container)
|
|
{
|
|
trusted_click(test, () => {
|
|
var promise = element.requestFullscreen();
|
|
if (promise) {
|
|
// Keep the promise resolution silent. Otherwise unhandledrejection
|
|
// may fire for the failure test cases.
|
|
promise.then(() => {}, () => {});
|
|
}
|
|
}, container || element.parentNode);
|
|
}
|
|
|
|
// Invokes element.requestFullscreen() from a trusted click.
|
|
function trusted_request_with_promise(test, element, container, resolve, reject)
|
|
{
|
|
trusted_click(test, () => {
|
|
element.requestFullscreen().then(resolve, reject);
|
|
}, container || element.parentNode);
|
|
}
|