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: // Test the webconsole output for various types of objects. michael@0: michael@0: const TEST_URI = "data:text/html;charset=utf8,test for console output - 01"; michael@0: michael@0: let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); michael@0: michael@0: let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH; michael@0: let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH; michael@0: DebuggerServer.LONG_STRING_LENGTH = 100; michael@0: DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50; michael@0: michael@0: let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a"); michael@0: let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); michael@0: michael@0: let inputTests = [ michael@0: // 0 michael@0: { michael@0: input: "'hello \\nfrom \\rthe \\\"string world!'", michael@0: output: "\"hello \nfrom \rthe \"string world!\"", michael@0: }, michael@0: michael@0: // 1 michael@0: { michael@0: // unicode test michael@0: input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'", michael@0: output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"", michael@0: }, michael@0: michael@0: // 2 michael@0: { michael@0: input: "'" + longString + "'", michael@0: output: '"' + initialString + "\"[\u2026]", michael@0: printOutput: initialString, michael@0: }, michael@0: michael@0: // 3 michael@0: { michael@0: input: "''", michael@0: output: '""', michael@0: printOutput: '""', michael@0: }, michael@0: michael@0: // 4 michael@0: { michael@0: input: "0", michael@0: output: "0", michael@0: }, michael@0: michael@0: // 5 michael@0: { michael@0: input: "'0'", michael@0: output: '"0"', michael@0: }, michael@0: michael@0: // 6 michael@0: { michael@0: input: "42", michael@0: output: "42", michael@0: }, michael@0: michael@0: // 7 michael@0: { michael@0: input: "'42'", michael@0: output: '"42"', michael@0: }, michael@0: michael@0: // 8 michael@0: { michael@0: input: "/foobar/", michael@0: output: "/foobar/", michael@0: inspectable: true, michael@0: }, michael@0: ]; michael@0: michael@0: longString = initialString = null; michael@0: michael@0: function test() { michael@0: registerCleanupFunction(() => { michael@0: DebuggerServer.LONG_STRING_LENGTH = LONG_STRING_LENGTH; michael@0: DebuggerServer.LONG_STRING_INITIAL_LENGTH = LONG_STRING_INITIAL_LENGTH; michael@0: }); michael@0: michael@0: Task.spawn(function*() { michael@0: let {tab} = yield loadTab(TEST_URI); michael@0: let hud = yield openConsole(tab); michael@0: return checkOutputForInputs(hud, inputTests); michael@0: }).then(finishUp); michael@0: } michael@0: michael@0: function finishUp() { michael@0: inputTests = null; michael@0: finishTest(); michael@0: }