michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // Tests for bug 704295 michael@0: michael@0: const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; michael@0: michael@0: function test() { michael@0: addTab(TEST_URI); michael@0: browser.addEventListener("load", function onLoad() { michael@0: browser.removeEventListener("load", onLoad, true); michael@0: openConsole(null, testCompletion); michael@0: }, true); michael@0: } michael@0: michael@0: function testCompletion(hud) { michael@0: var jsterm = hud.jsterm; michael@0: var input = jsterm.inputNode; michael@0: michael@0: // Test typing 'var d = 5;' and press RETURN michael@0: jsterm.setInputValue("var d = "); michael@0: EventUtils.synthesizeKey("5", {}); michael@0: EventUtils.synthesizeKey(";", {}); michael@0: is(input.value, "var d = 5;", "var d = 5;"); michael@0: is(jsterm.completeNode.value, "", "no completion"); michael@0: EventUtils.synthesizeKey("VK_RETURN", {}); michael@0: is(jsterm.completeNode.value, "", "clear completion on execute()"); michael@0: michael@0: // Test typing 'var a = d' and press RETURN michael@0: jsterm.setInputValue("var a = "); michael@0: EventUtils.synthesizeKey("d", {}); michael@0: is(input.value, "var a = d", "var a = d"); michael@0: is(jsterm.completeNode.value, "", "no completion"); michael@0: EventUtils.synthesizeKey("VK_RETURN", {}); michael@0: is(jsterm.completeNode.value, "", "clear completion on execute()"); michael@0: michael@0: jsterm = input = null; michael@0: finishTest(); michael@0: } michael@0: