Bug 1718021 - Add name attribute to PermissionStatus r=johannh,peterv

Spec change https://github.com/w3c/permissions/pull/248

Differential Revision: https://phabricator.services.mozilla.com/D118692
This commit is contained in:
Marcos Cáceres 2021-08-11 22:34:41 +00:00
Родитель 2575056f16
Коммит dab2507237
4 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -33,6 +33,8 @@ class PermissionStatus final : public DOMEventTargetHelper {
void DisconnectFromOwner() override;
PermissionName Name() const { return mName; }
private:
~PermissionStatus();

Просмотреть файл

@ -85,12 +85,15 @@
});
return Promise.all(promisesToRevoke);
},
checkPermissions(state) {
const promisesToQuery = PERMISSIONS.map(({ name }) => {
checkPermissions(expectedState) {
const promisesToQuery = PERMISSIONS.map(({ name: expectedName }) => {
return aWindow.navigator.permissions
.query({ name })
.query({ name: expectedName })
.then(
() => is(state, state, `correct state for '${name}'`),
({ state, name }) => {
is(state, expectedState, `correct state for '${expectedName}'`)
is(name, expectedName, `correct name for '${expectedName}'`)
},
() => ok(false, `query should not have rejected for '${name}'`)
);
});

Просмотреть файл

@ -15,6 +15,7 @@ enum PermissionState {
[Exposed=Window]
interface PermissionStatus : EventTarget {
readonly attribute PermissionName name;
readonly attribute PermissionState state;
attribute EventHandler onchange;
};

Просмотреть файл

@ -0,0 +1,15 @@
<!doctype html>
<meta charset=utf-8>
<title>Test PermissionStatus's name attribute.</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id="log"></div>
<script>
promise_test(async () => {
const result = await navigator.permissions.query({
name: "geolocation",
});
assert_equals(result.name, "geolocation", "Name was geolocation");
});
</script>