Update web-platform-tests to revision e87f38097902e16348d4e17f4fe3bc2d0112bff1

This commit is contained in:
WPT Sync Bot 2018-03-17 21:12:30 -04:00
parent 2f8fa32e91
commit db5631a086
381 changed files with 11610 additions and 4232 deletions

View file

@ -383,3 +383,33 @@ function test_subframe_header_policy(
});
}, test_name);
}
// This function tests that frame policy allows a given feature correctly. A
// feature is allowed in a frame either through inherited policy or specified
// by iframe allow attribute.
// Arguments:
// feature: feature name.
// src: the URL to load in the frame.
// test_expect: boolean value of whether the feature should be allowed.
// allow: optional, the allow attribute (container policy) of the iframe.
// allowfullscreen: optional, boolean value of allowfullscreen attribute.
function test_frame_policy(
feature, src, test_expect, allow, allowfullscreen) {
let frame = document.createElement('iframe');
document.body.appendChild(frame);
// frame_policy should be dynamically updated as allow and allowfullscreen is
// updated.
var frame_policy = frame.policy;
if (typeof allow !== 'undefined') {
frame.setAttribute('allow', allow);
}
if (!!allowfullscreen) {
frame.setAttribute('allowfullscreen', true);
}
frame.src = src;
if (test_expect) {
assert_true(frame_policy.allowedFeatures().includes(feature));
} else {
assert_false(frame_policy.allowedFeatures().includes(feature));
}
}