Bug 1464929 [wpt PR 11207] - Support promises for fullscreen API., a=testonly

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
This commit is contained in:
Dave Tapuska 2018-06-06 17:11:54 +00:00 коммит произвёл James Graham
Родитель 7e120afe76
Коммит 0d913dabc0
7 изменённых файлов: 123 добавлений и 93 удалений

Просмотреть файл

@ -11359,6 +11359,12 @@
{}
]
],
"fullscreen/api/promises-resolve-manual.html": [
[
"/fullscreen/api/promises-resolve-manual.html",
{}
]
],
"fullscreen/model/move-to-fullscreen-iframe-manual.html": [
[
"/fullscreen/model/move-to-fullscreen-iframe-manual.html",
@ -265976,6 +265982,11 @@
{}
]
],
"css/tools/README.md": [
[
{}
]
],
"css/tools/apiclient/.gitignore": [
[
{}
@ -266036,51 +266047,6 @@
{}
]
],
"css/tools/html2xhtml.py": [
[
{}
]
],
"css/tools/list-all.pl": [
[
{}
]
],
"css/tools/list-all.sh": [
[
{}
]
],
"css/tools/make-html.py": [
[
{}
]
],
"css/tools/supportprop.py": [
[
{}
]
],
"css/tools/templates/filename-list.tmpl": [
[
{}
]
],
"css/tools/travis/LICENSE": [
[
{}
]
],
"css/tools/travis/build.py": [
[
{}
]
],
"css/tools/travis/vcs.py": [
[
{}
]
],
"css/tools/w3ctestlib/.hgignore": [
[
{}
@ -330828,6 +330794,12 @@
{}
]
],
"fullscreen/api/promises-reject.html": [
[
"/fullscreen/api/promises-reject.html",
{}
]
],
"fullscreen/interfaces.html": [
[
"/fullscreen/interfaces.html",
@ -398650,7 +398622,7 @@
"support"
],
"./.gitmodules": [
"525f7d93f00f11086aabc1f652cf06623e21986c",
"6a203e28d43909d7513daf8761281b351d2b2bd7",
"support"
],
"./.pyup.yml": [
@ -489746,7 +489718,7 @@
"reftest"
],
"css/build-css-testsuites.sh": [
"0f1d955402449b61d134265ea5962d6ed93836f4",
"f08c6940dff13aad1b6c5fc81c08abcaa8aafc67",
"support"
],
"css/compositing/Blending_in_a_group_with_filter-ref.html": [
@ -544589,6 +544561,10 @@
"7301f0ec4d66b71a92818aa3d532c5eca718f677",
"support"
],
"css/tools/README.md": [
"17dc12660a62726b5975e125cefb1cc42b007b6f",
"support"
],
"css/tools/apiclient/.gitignore": [
"4f8c72d787595386529108512329027d424dad47",
"support"
@ -544637,42 +544613,6 @@
"9dc0b6f869b328886b153eee2dd0b0053cd712e2",
"support"
],
"css/tools/html2xhtml.py": [
"abaf4dec00fa3b29f556f35700410775acd63395",
"support"
],
"css/tools/list-all.pl": [
"27670ddc5a347fa2d0608483875294f8f4957b07",
"support"
],
"css/tools/list-all.sh": [
"040b805bb924cd18077cc07f7a449067d7fc0cd7",
"support"
],
"css/tools/make-html.py": [
"3fb558bb57627987e143d415d8677508a2dfbaf2",
"support"
],
"css/tools/supportprop.py": [
"92973da4c183e497ef7b4a888ca929216073f9ea",
"support"
],
"css/tools/templates/filename-list.tmpl": [
"ddcb87e03b20a95d9b10ad00bbb1228e3fd5a9ba",
"support"
],
"css/tools/travis/LICENSE": [
"0ea78bfe20b327310471cc22618f7c921c6e0481",
"support"
],
"css/tools/travis/build.py": [
"470c482e0463459a3d0b48af0107a2429a281db8",
"support"
],
"css/tools/travis/vcs.py": [
"715959f81edaae4a2ac5ad6a16dbb045c199074f",
"support"
],
"css/tools/w3ctestlib/.hgignore": [
"68a4744eda8cfd5d6313a91e1468cffacf37b61f",
"support"
@ -544694,7 +544634,7 @@
"support"
],
"css/tools/w3ctestlib/Sources.py": [
"36436dff53c614783778a373223c07be4f70fc1d",
"1541268bf0bec6fcbf1c9e5ce60c31878f29314e",
"support"
],
"css/tools/w3ctestlib/Suite.py": [
@ -544750,7 +544690,7 @@
"support"
],
"css/tools/w3ctestlib/templates/index.content.tmpl": [
"c9195c8e9ed930d37c3a64f65c0b43f1cb3d6fc0",
"cf6c10649767fbd6cd52672b14f1176537499c44",
"support"
],
"css/tools/w3ctestlib/templates/index.htm.tmpl": [
@ -560686,7 +560626,7 @@
"manual"
],
"fullscreen/api/document-onfullscreenerror.html": [
"ed8836f302fffdaa407bf9bf7799effa17fb6823",
"1dd69713aaa8030892e68cfb0fec2fccb8863723",
"testharness"
],
"fullscreen/api/element-ready-check-allowed-cross-origin-manual.sub.html": [
@ -560758,7 +560698,7 @@
"manual"
],
"fullscreen/api/element-request-fullscreen-not-allowed.html": [
"8991e8df530fa7c24a9e084f2ab17fa9c70fb120",
"5eac634c56810200d4c6a8b1c3c6f547ba1e7dc9",
"testharness"
],
"fullscreen/api/element-request-fullscreen-null-ns-manual.html": [
@ -560778,7 +560718,7 @@
"manual"
],
"fullscreen/api/element-request-fullscreen-timing-manual.html": [
"4ecd76a2ef773172d45f656f52a7358be2a4568d",
"48df66c401edcba47d1336313833a24d5e3d211d",
"manual"
],
"fullscreen/api/element-request-fullscreen-top-manual.html": [
@ -560801,6 +560741,14 @@
"9d9bec938f185b2461da4d00a5683ad5d07ee577",
"testharness"
],
"fullscreen/api/promises-reject.html": [
"2bc121b4bc0a397f2f25c5fca1aa32fa8727b776",
"testharness"
],
"fullscreen/api/promises-resolve-manual.html": [
"ec9276eb2b2ab279a84aa06a644b4333e46e970d",
"manual"
],
"fullscreen/api/resources/attempt-fullscreen.html": [
"33e277b3f06677f14eed442ecce76b408e7e006e",
"support"
@ -560858,7 +560806,7 @@
"manual"
],
"fullscreen/trusted-click.js": [
"e401e8e8bcd97446991398d6021a9bd712c923c5",
"069f4d40fbcb4e933d4f651d3220820836615660",
"support"
],
"gamepad/OWNERS": [

Просмотреть файл

@ -7,12 +7,23 @@
async_test(function(t)
{
var sync = true;
var promise_executed = false;
assert_equals(document.onfullscreenerror, null, "initial onfullscreenerror");
document.onfullscreenerror = t.step_func_done(function(event) {
assert_true(promise_executed);
assert_false(sync);
});
var e = document.createElement('span');
e.requestFullscreen();
var promise = e.requestFullscreen();
if (promise) {
promise.catch(()=> {
assert_false(sync);
promise_executed = true;
});
} else {
// If promises aren't supported just treat it as already done.
promise_executed = true;
}
sync = false;
});
</script>

Просмотреть файл

@ -6,14 +6,24 @@
<script>
async_test(t => {
const div = document.querySelector("div");
var promise_executed = false;
document.addEventListener("fullscreenerror", t.step_func_done(event => {
assert_equals(event.target, div, "event.target");
assert_true(event.bubbles, "event.bubbles");
assert_false(event.cancelable, "event.cancelable");
assert_true(event.composed, "event.composed");
assert_true(promise_executed, "promise executed");
}));
div.requestFullscreen();
var promise = div.requestFullscreen();
if (promise) {
promise.catch(()=> {
promise_executed = true;
});
} else {
// If promises aren't supported just treat it as already done.
promise_executed = true;
}
});
</script>

Просмотреть файл

@ -28,11 +28,19 @@ async_test(t => {
}, 'Timing of fullscreenchange and resize events');
async_test(t => {
document.createElement('a').requestFullscreen();
var promise = document.createElement('a').requestFullscreen();
var promise_executed = false;
if (promise) {
promise.catch(()=>{promise_executed = true; });
} else {
// if promises aren't supported treat it as executed.
promise_executed = true;
}
// If fullscreenerror is an animation frame event, then animation frame
// callbacks should be run after it is fired, before the timer callback.
document.onfullscreenerror = t.step_func(() => {
assert_true(promise_executed, "promise executed");
step_timeout(t.unreached_func('timer callback'));
requestAnimationFrame(t.step_func_done());
});

Просмотреть файл

@ -0,0 +1,17 @@
<!DOCTYPE html>
<title>Promises#reject</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>
async_test(function(t)
{
var e = document.createElement('span');
e.requestFullscreen().catch(t.step_func_done());
});
async_test(function(t)
{
var e = document.createElement('span');
document.exitFullscreen().catch(t.step_func_done());
});
</script>

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<title>Promises#resolve</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../trusted-click.js"></script>
<div id="log"></div>
<script>
async_test(function(t)
{
var div = document.querySelector("div");
trusted_request_with_promise(t, div, document.body,
() => {
assert_equals(document.fullscreenElement, div, "fullscreenElement before exitFullscreen()");
document.exitFullscreen().then(()=> {
assert_equals(document.fullscreenElement, null, "fullscreenElement after exiting fullscreen");
t.done();
});
assert_equals(document.fullscreenElement, div, "fullscreenElement after exitFullscreen()");
}, t.unreached_func("Request fullscreen failed"));
});
</script>

Просмотреть файл

@ -19,5 +19,20 @@ function trusted_click(test, callback, container)
// Invokes element.requestFullscreen() from a trusted click.
function trusted_request(test, element, container)
{
trusted_click(test, () => element.requestFullscreen(), container || element.parentNode);
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);
}