1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that the toolbox keybindings still work after the host is changed.
const URL = "data:text/html;charset=utf8,test page";
var {Toolbox} = require("devtools/client/framework/toolbox");
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
function getZoomValue() {
return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue"));
}
add_task(function* () {
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let {SIDE, BOTTOM} = Toolbox.HostType;
for (let type of [SIDE, BOTTOM, SIDE]) {
info("Switch to host type " + type);
yield toolbox.switchHost(type);
info("Try to use the toolbox shortcuts");
yield checkKeyBindings(toolbox);
}
Services.prefs.clearUserPref("devtools.toolbox.zoomValue");
Services.prefs.setCharPref("devtools.toolbox.host", BOTTOM);
yield toolbox.destroy();
gBrowser.removeCurrentTab();
});
function zoomWithKey(toolbox, key) {
let shortcut = L10N.getStr(key);
if (!shortcut) {
info("Key was empty, skipping zoomWithKey");
return;
}
info("Zooming with key: " + key);
let currentZoom = getZoomValue();
synthesizeKeyShortcut(shortcut, toolbox.win);
isnot(getZoomValue(), currentZoom, "The zoom level was changed in the toolbox");
}
function* checkKeyBindings(toolbox) {
zoomWithKey(toolbox, "toolbox.zoomIn.key");
zoomWithKey(toolbox, "toolbox.zoomIn2.key");
zoomWithKey(toolbox, "toolbox.zoomIn3.key");
zoomWithKey(toolbox, "toolbox.zoomReset.key");
zoomWithKey(toolbox, "toolbox.zoomOut.key");
zoomWithKey(toolbox, "toolbox.zoomOut2.key");
zoomWithKey(toolbox, "toolbox.zoomReset2.key");
}
|