Skip to content

Commit

Permalink
Restore geolocation permission for wpt geolocation policy tests and m…
Browse files Browse the repository at this point in the history
…ake attribute tests more similar

Permission was removed from permissions-policy-geolocation.html upstream but not
re-added to the individual tests.  These two tests need it.  They were
incorrectly passing in CI due to the tests that run before them
(disabled-by-permissions-policy.https.sub.html) granting the permission --
they would fail when run individually.

This also does some cosmetic cleanup to make it clear that the tests are
very similar.  This includes renaming the tests from "Geolocation API"
to "Geolocation", as the name was changed in Bug 1902628 [wpt PR 46750].

Additionally, enabled-by-permission-policy-attribute fails in test-verify mode
as an async_test -- the async setup function is not compatible with
that.  enabled-by-permission-policy-attribute-redirect-on-load
is the same test but with a redirect -- it is a promise_test.  This
switches enabled-by-permission-policy-attribute to work as a promise_test,
which fixes the test-verify issue.

Differential Revision: https://phabricator.services.mozilla.com/D232772

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1937188
gecko-commit: 2ad450615824e0e0ba0d95e928a8d3e0d59c2f9e
gecko-reviewers: saschanaz, jgraham
  • Loading branch information
davidp3 authored and moz-wptsync-bot committed Jan 18, 2025
1 parent b4b2ff9 commit 85b330f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
"use strict";
Expand All @@ -12,19 +14,25 @@
const same_origin_src = base_src + relative_path;
const cross_origin_src = `${base_src}https://{{hosts[alt][]}}:{{ports[https][0]}}${relative_path}`;

// Grant permission to outer frame
promise_setup(async () => {
await test_driver.set_permission({ name: "geolocation" }, "granted");
});

promise_test(async (test) => {
await test_feature_availability({
feature_description: "Geolocation API",
feature_description: "Geolocation",
test,
src: same_origin_src,
expect_feature_available: expect_feature_available_default,
is_promise_test: true,
feature_name: "geolocation",
});
}, 'Permissions-Policy allow="geolocation" allows same-origin redirection');

promise_test(async (test) => {
await test_feature_availability({
feature_description: "Geolocation API",
feature_description: "Geolocation",
test,
src: cross_origin_src,
expect_feature_available: expect_feature_available_default,
Expand Down
63 changes: 35 additions & 28 deletions geolocation/enabled-by-permission-policy-attribute.https.sub.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
<!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>
"use strict";
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/permissions-policy/resources/permissions-policy.js"></script>
<script>
"use strict";

const same_origin_src =
"/permissions-policy/resources/permissions-policy-geolocation.html";
const cross_origin_src =
"https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;
const same_origin_src =
"/permissions-policy/resources/permissions-policy-geolocation.html";
const cross_origin_src =
"https://{{hosts[alt][]}}:{{ports[https][0]}}" + same_origin_src;

async_test(t => {
test_feature_availability(
"geolocation",
t,
same_origin_src,
expect_feature_available_default,
"geolocation"
);
}, 'Permissions policy "geolocation" can be enabled in same-origin iframe using allow="geolocation" attribute');
// Grant permission to outer frame
promise_setup(async () => {
await test_driver.set_permission({ name: "geolocation" }, "granted");
});

async_test(t => {
test_feature_availability(
"geolocation",
t,
cross_origin_src,
expect_feature_available_default,
"geolocation"
);
}, 'Permissions policy "geolocation" can be enabled in cross-origin iframe using allow="geolocation" attribute');
</script>
promise_test(async (test) => {
await test_feature_availability(
"Geolocation",
test,
same_origin_src,
expect_feature_available_default,
"geolocation"
);
}, 'Permissions policy "geolocation" can be enabled in same-origin iframe using allow="geolocation" attribute');

promise_test(async (test) => {
await test_feature_availability(
"Geolocation",
test,
cross_origin_src,
expect_feature_available_default,
"geolocation"
);
}, 'Permissions policy "geolocation" can be enabled in cross-origin iframe using allow="geolocation" attribute');
</script>
</body>

0 comments on commit 85b330f

Please sign in to comment.