fune/browser/components/extensions/test/xpcshell/test_ext_manifest_commands.js
Kris Maglione 5595379222 Bug 1288885: Support testing WebExtensions from xpcshell tests. r=aswan
Most of the test helper code is derived from the SpecialPowers/ExtensionTestUtils
code that does the same. Eventually, the two implementations should probably
be unified, but I don't think it's worth the trouble for now.

MozReview-Commit-ID: 7Yy9jWkGsMM

--HG--
extra : source : 8da1ed0adf15e8244e57f22c581bbee072a118b9
2016-07-24 16:09:26 -07:00

24 lines
974 B
JavaScript

/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";
add_task(function* test_manifest_commands() {
let normalized = yield ExtensionTestUtils.normalizeManifest({
"commands": {
"toggle-feature": {
"suggested_key": {"default": "Shifty+Y"},
"description": "Send a 'toggle-feature' event to the extension",
},
},
});
let expectedError = (
String.raw`commands.toggle-feature.suggested_key.default: Value must either: ` +
String.raw`match the pattern /^\s*(Alt|Ctrl|Command|MacCtrl)\s*\+\s*(Shift\s*\+\s*)?([A-Z0-9]|Comma|Period|Home|End|PageUp|PageDown|Space|Insert|Delete|Up|Down|Left|Right)\s*$/, or ` +
String.raw`match the pattern /^(MediaNextTrack|MediaPlayPause|MediaPrevTrack|MediaStop)$/`
);
ok(normalized.error.includes(expectedError),
`The manifest error ${JSON.stringify(normalized.error)} must contain ${JSON.stringify(expectedError)}`);
});