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
|
/* vim:set ts=2 sw=2 sts=2 et: */
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Tests that document.body autocompletes in the web console.
function test() {
addTab("data:text/html;charset=utf-8,Web Console autocompletion bug in document.body");
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
let gHUD;
function consoleOpened(aHud) {
gHUD = aHud;
let jsterm = gHUD.jsterm;
let popup = jsterm.autocompletePopup;
let completeNode = jsterm.completeNode;
ok(!popup.isOpen, "popup is not open");
popup._panel.addEventListener("popupshown", function onShown() {
popup._panel.removeEventListener("popupshown", onShown, false);
ok(popup.isOpen, "popup is open");
is(popup.itemCount, jsterm._autocompleteCache.length,
"popup.itemCount is correct");
isnot(jsterm._autocompleteCache.indexOf("addEventListener"), -1,
"addEventListener is in the list of suggestions");
isnot(jsterm._autocompleteCache.indexOf("bgColor"), -1,
"bgColor is in the list of suggestions");
isnot(jsterm._autocompleteCache.indexOf("ATTRIBUTE_NODE"), -1,
"ATTRIBUTE_NODE is in the list of suggestions");
popup._panel.addEventListener("popuphidden", autocompletePopupHidden, false);
EventUtils.synthesizeKey("VK_ESCAPE", {});
}, false);
jsterm.setInputValue("document.body");
EventUtils.synthesizeKey(".", {});
}
function autocompletePopupHidden()
{
let jsterm = gHUD.jsterm;
let popup = jsterm.autocompletePopup;
let completeNode = jsterm.completeNode;
let inputNode = jsterm.inputNode;
popup._panel.removeEventListener("popuphidden", autocompletePopupHidden, false);
ok(!popup.isOpen, "popup is not open");
jsterm.once("autocomplete-updated", function() {
is(completeNode.value, testStr + "dy", "autocomplete shows document.body");
testPropertyPanel();
});
let inputStr = "document.b";
jsterm.setInputValue(inputStr);
EventUtils.synthesizeKey("o", {});
let testStr = inputStr.replace(/./g, " ") + " ";
}
function testPropertyPanel()
{
let jsterm = gHUD.jsterm;
jsterm.clearOutput();
jsterm.execute("document", (msg) => {
jsterm.once("variablesview-fetched", onVariablesViewReady);
let anchor = msg.querySelector(".message-body a");
EventUtils.synthesizeMouse(anchor, 2, 2, {}, gHUD.iframeWindow);
});
}
function onVariablesViewReady(aEvent, aView)
{
findVariableViewProperties(aView, [
{ name: "body", value: "<body>" },
], { webconsole: gHUD }).then(finishUp);
}
function finishUp() {
gHUD = null;
finishTest();
}
|