1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/webconsole/test/browser_webconsole_output_02.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,160 @@ 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 = "http://example.com/browser/browser/devtools/webconsole/test/test-console-output-02.html"; 1.12 + 1.13 +let inputTests = [ 1.14 + // 0 - native named function 1.15 + { 1.16 + input: "document.getElementById", 1.17 + output: "function getElementById()", 1.18 + printOutput: "function getElementById() {\n [native code]\n}", 1.19 + inspectable: true, 1.20 + variablesViewLabel: "getElementById()", 1.21 + }, 1.22 + 1.23 + // 1 - anonymous function 1.24 + { 1.25 + input: "(function() { return 42; })", 1.26 + output: "function ()", 1.27 + printOutput: "function () { return 42; }", 1.28 + inspectable: true, 1.29 + }, 1.30 + 1.31 + // 2 - named function 1.32 + { 1.33 + input: "window.testfn1", 1.34 + output: "function testfn1()", 1.35 + printOutput: "function testfn1() { return 42; }", 1.36 + inspectable: true, 1.37 + variablesViewLabel: "testfn1()", 1.38 + }, 1.39 + 1.40 + // 3 - anonymous function, but spidermonkey gives us an inferred name. 1.41 + { 1.42 + input: "testobj1.testfn2", 1.43 + output: "function testobj1.testfn2()", 1.44 + printOutput: "function () { return 42; }", 1.45 + inspectable: true, 1.46 + variablesViewLabel: "testobj1.testfn2()", 1.47 + }, 1.48 + 1.49 + // 4 - named function with custom display name 1.50 + { 1.51 + input: "window.testfn3", 1.52 + output: "function testfn3DisplayName()", 1.53 + printOutput: "function testfn3() { return 42; }", 1.54 + inspectable: true, 1.55 + variablesViewLabel: "testfn3DisplayName()", 1.56 + }, 1.57 + 1.58 + // 5 - basic array 1.59 + { 1.60 + input: "window.array1", 1.61 + output: 'Array [ 1, 2, 3, "a", "b", "c", "4", "5" ]', 1.62 + printOutput: "1,2,3,a,b,c,4,5", 1.63 + inspectable: true, 1.64 + variablesViewLabel: "Array[8]", 1.65 + }, 1.66 + 1.67 + // 6 - array with objects 1.68 + { 1.69 + input: "window.array2", 1.70 + output: 'Array [ "a", HTMLDocument \u2192 test-console-output-02.html, <body>, ' + 1.71 + "DOMStringMap[0], DOMTokenList[0] ]", 1.72 + printOutput: '"a,[object HTMLDocument],[object HTMLBodyElement],' + 1.73 + '[object DOMStringMap],"', 1.74 + inspectable: true, 1.75 + variablesViewLabel: "Array[5]", 1.76 + }, 1.77 + 1.78 + // 7 - array with more than 10 elements 1.79 + { 1.80 + input: "window.array3", 1.81 + output: 'Array [ 1, Window \u2192 test-console-output-02.html, null, "a", "b", ' + 1.82 + 'undefined, false, "", -Infinity, testfn3DisplayName(), 3 more\u2026 ]', 1.83 + printOutput: '"1,[object Window],,a,b,,false,,-Infinity,' + 1.84 + 'function testfn3() { return 42; },[object Object],foo,bar"', 1.85 + inspectable: true, 1.86 + variablesViewLabel: "Array[13]", 1.87 + }, 1.88 + 1.89 + // 8 - array with holes and a cyclic reference 1.90 + { 1.91 + input: "window.array4", 1.92 + output: 'Array [ , , , , , "test", Array[7] ]', 1.93 + printOutput: '",,,,,test,"', 1.94 + inspectable: true, 1.95 + variablesViewLabel: "Array[7]", 1.96 + }, 1.97 + 1.98 + // 9 1.99 + { 1.100 + input: "window.typedarray1", 1.101 + output: 'Int32Array [ 1, 287, 8651, 40983, 8754 ]', 1.102 + printOutput: "[object Int32Array]", 1.103 + inspectable: true, 1.104 + variablesViewLabel: "Int32Array[5]", 1.105 + }, 1.106 + 1.107 + // 10 - Set with cyclic reference 1.108 + { 1.109 + input: "window.set1", 1.110 + output: 'Set [ 1, 2, null, Array[13], "a", "b", undefined, <head>, Set[9] ]', 1.111 + printOutput: "[object Set]", 1.112 + inspectable: true, 1.113 + variablesViewLabel: "Set[9]", 1.114 + }, 1.115 + 1.116 + // 11 - Object with cyclic reference and a getter 1.117 + { 1.118 + input: "window.testobj2", 1.119 + output: 'Object { a: "b", c: "d", e: 1, f: "2", foo: Object, bar: Object, ' + 1.120 + "getterTest: Getter }", 1.121 + printOutput: "[object Object]", 1.122 + inspectable: true, 1.123 + variablesViewLabel: "Object", 1.124 + }, 1.125 + 1.126 + // 12 - Object with more than 10 properties 1.127 + { 1.128 + input: "window.testobj3", 1.129 + output: 'Object { a: "b", c: "d", e: 1, f: "2", g: true, h: null, i: undefined, ' + 1.130 + 'j: "", k: StyleSheetList[0], l: NodeList[5], 2 more\u2026 }', 1.131 + printOutput: "[object Object]", 1.132 + inspectable: true, 1.133 + variablesViewLabel: "Object", 1.134 + }, 1.135 + 1.136 + // 13 - Object with a non-enumerable property that we do not show 1.137 + { 1.138 + input: "window.testobj4", 1.139 + output: 'Object { a: "b", c: "d", 1 more\u2026 }', 1.140 + printOutput: "[object Object]", 1.141 + inspectable: true, 1.142 + variablesViewLabel: "Object", 1.143 + }, 1.144 + 1.145 + // 14 - Map with cyclic references 1.146 + { 1.147 + input: "window.map1", 1.148 + output: 'Map { a: "b", HTMLCollection[2]: Object, Map[3]: Set[9] }', 1.149 + printOutput: "[object Map]", 1.150 + inspectable: true, 1.151 + variablesViewLabel: "Map[3]", 1.152 + }, 1.153 +]; 1.154 + 1.155 +function test() { 1.156 + requestLongerTimeout(2); 1.157 + Task.spawn(function*() { 1.158 + const {tab} = yield loadTab(TEST_URI); 1.159 + const hud = yield openConsole(tab); 1.160 + yield checkOutputForInputs(hud, inputTests); 1.161 + inputTests = null; 1.162 + }).then(finishTest); 1.163 +}