Update web-platform-tests to revision 78f764c05c229883e87ad135c7153051a66e2851

This commit is contained in:
WPT Sync Bot 2019-03-06 20:32:15 -05:00
parent 55347aa39f
commit bf84a079f9
1983 changed files with 58006 additions and 31437 deletions

View file

@ -21,7 +21,7 @@ img {
#image-container {
position: absolute;
top: 400%;
top: 10000px;
}
</style>
<body>
@ -58,4 +58,4 @@ img {
await img_auto.load_complete;
}, "Sanity-check: Verify that all images load after they are scrolled into view.");
</script>
</body>
</body>

View file

@ -16,7 +16,7 @@ iframe {
.spacer {
width: 100%;
height: 300%;
height: 10000px;
}
</style>
<div class="spacer"></div>

View file

@ -20,13 +20,13 @@ img {
#image-container {
position: absolute;
top: 400%;
top: 10000px;
}
</style>
<body>
<p>Image inserted further below.</p>
<div id="image-container">
<img id="off" lazyload="off" src="http://{{hosts[alt][www1]}}:{{ports[http][0]}}/feature-policy/experimental-features/resources/lazyload.png"></img>
<img id="off" load="eager" src="http://{{hosts[alt][www1]}}:{{ports[http][0]}}/feature-policy/experimental-features/resources/lazyload.png"></img>
</div>
<script>
var img = document.querySelector("img");
@ -40,6 +40,6 @@ img {
promise_test( async(t) => {
await window.load_complete;
assert_true(img.did_load, "Image should have loaded.");
}, "When feature is enabled, lazyload=OFF works as expected.");
}, "When feature is enabled, load=eager works as expected.");
</script>
</body>
</body>

View file

@ -16,7 +16,7 @@ iframe {
.spacer {
width: 100%;
height: 300%;
height: 10000px;
}
</style>
<div class="spacer"></div>
@ -31,12 +31,12 @@ iframe {
window.scrollTo(0, 0);
// Sanity-check: Make sure lazyload='on' works as intended.
// Sanity-check: Make sure load='lazy' works as intended.
promise_test(async(t) => {
// Add a frame with lazyload="on".
// Add a frame with load="lazy".
let frame_on = createIframe(document.body, {
id: "ON",
lazyload: "on",
load: "lazy",
src: `${cross_origin_url}?id=ON`
});
// Sanity-check: The frame is not visible.
@ -48,17 +48,17 @@ iframe {
await waitForMessageOrTimeout(t, "ON", load_timeout);
assert_equals(msg_or_timeout_attr_on,
expected_timeout_msg,
"With lazyload='on', the frame should not load.");
"With load='lazy', the frame should not load.");
}, "Sanity-check: Contents do not load immediately (no eager-loading) " +
"when the lazyload attribute is 'on' and frame is in viewport.");
"when the load attribute is 'lazy' and frame is in viewport.");
// When feature is enabled, a frame can turn off lazy loading by setting the
// attribute to 'off'.
promise_test(async(t) => {
// Add a frame with lazyload="off".
// Add a frame with load="eager".
let frame_off = createIframe(document.body, {
id: "OFF",
lazyload: "off",
load: "eager",
src: `${cross_origin_url}?id=OFF`
});
// Sanity-check: The frame is not visible.
@ -71,7 +71,7 @@ iframe {
assert_equals(msg_or_timeout_attr_off,
expected_load_msg,
"With lazyload='off', the frame should load.");
"With load='eager', the frame should load.");
}, "When 'lazyload' feature is enabled, a frame can avoid lazyloading by " +
"setting 'lazyload' attribute to 'off'");
"setting 'load' attribute to 'eager'");
</script>

View file

@ -19,7 +19,7 @@ img {
#image-container {
position: absolute;
top: 400%;
top: 10000px;
}
</style>
<body>
@ -45,4 +45,4 @@ img {
}, "Verify 'lazyload' attribute state 'on' works as expected: image loads only when in " +
"viewport.");
</script>
</body>
</body>

View file

@ -0,0 +1,63 @@
<!DOCTYPE html>
<head>
<meta name="timeout" content="long">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<div id="iframe-embedder"></div>
<script src="./resources/helper.js"></script>
<script>
'use strict';
// TODO(ekaramad): Add cross-origin examples both for the <iframe> and the
// opened window.
const iframe_src = "/feature-policy/feature-policy-for-sandbox/resources/window_opener.html";
const window_url_main = "/feature-policy/feature-policy-for-sandbox/resources/opened_window.html";
promise_test( async () => {
for (const feature of features_that_propagate) {
const iframe = await add_iframe(
{src: iframe_src, allow: `${feature} 'none'`});
iframe.contentWindow.postMessage({type: "feature", feature: feature}, "*");
const iframe_state = await feature_update(feature);
assert_false(iframe_state, `'${feature}' is not disabled in <iframe>.'`);
iframe.contentWindow.postMessage({
type: "open_window",
url: `${window_url_main}?${feature}`
}, "*");
const window_state = await feature_update(feature);
assert_false(window_state,
`'${feature}' is not disabled in new window.`);
const did_close = await close_aux_window(iframe);
assert_true(did_close);
iframe.parentElement.removeChild(iframe);
}
}, "Verify feature policies are inherited by the auxiliary browsing context " +
"if opened from a non-sandboxed same-origin <iframe>.");
promise_test( async() => {
for (const feature of features_that_propagate) {
const iframe = await add_iframe({
src: iframe_src,
allow: `${feature} 'none'`,
sandbox: "allow-scripts allow-popups allow-popups-to-escape-sandbox"});
iframe.contentWindow.postMessage({type: "feature", feature: feature}, "*");
const iframe_state = await feature_update(feature);
assert_false(iframe_state,
`'${feature}' is not disabled in <iframe>.'`);
iframe.contentWindow.postMessage({
type: "open_window",
url: `${window_url_main}?${feature}`
}, "*");
const window_state = await feature_update(feature);
assert_true(window_state, `'${feature}' is disabled.`);
const did_close = await close_aux_window(iframe);
assert_true(did_close);
iframe.parentElement.removeChild(iframe);
}
}, "Verify feature policies are NOT inherited by the auxiliary browsing " +
"context if opened from a sandboxed same-origin <iframe> which allows " +
"popups to escape sandbox.");
</script>
</body>

View file

@ -0,0 +1,88 @@
// The list of all feature policies including the sandbox policies.
const all_features = document.featurePolicy.allowedFeatures();
// 'popups' is nonsensical in this test and it is not possible to test 'scripts'
// within this test model.
const ignore_features = ["popups", "scripts"];
// TODO(ekaramad): Figure out different inheritance requirements for different
// policies.
// Features which will be tested for propagation to auxiliary contexts.
const features_that_propagate = all_features.filter(
(feature) => !ignore_features.includes(feature));
var last_feature_message = null;
var on_new_feature_callback = null;
var on_close_window_callback = null;
function add_iframe(options) {
assert_true("src" in options, "invalid options");
var iframe = document.createElement("iframe");
iframe.src = options.src;
if ("allow" in options)
iframe.setAttribute("allow", options.allow);
if ("sandbox" in options)
iframe.setAttribute("sandbox", options.sandbox);
return new Promise( (r) => {
iframe.addEventListener("load", () => r(iframe));
document.getElementById("iframe-embedder").appendChild(iframe);
});
}
// Returns a promise which is resolved with the next/already received message
// with feature update for |feature|. The resolved value is the state of the
// feature |feature|.
function feature_update(feature) {
function reset_for_next_update() {
return new Promise((r) => {
const state = last_feature_message.state;
last_feature_message = null;
r(state);
});
}
if (last_feature_message && last_feature_message.feature === feature)
return reset_for_next_update();
return new Promise((r) => on_new_feature_callback = r)
.then(() => reset_for_next_update());
}
function close_aux_window(iframe) {
return new Promise( (r) => {
on_close_window_callback = r;
iframe.contentWindow.postMessage({type: "close_window"}, "*");
});
}
function on_message(e) {
var msg = e.data;
assert_true("type" in msg);
switch (msg.type) {
case "feature":
on_feature_msg(msg);
break;
case "close_window":
on_close_window_msg(msg);
break;
}
}
function on_feature_msg(msg) {
assert_true("feature" in msg);
assert_true("state" in msg);
last_feature_message = msg
if (on_new_feature_callback) {
on_new_feature_callback();
on_new_feature_callback = null;
}
}
function on_close_window_msg(msg) {
if (on_close_window_callback) {
on_close_window_callback(msg.result);
on_close_window_callback = null;
}
}
window.addEventListener("message", on_message);

View file

@ -0,0 +1,5 @@
<!doctype html>
<title>This page verifies the status of the feature provided in search query.</title>
<body>
<script async src="/feature-policy/feature-policy-for-sandbox/resources/opened_window.js"></script>
</body>

View file

@ -0,0 +1,7 @@
var feature = window.location.search.substr(1);
var state = document.featurePolicy.allowsFeature(feature);
// TODO(ekaramad): We might at some point choose a different propagation
// strategy with rel=noopener. This test should adapt accordingly (perhaps use
// broadcast channels).
window.opener.parent.postMessage(
{type: "feature", feature: feature, state: state}, "*");

View file

@ -0,0 +1,5 @@
<!doctype html>
<title>Helper document for cross-domain messaging.</title>
<body>
<script async src="/feature-policy/feature-policy-for-sandbox/resources/window_opener.js"></script>
</body>

View file

@ -0,0 +1,21 @@
var auxiliary_context = null;
window.addEventListener("message", (e) => {
var msg = e.data;
switch (msg.type) {
case "feature":
var state = document.featurePolicy.allowsFeature(msg.feature);
e.source.postMessage({
type: "feature",
feature: msg.feature,
state: state}, "*");
break;
case "open_window":
auxiliary_context = window.open(msg.url);
break;
case "close_window":
if (auxiliary_context)
auxiliary_context.close();
e.source.postMessage(
{type: "close_window", result: auxiliary_context != null}, "*");
}
});

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
</head>
<body>
<script>
var image = new Image();
image.src = "./unoptimized-image.jpg";
var check_report_format = (reports, observer) => {
let report = reports[0];
assert_equals(report.type, "feature-policy-violation");
assert_equals(report.url, document.location.href);
assert_equals(report.body.featureId, "unoptimized-images");
assert_equals(report.body.disposition, "enforce");
};
async_test(t => {
new ReportingObserver(t.step_func_done(check_report_format),
{types: ['feature-policy-violation'], buffered: true}).observe();
}, "unoptimized-images Report Format");
</script>
</body>
</html>

View file

@ -0,0 +1 @@
Feature-Policy: unoptimized-images 'none'