browser/devtools/webconsole/test/browser_webconsole_output_01.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /*
michael@0 2 * Any copyright is dedicated to the Public Domain.
michael@0 3 * http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 */
michael@0 5
michael@0 6 // Test the webconsole output for various types of objects.
michael@0 7
michael@0 8 const TEST_URI = "data:text/html;charset=utf8,test for console output - 01";
michael@0 9
michael@0 10 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
michael@0 11
michael@0 12 let LONG_STRING_LENGTH = DebuggerServer.LONG_STRING_LENGTH;
michael@0 13 let LONG_STRING_INITIAL_LENGTH = DebuggerServer.LONG_STRING_INITIAL_LENGTH;
michael@0 14 DebuggerServer.LONG_STRING_LENGTH = 100;
michael@0 15 DebuggerServer.LONG_STRING_INITIAL_LENGTH = 50;
michael@0 16
michael@0 17 let longString = (new Array(DebuggerServer.LONG_STRING_LENGTH + 4)).join("a");
michael@0 18 let initialString = longString.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH);
michael@0 19
michael@0 20 let inputTests = [
michael@0 21 // 0
michael@0 22 {
michael@0 23 input: "'hello \\nfrom \\rthe \\\"string world!'",
michael@0 24 output: "\"hello \nfrom \rthe \"string world!\"",
michael@0 25 },
michael@0 26
michael@0 27 // 1
michael@0 28 {
michael@0 29 // unicode test
michael@0 30 input: "'\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165'",
michael@0 31 output: "\"\xFA\u1E47\u0129\xE7\xF6d\xEA \u021B\u0115\u0219\u0165\"",
michael@0 32 },
michael@0 33
michael@0 34 // 2
michael@0 35 {
michael@0 36 input: "'" + longString + "'",
michael@0 37 output: '"' + initialString + "\"[\u2026]",
michael@0 38 printOutput: initialString,
michael@0 39 },
michael@0 40
michael@0 41 // 3
michael@0 42 {
michael@0 43 input: "''",
michael@0 44 output: '""',
michael@0 45 printOutput: '""',
michael@0 46 },
michael@0 47
michael@0 48 // 4
michael@0 49 {
michael@0 50 input: "0",
michael@0 51 output: "0",
michael@0 52 },
michael@0 53
michael@0 54 // 5
michael@0 55 {
michael@0 56 input: "'0'",
michael@0 57 output: '"0"',
michael@0 58 },
michael@0 59
michael@0 60 // 6
michael@0 61 {
michael@0 62 input: "42",
michael@0 63 output: "42",
michael@0 64 },
michael@0 65
michael@0 66 // 7
michael@0 67 {
michael@0 68 input: "'42'",
michael@0 69 output: '"42"',
michael@0 70 },
michael@0 71
michael@0 72 // 8
michael@0 73 {
michael@0 74 input: "/foobar/",
michael@0 75 output: "/foobar/",
michael@0 76 inspectable: true,
michael@0 77 },
michael@0 78 ];
michael@0 79
michael@0 80 longString = initialString = null;
michael@0 81
michael@0 82 function test() {
michael@0 83 registerCleanupFunction(() => {
michael@0 84 DebuggerServer.LONG_STRING_LENGTH = LONG_STRING_LENGTH;
michael@0 85 DebuggerServer.LONG_STRING_INITIAL_LENGTH = LONG_STRING_INITIAL_LENGTH;
michael@0 86 });
michael@0 87
michael@0 88 Task.spawn(function*() {
michael@0 89 let {tab} = yield loadTab(TEST_URI);
michael@0 90 let hud = yield openConsole(tab);
michael@0 91 return checkOutputForInputs(hud, inputTests);
michael@0 92 }).then(finishUp);
michael@0 93 }
michael@0 94
michael@0 95 function finishUp() {
michael@0 96 inputTests = null;
michael@0 97 finishTest();
michael@0 98 }

mercurial