Revision 9b9293f0a667ca23ded04060894c2ce9e4a3e19c authored by Brian Birtles on 15 February 2018, 11:42:52 UTC, committed by moz-wptsync-bot on 15 February 2018, 11:42:52 UTC
These tests test the behavior introduced in the following changesets to the Web Animations specification: 1. https://github.com/w3c/csswg-drafts/commit/5af5e276badf4df0271bcfa0b8e7837fff24133a 2. https://github.com/w3c/csswg-drafts/commit/673f6fc1269829743c707c53dcb04092f958de35 which can be viewed as a merged diff at: https://gist.github.com/birtles/d147eb2e0e2d4d37fadf217abd709411 See the following spec issues: 1. https://github.com/w3c/csswg-drafts/issues/2059 2. https://github.com/w3c/csswg-drafts/issues/2266 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1436659 gecko-commit: 7465cb110ae5ec2e2ca73182caf5293f0efc8fd5 gecko-integration-branch: central gecko-reviewers: hiro
1 parent eb7491d
generic-sensor-feature-policy-test.sub.js
const feature_policies = {
"AmbientLightSensor" : ["ambient-light-sensor"],
"Accelerometer" : ["accelerometer"],
"LinearAccelerationSensor" : ["accelerometer"],
"GravitySensor" : ["accelerometer"],
"Gyroscope" : ["gyroscope"],
"GeolocationSensor" : ["geolocation"],
"Magnetometer" : ["magnetometer"],
"UncalibratedMagnetometer" : ["magnetometer"],
"AbsoluteOrientationSensor" : ["accelerometer", "gyroscope", "magnetometer"],
"RelativeOrientationSensor" : ["accelerometer", "gyroscope"]
};
const same_origin_src =
"/feature-policy/resources/feature-policy-generic-sensor.html#";
const cross_origin_src =
"https://{{domains[www]}}:{{ports[https][0]}}" + same_origin_src;
const base_src = "/feature-policy/resources/redirect-on-load.html#";
function run_fp_tests_disabled(sensorType) {
const sensorName = sensorType.name;
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" 'none';") + " 'none'";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_throws("SecurityError", () => {new sensorType()});
}, `${sensorName}: ${header} disallows the top-level document.`);
async_test(t => {
test_feature_availability(
desc,
t,
same_origin_src + sensorName,
expect_feature_unavailable_default
);
}, `${sensorName}: ${header} disallows same-origin iframes.`);
async_test(t => {
test_feature_availability(
desc,
t,
cross_origin_src + sensorName,
expect_feature_unavailable_default
);
}, `${sensorName}: ${header} disallows cross-origin iframes.`);
}
function run_fp_tests_enabled(sensorType) {
const sensorName = sensorType.name;
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" *;") + " *";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_true(sensorName in window);
}, `${sensorName}: ${header} allows the top-level document.`);
async_test(t => {
test_feature_availability(
desc,
t,
same_origin_src + sensorName,
expect_feature_available_default
);
}, `${sensorName}: ${header} allows same-origin iframes.`);
async_test(t => {
test_feature_availability(
desc,
t,
cross_origin_src + sensorName,
expect_feature_available_default
);
}, `${sensorName}: ${header} allows cross-origin iframes.`);
}
function run_fp_tests_enabled_by_attribute(sensorType) {
const sensorName = sensorType.name;
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy allow='" + featureNameList.join(" ") + "' attribute";
const desc = "'new " + sensorName + "()'";
async_test(t => {
test_feature_availability(
desc,
t,
same_origin_src + sensorName,
expect_feature_available_default,
featureNameList.join(";")
);
}, `${sensorName}: ${header} allows same-origin iframe`);
async_test(t => {
test_feature_availability(
desc,
t,
cross_origin_src + sensorName,
expect_feature_available_default,
featureNameList.join(";")
);
}, `${sensorName}: ${header} allows cross-origin iframe`);
}
function run_fp_tests_enabled_by_attribute_redirect_on_load(sensorType) {
const sensorName = sensorType.name;
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy allow='" + featureNameList.join(" ") + "' attribute";
const desc = "'new " + sensorName + "()'";
async_test(t => {
test_feature_availability(
desc,
t,
base_src + same_origin_src + sensorName,
expect_feature_available_default,
featureNameList.join(";")
);
}, `${sensorName}: ${header} allows same-origin relocation`);
async_test(t => {
test_feature_availability(
desc,
t,
base_src + cross_origin_src + sensorName,
expect_feature_unavailable_default,
featureNameList.join(";")
);
}, `${sensorName}: ${header} disallows cross-origin relocation`);
}
function run_fp_tests_enabled_on_self_origin(sensorType) {
const sensorName = sensorType.name;
const featureNameList = feature_policies[sensorName];
const header = "Feature-Policy header " + featureNameList.join(" 'self';") + " 'self'";
const desc = "'new " + sensorName + "()'";
test(() => {
assert_true(sensorName in window);
}, `${sensorName}: ${header} allows the top-level document.`);
async_test(t => {
test_feature_availability(
desc,
t,
same_origin_src + sensorName,
expect_feature_available_default
);
}, `${sensorName}: ${header} allows same-origin iframes.`);
async_test(t => {
test_feature_availability(
desc,
t,
cross_origin_src + sensorName,
expect_feature_unavailable_default
);
}, `${sensorName}: ${header} disallows cross-origin iframes.`);
}
Computing file changes ...