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