Bug 1689565 - Part 2: Tweak marionette hack to allow `notifications` r=jgraham,webdriver-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D167976
This commit is contained in:
Kagami Sascha Rosylight 2023-01-30 12:50:51 +00:00
Родитель c1b2ac7b4e
Коммит d5986c606b
1 изменённых файлов: 20 добавлений и 11 удалений

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

@ -34,13 +34,6 @@ permissions.set = function(descriptor, state, oneRealm) {
);
}
const { name } = descriptor;
if (!["clipboard-write", "clipboard-read"].includes(name)) {
throw new lazy.error.UnsupportedOperationError(
`'Set Permission' doesn't support '${name}'`
);
}
if (state === "prompt") {
throw new lazy.error.UnsupportedOperationError(
"'Set Permission' doesn't support prompt"
@ -49,12 +42,28 @@ permissions.set = function(descriptor, state, oneRealm) {
// This is not a real implementation of the permissions API.
// Instead the purpose of this implementation is to have web-platform-tests
// that use `set_permission('clipboard-write|read')` not fail.
// We enable dom.events.testing.asyncClipboard for the whole test suite anyway,
// so no extra permission is necessary.
if (!Services.prefs.getBoolPref("dom.events.testing.asyncClipboard", false)) {
// that use `set_permission()` not fail.
// Each test needs the corresponding testing pref to make it actually work.
const { name } = descriptor;
if (["clipboard-write", "clipboard-read"].includes(name)) {
if (
Services.prefs.getBoolPref("dom.events.testing.asyncClipboard", false)
) {
return;
}
throw new lazy.error.UnsupportedOperationError(
"'Set Permission' expected dom.events.testing.asyncClipboard to be set"
);
} else if (name === "notifications") {
if (Services.prefs.getBoolPref("notification.prompt.testing", false)) {
return;
}
throw new lazy.error.UnsupportedOperationError(
"'Set Permission' expected notification.prompt.testing to be set"
);
}
throw new lazy.error.UnsupportedOperationError(
`'Set Permission' doesn't support '${name}'`
);
};