1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_output_order.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,51 @@ 1.4 +/* vim:set ts=2 sw=2 sts=2 et: */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +// Tests that any output created from calls to the console API comes after the 1.10 +// echoed JavaScript. 1.11 + 1.12 +const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console.html"; 1.13 + 1.14 +function test() { 1.15 + addTab(TEST_URI); 1.16 + browser.addEventListener("load", function onLoad() { 1.17 + browser.removeEventListener("load", onLoad, true); 1.18 + openConsole(null, testOutputOrder); 1.19 + }, true); 1.20 +} 1.21 + 1.22 +function testOutputOrder(hud) { 1.23 + let jsterm = hud.jsterm; 1.24 + let outputNode = jsterm.outputNode; 1.25 + 1.26 + jsterm.clearOutput(); 1.27 + jsterm.execute("console.log('foo', 'bar');"); 1.28 + 1.29 + waitForMessages({ 1.30 + webconsole: hud, 1.31 + messages: [{ 1.32 + text: "console.log('foo', 'bar');", 1.33 + category: CATEGORY_INPUT, 1.34 + }, 1.35 + { 1.36 + text: "undefined", 1.37 + category: CATEGORY_OUTPUT, 1.38 + }, 1.39 + { 1.40 + text: '"foo" "bar"', 1.41 + category: CATEGORY_WEBDEV, 1.42 + severity: SEVERITY_LOG, 1.43 + }], 1.44 + }).then(([function_call, result, console_message]) => { 1.45 + let fncall_node = [...function_call.matched][0]; 1.46 + let result_node = [...result.matched][0]; 1.47 + let console_message_node = [...console_message.matched][0]; 1.48 + is(fncall_node.nextElementSibling, result_node, 1.49 + "console.log() is followed by undefined"); 1.50 + is(result_node.nextElementSibling, console_message_node, 1.51 + "undefined is followed by 'foo' 'bar'"); 1.52 + finishTest(); 1.53 + }); 1.54 +}