Skip to content

Commit

Permalink
Feature Policy JS API Update: Add document.featurePolicy.features
Browse files Browse the repository at this point in the history
This adds a method to return the names of all policy-controlled
features supported by the browser. Because this list is determined by
the set of features implemented by Chrome, rather than conformance to
any particular spec, the tests are in /webexposed/ rather than WPT.

(Existing IDL tests in WPT cover the existence of the new method and
the data types that it returns, without depending on the exact values
returned.)

Bug: 917070
Change-Id: I35ccbdce794e236500d15afe5419057a8f162ae7
Reviewed-on: https://chromium-review.googlesource.com/c/1387151
Commit-Queue: Ian Clelland <[email protected]>
Reviewed-by: Rick Byers <[email protected]>
Cr-Commit-Position: refs/heads/master@{#625667}
  • Loading branch information
clelland authored and chromium-wpt-export-bot committed Jan 24, 2019
1 parent 95d10c7 commit f4c41ee
Show file tree
Hide file tree
Showing 14 changed files with 158 additions and 0 deletions.
11 changes: 11 additions & 0 deletions accelerometer/Accelerometer-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that accelerometer is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('accelerometer', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise accelerometer.');
</script>
11 changes: 11 additions & 0 deletions ambient-light/AmbientLightSensor-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that ambient-light-sensor is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('ambient-light-sensor', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise ambient-light-sensor.');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that encrypted-media is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://github.com/w3c/encrypted-media/pull/432">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('encrypted-media', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise encrypted-media.');
</script>
11 changes: 11 additions & 0 deletions feature-policy/payment-supported-by-feature-policy.tentative.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that payment is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://github.com/w3c/payment-request/issues/600">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('payment', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise payment.');
</script>
11 changes: 11 additions & 0 deletions feature-policy/picture-in-picture-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that picture-in-picture is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://wicg.github.io/picture-in-picture/#feature-policy">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('picture-in-picture', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise picture-in-picture.');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that geolocation is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('geolocation', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise geolocation.');
</script>
11 changes: 11 additions & 0 deletions gyroscope/Gyroscope-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that gyroscope is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('gyroscope', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise gyroscope.');
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that autoplay is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://html.spec.whatwg.org/multipage/infrastructure.html#policy-controlled-features">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('autoplay', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise autoplay.');
</script>
11 changes: 11 additions & 0 deletions magnetometer/Magnetometer-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that magnetometer is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/sensors/#feature-policy-api">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('magnetometer', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise magnetometer.');
</script>
15 changes: 15 additions & 0 deletions mediacapture-streams/MediaStream-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<title>Test that accelerometer is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/mediacapture-main/#feature-policy-integration">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('camera', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise camera.');

test(() => {
assert_in_array('microphone', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise microphone.');
</script>
11 changes: 11 additions & 0 deletions wake-lock/wakelock-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that wake-lock is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://w3c.github.io/wake-lock/#dfn-wake-lock-feature">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('wake-lock', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise wake-lock.');
</script>
11 changes: 11 additions & 0 deletions webusb/usb-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that usb is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://wicg.github.io/webusb/#feature-policy">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('usb', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise usb.');
</script>
11 changes: 11 additions & 0 deletions webvr/webvr-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that xr is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://immersive-web.github.io/webxr/#feature-policy">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('xr', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise xr.');
</script>
11 changes: 11 additions & 0 deletions xhr/sync-xhr-supported-by-feature-policy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<title>Test that sync-xhr is advertised in the feature list</title>
<link rel="help" href="https://w3c.github.io/webappsec-feature-policy/#dom-featurepolicy-features">
<link rel="help" href="https://xhr.spec.whatwg.org/#feature-policy-integration">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
assert_in_array('sync-xhr', document.featurePolicy.features());
}, 'document.featurePolicy.features should advertise sync-xhr.');
</script>

0 comments on commit f4c41ee

Please sign in to comment.