1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_output_01.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,98 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/publicdomain/zero/1.0/ 1.7 + */ 1.8 + 1.9 +// Test the webconsole output for various types of objects. 1.10 + 1.11 +const TEST_URI = "data:text/html;charset=utf8,test for console output - 01"; 1.12 + 1.13 +let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {}); 1.14 + 1.15 +let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH; 1.16 +let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH; 1.17 +DebuggerServer.LONG_STRING_LENGTH = 100; 1.18 +DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50; 1.19 + 1.20 +let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a"); 1.21 +let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); 1.22 + 1.23 +let inputTests = [ 1.24 + // 0 1.25 + { 1.26 + input: "'hello \\nfrom \\rthe \\\"string world!'", 1.27 + output: "\"hello \nfrom \rthe \"string world!\"", 1.28 + }, 1.29 + 1.30 + // 1 1.31 + { 1.32 + // unicode test 1.33 + input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'", 1.34 + output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"", 1.35 + }, 1.36 + 1.37 + // 2 1.38 + { 1.39 + input: "'" + longString + "'", 1.40 + output: '"' + initialString + "\"[\u2026]", 1.41 + printOutput: initialString, 1.42 + }, 1.43 + 1.44 + // 3 1.45 + { 1.46 + input: "''", 1.47 + output: '""', 1.48 + printOutput: '""', 1.49 + }, 1.50 + 1.51 + // 4 1.52 + { 1.53 + input: "0", 1.54 + output: "0", 1.55 + }, 1.56 + 1.57 + // 5 1.58 + { 1.59 + input: "'0'", 1.60 + output: '"0"', 1.61 + }, 1.62 + 1.63 + // 6 1.64 + { 1.65 + input: "42", 1.66 + output: "42", 1.67 + }, 1.68 + 1.69 + // 7 1.70 + { 1.71 + input: "'42'", 1.72 + output: '"42"', 1.73 + }, 1.74 + 1.75 + // 8 1.76 + { 1.77 + input: "/foobar/", 1.78 + output: "/foobar/", 1.79 + inspectable: true, 1.80 + }, 1.81 +]; 1.82 + 1.83 +longString = initialString = null; 1.84 + 1.85 +function test() { 1.86 + registerCleanupFunction(() => { 1.87 + DebuggerServer.LONG_STRING_LENGTH = LONG_STRING_LENGTH; 1.88 + DebuggerServer.LONG_STRING_INITIAL_LENGTH = LONG_STRING_INITIAL_LENGTH; 1.89 + }); 1.90 + 1.91 + Task.spawn(function*() { 1.92 + let {tab} = yield loadTab(TEST_URI); 1.93 + let hud = yield openConsole(tab); 1.94 + return checkOutputForInputs(hud, inputTests); 1.95 + }).then(finishUp); 1.96 +} 1.97 + 1.98 +function finishUp() { 1.99 + inputTests = null; 1.100 + finishTest(); 1.101 +}