Bug 1594786 - Make test.withHandlingUserInput to be only supported in automation. r=mixedpuppy,robwu

Make test.withHandingUserInput more restrictive than the rest of the test namespace
(which is also going to be available if an XPCSHELL_TEST_PROFILE_DIR environment var
is defined).

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Luca Greco 2019-11-25 19:04:57 +00:00
Родитель ae7be05784
Коммит cf216aa0c2
1 изменённых файлов: 9 добавлений и 0 удалений

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

@ -123,6 +123,15 @@ this.test = class extends ExtensionAPI {
return {
test: {
withHandlingUserInput(callback) {
// TODO(Bug 1598804): remove this once we don't expose anymore the
// entire test API namespace based on an environment variable.
if (!Cu.isInAutomation) {
// This dangerous method should only be available if the
// automation pref is set, which is the case in browser tests.
throw new ExtensionUtils.ExtensionError(
"withHandlingUserInput can only be called in automation"
);
}
ExtensionCommon.withHandlingUserInput(
context.contentWindow,
callback