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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
|
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
function test() {
info("Test various cases where the escape key should hide the split console.");
let toolbox;
let hud;
let jsterm;
let hudMessages;
let variablesView;
Task.spawn(runner).then(finish);
function* runner() {
let {tab} = yield loadTab("data:text/html;charset=utf-8,<p>Web Console test for splitting");
let target = TargetFactory.forTab(tab);
toolbox = yield gDevTools.showToolbox(target, "inspector");
yield testCreateSplitConsoleAfterEscape();
yield showAutoCompletePopoup();
yield testHideAutoCompletePopupAfterEscape();
yield executeJS();
yield clickMessageAndShowVariablesView();
jsterm.inputNode.focus();
yield testHideVariablesViewAfterEscape();
yield clickMessageAndShowVariablesView();
yield startPropertyEditor();
yield testCancelPropertyEditorAfterEscape();
yield testHideVariablesViewAfterEscape();
yield testHideSplitConsoleAfterEscape();
}
function testCreateSplitConsoleAfterEscape() {
let result = toolbox.once("webconsole-ready", () => {
hud = toolbox.getPanel("webconsole").hud;
jsterm = hud.jsterm;
ok(toolbox.splitConsole, "Split console is created.");
});
let contentWindow = toolbox.frame.contentWindow;
contentWindow.focus();
EventUtils.sendKey("ESCAPE", contentWindow);
return result;
}
function testShowSplitConsoleAfterEscape() {
let result = toolbox.once("split-console", () => {
ok(toolbox.splitConsole, "Split console is shown.");
});
EventUtils.sendKey("ESCAPE", toolbox.frame.contentWindow);
return result;
}
function testHideSplitConsoleAfterEscape() {
let result = toolbox.once("split-console", () => {
ok(!toolbox.splitConsole, "Split console is hidden.");
});
EventUtils.sendKey("ESCAPE", toolbox.frame.contentWindow);
return result;
}
function testHideVariablesViewAfterEscape() {
let result = jsterm.once("sidebar-closed", () => {
ok(!hud.ui.jsterm.sidebar,
"Variables view is hidden.");
ok(toolbox.splitConsole,
"Split console is open after hiding the variables view.");
});
EventUtils.sendKey("ESCAPE", toolbox.frame.contentWindow);
return result;
}
function testHideAutoCompletePopupAfterEscape() {
let deferred = promise.defer();
let popup = jsterm.autocompletePopup;
popup._panel.addEventListener("popuphidden", function popupHidden() {
popup._panel.removeEventListener("popuphidden", popupHidden, false);
ok(!popup.isOpen,
"Auto complete popup is hidden.");
ok(toolbox.splitConsole,
"Split console is open after hiding the autocomplete popup.");
deferred.resolve();
}, false);
EventUtils.sendKey("ESCAPE", toolbox.frame.contentWindow);
return deferred.promise;
}
function testCancelPropertyEditorAfterEscape() {
EventUtils.sendKey("ESCAPE", variablesView.window);
ok(hud.ui.jsterm.sidebar,
"Variables view is open after canceling property editor.");
ok(toolbox.splitConsole,
"Split console is open after editing.");
}
function executeJS() {
jsterm.execute("var foo = { bar: \"baz\" }; foo;");
hudMessages = yield waitForMessages({
webconsole: hud,
messages: [{
text: "Object { bar: \"baz\" }",
category: CATEGORY_OUTPUT,
objects: true
}],
});
}
function clickMessageAndShowVariablesView() {
let result = jsterm.once("variablesview-fetched", (event, vview) => {
variablesView = vview;
});
let clickable = hudMessages[0].clickableElements[0];
EventUtils.synthesizeMouse(clickable, 2, 2, {}, hud.iframeWindow);
return result;
}
function startPropertyEditor() {
let results = yield findVariableViewProperties(variablesView, [
{name: "bar", value: "baz"}
], {webconsole: hud});
results[0].matchedProp.focus();
EventUtils.synthesizeKey("VK_RETURN", variablesView.window);
}
function showAutoCompletePopoup() {
let deferred = promise.defer();
let popupPanel = jsterm.autocompletePopup._panel;
popupPanel.addEventListener("popupshown", function popupShown() {
popupPanel.removeEventListener("popupshown", popupShown, false);
deferred.resolve();
}, false);
jsterm.inputNode.focus();
jsterm.setInputValue("document.location.");
EventUtils.sendKey("TAB", hud.iframeWindow);
return deferred.promise;
}
function finish() {
toolbox.destroy().then(() => {
toolbox = null;
hud = null;
jsterm = null;
hudMessages = null;
variablesView = null;
finishTest();
});
}
}
|