mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-21 09:15:35 +00:00
Bug 1162848 - Use a single synthesizeKeyFromKeyTag helper for mochitest-devtools;r=jryans
--HG-- extra : commitid : 45zZOTo938D
This commit is contained in:
parent
7852a87430
commit
e21883e698
@ -52,18 +52,18 @@ function* testOptionsShortcut() {
|
||||
|
||||
yield toolbox.selectTool("webconsole");
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
|
||||
synthesizeKeyFromKeyTag("toolbox-options-key", doc);
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
|
||||
synthesizeKeyFromKeyTag("toolbox-options-key", doc);
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected (1)");
|
||||
|
||||
yield toolbox.selectTool("webconsole");
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is selected");
|
||||
synthesizeKeyFromKeyTag("toolbox-options-key2", doc);
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key2"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
|
||||
synthesizeKeyFromKeyTag("toolbox-options-key", doc);
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
|
||||
is(toolbox.currentToolId, "webconsole", "webconsole is reselected (2)");
|
||||
synthesizeKeyFromKeyTag("toolbox-options-key2", doc);
|
||||
synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key2"));
|
||||
is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (2)");
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,8 @@ function removeTab(tab) {
|
||||
});
|
||||
}
|
||||
|
||||
function synthesizeKeyFromKeyTag(aKeyId, document) {
|
||||
let key = document.getElementById(aKeyId);
|
||||
isnot(key, null, "Successfully retrieved the <key> node");
|
||||
function synthesizeKeyFromKeyTag(key) {
|
||||
is(key && key.tagName, "key", "Successfully retrieved the <key> node");
|
||||
|
||||
let modifiersAttr = key.getAttribute("modifiers");
|
||||
|
||||
@ -113,13 +112,14 @@ function synthesizeKeyFromKeyTag(aKeyId, document) {
|
||||
isnot(name, null, "Successfully retrieved keycode/key");
|
||||
|
||||
let modifiers = {
|
||||
shiftKey: modifiersAttr.match("shift"),
|
||||
ctrlKey: modifiersAttr.match("ctrl"),
|
||||
altKey: modifiersAttr.match("alt"),
|
||||
metaKey: modifiersAttr.match("meta"),
|
||||
accelKey: modifiersAttr.match("accel")
|
||||
shiftKey: !!modifiersAttr.match("shift"),
|
||||
ctrlKey: !!modifiersAttr.match("control"),
|
||||
altKey: !!modifiersAttr.match("alt"),
|
||||
metaKey: !!modifiersAttr.match("meta"),
|
||||
accelKey: !!modifiersAttr.match("accel")
|
||||
};
|
||||
|
||||
info("Synthesizing key " + name + " " + JSON.stringify(modifiers));
|
||||
EventUtils.synthesizeKey(name, modifiers);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ function test() {
|
||||
|
||||
let mgr = ResponsiveUI.ResponsiveUIManager;
|
||||
|
||||
synthesizeKeyFromKeyTag("key_responsiveUI");
|
||||
synthesizeKeyFromKeyTag(document.getElementById("key_responsiveUI"));
|
||||
|
||||
yield once(mgr, "on");
|
||||
|
||||
|
@ -24,29 +24,13 @@ function test() {
|
||||
return testOnePreset(instance.menulist.firstChild.childNodes.length - 4);
|
||||
}
|
||||
|
||||
function synthesizeKeyFromKeyTag(aKeyId) {
|
||||
let key = document.getElementById(aKeyId);
|
||||
isnot(key, null, "Successfully retrieved the <key> node");
|
||||
|
||||
let name = null;
|
||||
|
||||
if (key.getAttribute("keycode"))
|
||||
name = key.getAttribute("keycode");
|
||||
else if (key.getAttribute("key"))
|
||||
name = key.getAttribute("key");
|
||||
|
||||
isnot(name, null, "Successfully retrieved keycode/key");
|
||||
|
||||
key.doCommand();
|
||||
}
|
||||
|
||||
Task.spawn(function*() {
|
||||
|
||||
yield addTab("data:text/html;charset=utf8,test custom presets in responsive mode");
|
||||
|
||||
let mgr = ResponsiveUI.ResponsiveUIManager;
|
||||
|
||||
synthesizeKeyFromKeyTag("key_responsiveUI");
|
||||
synthesizeKeyFromKeyTag(document.getElementById("key_responsiveUI"));
|
||||
|
||||
yield once(mgr, "on");
|
||||
|
||||
@ -107,7 +91,7 @@ function test() {
|
||||
// Let's wait next loop to stop it.
|
||||
yield nextTick();
|
||||
|
||||
synthesizeKeyFromKeyTag("key_responsiveUI");
|
||||
synthesizeKeyFromKeyTag(document.getElementById("key_responsiveUI"));
|
||||
|
||||
yield once(mgr, "on");
|
||||
|
||||
@ -140,7 +124,7 @@ function test() {
|
||||
instance.close();
|
||||
yield once(mgr, "off");
|
||||
|
||||
synthesizeKeyFromKeyTag("key_responsiveUI");
|
||||
synthesizeKeyFromKeyTag(document.getElementById("key_responsiveUI"));
|
||||
|
||||
info("waiting for responsive mode to turn on");
|
||||
yield once(mgr, "on");
|
||||
|
@ -3,10 +3,8 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var {TargetFactory} = require("devtools/client/framework/target");
|
||||
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
var promise = require("promise");
|
||||
// shared-head.js handles imports, constants, and utility functions
|
||||
Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js", this);
|
||||
|
||||
// Import the GCLI test helper
|
||||
var testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
|
||||
@ -184,32 +182,6 @@ function wait(ms) {
|
||||
return def.promise;
|
||||
}
|
||||
|
||||
function synthesizeKeyFromKeyTag(aKeyId) {
|
||||
let key = document.getElementById(aKeyId);
|
||||
isnot(key, null, "Successfully retrieved the <key> node");
|
||||
|
||||
let modifiersAttr = key.getAttribute("modifiers");
|
||||
|
||||
let name = null;
|
||||
|
||||
if (key.getAttribute("keycode"))
|
||||
name = key.getAttribute("keycode");
|
||||
else if (key.getAttribute("key"))
|
||||
name = key.getAttribute("key");
|
||||
|
||||
isnot(name, null, "Successfully retrieved keycode/key");
|
||||
|
||||
let modifiers = {
|
||||
shiftKey: modifiersAttr.match("shift"),
|
||||
ctrlKey: modifiersAttr.match("ctrl"),
|
||||
altKey: modifiersAttr.match("alt"),
|
||||
metaKey: modifiersAttr.match("meta"),
|
||||
accelKey: modifiersAttr.match("accel")
|
||||
}
|
||||
|
||||
EventUtils.synthesizeKey(name, modifiers);
|
||||
}
|
||||
|
||||
function nextTick() {
|
||||
let def = promise.defer();
|
||||
executeSoon(() => def.resolve())
|
||||
|
@ -5,15 +5,12 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
var {gDevTools} = Cu.import("resource://devtools/client/framework/gDevTools.jsm", {});
|
||||
var {console} = Cu.import("resource://gre/modules/Console.jsm", {});
|
||||
// shared-head.js handles imports, constants, and utility functions
|
||||
Services.scriptloader.loadSubScript("chrome://mochitests/content/browser/devtools/client/framework/test/shared-head.js", this);
|
||||
|
||||
var {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
|
||||
var {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
|
||||
var promise = require("promise");
|
||||
var {TargetFactory} = require("devtools/client/framework/target");
|
||||
var {Utils: WebConsoleUtils} = require("devtools/shared/webconsole/utils");
|
||||
var {Messages} = require("devtools/client/webconsole/console-output");
|
||||
var DevToolsUtils = require("devtools/shared/DevToolsUtils");
|
||||
const asyncStorage = require("devtools/shared/async-storage");
|
||||
|
||||
// Services.prefs.setBoolPref("devtools.debugger.log", true);
|
||||
|
Loading…
Reference in New Issue
Block a user