Bug 1498667 [wpt PR 13484] - [Picture-in-Picture] Bail early for feature policy tests, a=testonly

Automatic update from web-platform-tests[Picture-in-Picture] Bail early for feature policy tests

Change-Id: I0186fd20fc1d1e763208f5488917b65d24fa3e00
Reviewed-on: https://chromium-review.googlesource.com/c/1278786
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#599253}

--

wpt-commits: 433fc8986e3dbad91f7d3e3fe0271488ba146504
wpt-pr: 13484
This commit is contained in:
François Beaufort 2018-10-16 09:58:35 +00:00 коммит произвёл James Graham
Родитель ee392f1c3d
Коммит 7655735b19
7 изменённых файлов: 29 добавлений и 17 удалений

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

@ -16,13 +16,13 @@
relative_path;
const header = 'Feature-Policy allow="picture-in-picture"';
async_test(t => {
async_pip_test(t => {
test_feature_availability(
'picture-in-picture', t, same_origin_src,
expect_feature_available_default, 'picture-in-picture');
}, header + ' allows same-origin navigation in an iframe.');
async_test(t => {
async_pip_test(t => {
test_feature_availability(
'picture-in-picture', t, cross_origin_src,
expect_feature_unavailable_default, 'picture-in-picture');

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

@ -15,13 +15,13 @@
const feature_name = 'Feature policy "picture-in-picture"';
const header = 'allow="picture-in-picture" attribute';
async_test(t => {
async_pip_test(t => {
test_feature_availability(
'picture-in-picture', t, same_origin_src,
expect_feature_available_default, 'picture-in-picture');
}, feature_name + ' can be enabled in same-origin iframe using ' + header);
async_test(t => {
async_pip_test(t => {
test_feature_availability(
'picture-in-picture', t, cross_origin_src,
expect_feature_available_default, 'picture-in-picture');

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

@ -14,18 +14,18 @@
same_origin_src;
const header = 'Feature-Policy header: picture-in-picture *';
async_test(t => {
async_pip_test(t => {
isPictureInPictureAllowed().then(t.step_func_done((result) => {
assert_true(result);
}));
}, header + ' allows the top-level document.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, same_origin_src,
expect_feature_available_default);
}, header + ' allows same-origin iframes.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, cross_origin_src,
expect_feature_available_default);
}, header + ' allows cross-origin iframes.');

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

@ -14,18 +14,18 @@
same_origin_src;
const header = 'Default "picture-in-picture" feature policy [*]';
async_test(t => {
async_pip_test(t => {
isPictureInPictureAllowed().then(t.step_func_done((result) => {
assert_true(result);
}));
}, header + ' allows the top-level document.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, same_origin_src,
expect_feature_available_default);
}, header + ' allows same-origin iframes.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, cross_origin_src,
expect_feature_available_default);
}, header + ' allows cross-origin iframes.');

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

@ -14,18 +14,18 @@
same_origin_src;
const header = 'Feature-Policy header: picture-in-picture "none"';
async_test(t => {
async_pip_test(t => {
isPictureInPictureAllowed().then(t.step_func_done((result) => {
assert_false(result);
}));
}, header + ' disallows the top-level document.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, same_origin_src,
expect_feature_unavailable_default);
}, header + ' disallows same-origin iframes.');
async_test(t => {
async_pip_test(t => {
test_feature_availability('picture-in-picture', t, cross_origin_src,
expect_feature_unavailable_default);
}, header + ' disallows cross-origin iframes.');

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

@ -6,6 +6,7 @@
<script src='/resources/testharnessreport.js'></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src='../resources/picture-in-picture.js'></script>
</head>
<body>
<script>
@ -28,7 +29,7 @@ const loadVideo = () => new Promise(resolve => {
}, { once: true });
});
promise_test(async (t) => {
promise_pip_test(async (t) => {
const report = new Promise(resolve => {
new ReportingObserver((reports, observer) => resolve([reports, observer]),
{types: ['feature-policy']}).observe();

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

@ -1,7 +1,18 @@
function isPictureInPictureAllowed() {
if (!('pictureInPictureEnabled' in document))
return Promise.resolve(false);
function async_pip_test(func, name) {
async_test(t => {
assert_true('pictureInPictureEnabled' in document, 'Picture-in-Picture API is available');
func(t);
}, name);
}
function promise_pip_test(func, name) {
promise_test(async t => {
assert_true('pictureInPictureEnabled' in document, 'Picture-in-Picture API is available');
return func(t);
}, name);
}
function isPictureInPictureAllowed() {
return new Promise(resolve => {
let video = document.createElement('video');
video.src = getVideoURI('/media/movie_5');