summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/permissions-policy
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:37 +0000
commita90a5cba08fdf6c0ceb95101c275108a152a3aed (patch)
tree532507288f3defd7f4dcf1af49698bcb76034855 /testing/web-platform/tests/permissions-policy
parentAdding debian version 126.0.1-1. (diff)
downloadfirefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.tar.xz
firefox-a90a5cba08fdf6c0ceb95101c275108a152a3aed.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/permissions-policy')
-rw-r--r--testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy-attribute.https.sub.html59
-rw-r--r--testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy.https.sub.html86
-rw-r--r--testing/web-platform/tests/permissions-policy/payment-default-permissions-policy.https.sub.html67
-rw-r--r--testing/web-platform/tests/permissions-policy/payment-disabled-by-permissions-policy.https.sub.html64
-rw-r--r--testing/web-platform/tests/permissions-policy/resources/permissions-policy.js38
5 files changed, 205 insertions, 109 deletions
diff --git a/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy-attribute.https.sub.html b/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy-attribute.https.sub.html
index 779e9d666c..3a7e11b03c 100644
--- a/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy-attribute.https.sub.html
+++ b/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy-attribute.https.sub.html
@@ -1,26 +1,47 @@
<!DOCTYPE html>
<body>
- <script src=/resources/testharness.js></script>
- <script src=/resources/testharnessreport.js></script>
- <script src=/permissions-policy/resources/permissions-policy.js></script>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
- 'use strict';
- var same_origin_src = '/permissions-policy/resources/permissions-policy-payment.html';
- var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
- same_origin_src;
- var feature_name = 'permissions policy "payment"';
- var header = 'allow="payment" attribute';
+ "use strict";
+ const same_origin_src =
+ "/permissions-policy/resources/permissions-policy-payment.html";
+ const cross_origin_src =
+ "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
+ const feature_name = 'permissions policy "payment"';
+ const header = 'allow="payment" attribute';
- async_test(t => {
- test_feature_availability(
- 'PaymentRequest()', t, same_origin_src,
- expect_feature_available_default, 'payment');
- }, feature_name + ' can be enabled in same-origin iframe using ' + header);
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: same_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ is_promise_test: true
+ });
+ }, `${feature_name} is enabled by default`);
- async_test(t => {
- test_feature_availability(
- 'PaymentRequest()', t, cross_origin_src,
- expect_feature_available_default, 'payment');
- }, feature_name + ' can be enabled in cross-origin iframe using ' + header);
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: same_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ feature_name: "payment",
+ is_promise_test: true,
+ });
+ }, `${feature_name} can be enabled in same-origin iframe using ${header}`);
+
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: cross_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ feature_name: "payment",
+ is_promise_test: true,
+ });
+ }, `${feature_name} can be enabled in cross-origin iframe using ${header}`);
</script>
</body>
diff --git a/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy.https.sub.html b/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy.https.sub.html
index 456626c350..27583d3c9c 100644
--- a/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy.https.sub.html
+++ b/testing/web-platform/tests/permissions-policy/payment-allowed-by-permissions-policy.https.sub.html
@@ -1,40 +1,64 @@
<!DOCTYPE html>
<body>
- <script src=/resources/testharness.js></script>
- <script src=/resources/testharnessreport.js></script>
- <script src=/permissions-policy/resources/permissions-policy.js></script>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
- 'use strict';
- var same_origin_src = '/permissions-policy/resources/permissions-policy-payment.html';
- var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
- same_origin_src;
- var header = 'permissions policy header "payment=*"';
+ "use strict";
+ const same_origin_src =
+ "/permissions-policy/resources/permissions-policy-payment.html";
+ const cross_origin_src =
+ "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
+ const header = 'permissions policy header "payment=*"';
- test(() => {
- var supportedMethods = [ { supportedMethods: 'https://{{domains[nonexistent]}}/payment-request' } ];
- var details = {
- total: { label: 'Test', amount: { currency: 'USD', value: '5.00' } }
- };
- try {
- new PaymentRequest(supportedMethods, details);
- } catch (e) {
- assert_unreached();
- }
- }, header + ' allows the top-level document.');
+ test(() => {
+ const supportedMethods = [
+ {
+ supportedMethods: "https://{{domains[nonexistent]}}/payment-request",
+ },
+ ];
+ const details = {
+ total: {
+ label: "Test",
+ amount: { currency: "USD", value: "5.00" },
+ },
+ };
+ try {
+ new PaymentRequest(supportedMethods, details);
+ } catch (e) {
+ assert_unreached();
+ }
+ }, `${header} allows Payment Request API the top-level document.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, same_origin_src,
- expect_feature_available_default);
- }, header + ' allows same-origin iframes.');
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: same_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ is_promise_test: true,
+ });
+ }, `${header} allows Payment Request API same-origin iframes.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, cross_origin_src,
- expect_feature_unavailable_default);
- }, header + ' disallows cross-origin iframes.');
+ promise_test(async (test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: cross_origin_src,
+ expect_feature_available: expect_feature_unavailable_default,
+ is_promise_test: true,
+ });
+ }, `${header} disallows Payment Request API cross-origin iframes.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, cross_origin_src,
- expect_feature_available_default, 'payment');
- }, header + ' allow="payment" allows cross-origin iframes.');
+ promise_test(async (test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: cross_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ feature_name: "payment",
+ is_promise_test: true,
+ });
+ }, `${header} allow="payment" allows Payment Request in cross-origin iframes.`);
</script>
</body>
diff --git a/testing/web-platform/tests/permissions-policy/payment-default-permissions-policy.https.sub.html b/testing/web-platform/tests/permissions-policy/payment-default-permissions-policy.https.sub.html
index da5fe80f66..92a0f7e14f 100644
--- a/testing/web-platform/tests/permissions-policy/payment-default-permissions-policy.https.sub.html
+++ b/testing/web-platform/tests/permissions-policy/payment-default-permissions-policy.https.sub.html
@@ -1,35 +1,48 @@
<!DOCTYPE html>
<body>
- <script src=/resources/testharness.js></script>
- <script src=/resources/testharnessreport.js></script>
- <script src=/permissions-policy/resources/permissions-policy.js></script>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
- 'use strict';
- var same_origin_src = '/permissions-policy/resources/permissions-policy-payment.html';
- var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
- same_origin_src;
- var header = 'Default "payment" permissions policy';
+ "use strict";
+ const same_origin_src =
+ "/permissions-policy/resources/permissions-policy-payment.html";
+ const cross_origin_src =
+ "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
- test(() => {
- var supportedInstruments = [ { supportedMethods: 'visa' } ];
- var details = {
- total: { label: 'Test', amount: { currency: 'USD', value: '5.00' } }
- };
- try {
- new PaymentRequest(supportedInstruments, details);
- } catch (e) {
- assert_unreached();
- }
- }, header + ' allows the top-level document.');
+ test(() => {
+ const supportedInstruments = [{ supportedMethods: "visa" }];
+ const details = {
+ total: {
+ label: "Test",
+ amount: { currency: "USD", value: "5.00" },
+ },
+ };
+ try {
+ new PaymentRequest(supportedInstruments, details);
+ } catch (e) {
+ assert_unreached();
+ }
+ }, `Payment Request API is enabled by default the top-level document.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, same_origin_src,
- expect_feature_available_default);
- }, header + ' allows same-origin iframes.');
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: same_origin_src,
+ expect_feature_available: expect_feature_available_default,
+ is_promise_test: true,
+ });
+ }, `Payment Request API is enabled by default in same-origin iframes.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, cross_origin_src,
- expect_feature_unavailable_default);
- }, header + ' disallows cross-origin iframes.');
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: cross_origin_src,
+ expect_feature_available: expect_feature_unavailable_default,
+ is_promise_test: true,
+ });
+ }, `Payment Request API is disabled by default in cross-origin iframes.`);
</script>
</body>
diff --git a/testing/web-platform/tests/permissions-policy/payment-disabled-by-permissions-policy.https.sub.html b/testing/web-platform/tests/permissions-policy/payment-disabled-by-permissions-policy.https.sub.html
index cc358a1c0f..b53eff996a 100644
--- a/testing/web-platform/tests/permissions-policy/payment-disabled-by-permissions-policy.https.sub.html
+++ b/testing/web-platform/tests/permissions-policy/payment-disabled-by-permissions-policy.https.sub.html
@@ -1,33 +1,47 @@
<!DOCTYPE html>
<body>
- <script src=/resources/testharness.js></script>
- <script src=/resources/testharnessreport.js></script>
- <script src=/permissions-policy/resources/permissions-policy.js></script>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
- 'use strict';
- var same_origin_src = '/permissions-policy/resources/permissions-policy-payment.html';
- var cross_origin_src = 'https://{{domains[www]}}:{{ports[https][0]}}' +
- same_origin_src;
- var header = 'permissions policy header "payment=()"';
+ "use strict";
+ const same_origin_src =
+ "/permissions-policy/resources/permissions-policy-payment.html";
+ const cross_origin_src =
+ "https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
+ const header = 'permissions policy header "payment=()"';
- test(() => {
- var supportedInstruments = [ { supportedMethods: 'visa' } ];
- var details = {
- total: { label: 'Test', amount: { currency: 'USD', value: '5.00' } }
- };
- assert_throws_dom('SecurityError', () => {
- new PaymentRequest(supportedInstruments, details);
- });
- }, header + ' disallows the top-level document.');
+ test(() => {
+ const supportedInstruments = [{ supportedMethods: "visa" }];
+ const details = {
+ total: {
+ label: "Test",
+ amount: { currency: "USD", value: "5.00" },
+ },
+ };
+ assert_throws_dom("SecurityError", () => {
+ new PaymentRequest(supportedInstruments, details);
+ });
+ }, `${header} disallows Payment Request API in top-level document.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, same_origin_src,
- expect_feature_unavailable_default);
- }, header + ' disallows same-origin iframes.');
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: same_origin_src,
+ expect_feature_available: expect_feature_unavailable_default,
+ is_promise_test: true,
+ });
+ }, `${header} disallows Payment Request API in same-origin iframes.`);
- async_test(t => {
- test_feature_availability('PaymentRequest()', t, cross_origin_src,
- expect_feature_unavailable_default,);
- }, header + ' disallows cross-origin iframes.');
+ promise_test((test) => {
+ return test_feature_availability({
+ feature_description: "PaymentRequest()",
+ test,
+ src: cross_origin_src,
+ expect_feature_available: expect_feature_unavailable_default,
+ is_promise_test: true,
+ });
+ }, `${header} disallows Payment Request API in cross-origin iframes.`);
</script>
</body>
diff --git a/testing/web-platform/tests/permissions-policy/resources/permissions-policy.js b/testing/web-platform/tests/permissions-policy/resources/permissions-policy.js
index 32fb4cfd4a..d30d1191d1 100644
--- a/testing/web-platform/tests/permissions-policy/resources/permissions-policy.js
+++ b/testing/web-platform/tests/permissions-policy/resources/permissions-policy.js
@@ -6,8 +6,9 @@ function assert_permissions_policy_supported() {
// Tests whether a feature that is enabled/disabled by permissions policy works
// as expected.
// Arguments:
-// feature_description: a short string describing what feature is being
-// tested. Examples: "usb.GetDevices()", "PaymentRequest()".
+// feature_descriptionOrObject: either and object, containing the following
+// properties, or a string describing what feature is being tested.
+// Examples: "usb.GetDevices()", "PaymentRequest()".
// test: test created by testharness. Examples: async_test, promise_test.
// src: URL where a feature's availability is checked. Examples:
// "/permissions-policy/resources/permissions-policy-payment.html",
@@ -24,13 +25,36 @@ function assert_permissions_policy_supported() {
// feature (https://w3c.github.io/webappsec-permissions-policy/#features).
// See examples at:
// https://github.com/w3c/webappsec-permissions-policy/blob/main/features.md
-// allow_attribute: Optional argument, only used for testing fullscreen
+// allowfullscreen: Optional argument, only used for testing fullscreen
// by passing "allowfullscreen".
// is_promise_test: Optional argument, true if this call should return a
// promise. Used by test_feature_availability_with_post_message_result()
function test_feature_availability(
- feature_description, test, src, expect_feature_available, feature_name,
- allow_attribute, is_promise_test = false) {
+ feature_descriptionOrObject, test, src, expect_feature_available, feature_name,
+ allowfullscreen, is_promise_test = false) {
+
+ if (feature_descriptionOrObject && feature_descriptionOrObject instanceof Object) {
+ const {
+ feature_description,
+ test,
+ src,
+ expect_feature_available,
+ feature_name,
+ allowfullscreen,
+ is_promise_test,
+ } = feature_descriptionOrObject;
+ return test_feature_availability(
+ feature_description,
+ test,
+ src,
+ expect_feature_available,
+ feature_name,
+ allowfullscreen,
+ is_promise_test
+ );
+ }
+
+ const feature_description = feature_descriptionOrObject;
let frame = document.createElement('iframe');
frame.src = src;
@@ -38,8 +62,8 @@ function test_feature_availability(
frame.allow = frame.allow.concat(";" + feature_name);
}
- if (typeof allow_attribute !== 'undefined') {
- frame.setAttribute(allow_attribute, true);
+ if (typeof allowfullscreen !== 'undefined') {
+ frame.setAttribute(allowfullscreen, true);
}
function expectFeatureAvailable(evt) {