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
|
/*
* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Check that native getters and setters for DOM elements work as expected in
// variables view - bug 870220.
const TEST_URI = "data:text/html;charset=utf8,<title>bug870220</title>\n" +
"<p>hello world\n<p>native getters!";
let gWebConsole, gJSTerm, gVariablesView;
function test()
{
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, consoleOpened);
}, true);
}
function consoleOpened(hud)
{
gWebConsole = hud;
gJSTerm = hud.jsterm;
gJSTerm.execute("document");
waitForMessages({
webconsole: hud,
messages: [{
text: "HTMLDocument \u2192 data:text/html;charset=utf8",
category: CATEGORY_OUTPUT,
objects: true,
}],
}).then(onEvalResult);
}
function onEvalResult(aResults)
{
let clickable = aResults[0].clickableElements[0];
ok(clickable, "clickable object found");
gJSTerm.once("variablesview-fetched", onDocumentFetch);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
}
function onDocumentFetch(aEvent, aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
findVariableViewProperties(aVar, [
{ name: "title", value: "bug870220" },
{ name: "bgColor" },
], { webconsole: gWebConsole }).then(onDocumentPropsFound);
}
function onDocumentPropsFound(aResults)
{
let prop = aResults[1].matchedProp;
ok(prop, "matched the |bgColor| property in the variables view");
// Check that property value updates work.
updateVariablesViewProperty({
property: prop,
field: "value",
string: "'red'",
webconsole: gWebConsole,
callback: onFetchAfterBackgroundUpdate,
});
}
function onFetchAfterBackgroundUpdate(aEvent, aVar)
{
info("onFetchAfterBackgroundUpdate");
is(content.document.bgColor, "red", "document background color changed");
findVariableViewProperties(aVar, [
{ name: "bgColor", value: "red" },
], { webconsole: gWebConsole }).then(testParagraphs);
}
function testParagraphs()
{
gJSTerm.execute("$$('p')");
waitForMessages({
webconsole: gWebConsole,
messages: [{
text: "NodeList [",
category: CATEGORY_OUTPUT,
objects: true,
}],
}).then(onEvalNodeList);
}
function onEvalNodeList(aResults)
{
let clickable = aResults[0].clickableElements[0];
ok(clickable, "clickable object found");
gJSTerm.once("variablesview-fetched", onNodeListFetch);
EventUtils.synthesizeMouse(clickable, 2, 2, {}, gWebConsole.iframeWindow)
}
function onNodeListFetch(aEvent, aVar)
{
gVariablesView = aVar._variablesView;
ok(gVariablesView, "variables view object");
findVariableViewProperties(aVar, [
{ name: "0.textContent", value: /hello world/ },
{ name: "1.textContent", value: /native getters/ },
], { webconsole: gWebConsole }).then(() => {
gWebConsole = gJSTerm = gVariablesView = null;
finishTest();
});
}
|