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 = "http://example.com/browser/browser/devtools/webconsole/test/test-console-output-02.html"; michael@0: michael@0: let inputTests = [ michael@0: // 0 - native named function michael@0: { michael@0: input: "document.getElementById", michael@0: output: "function getElementById()", michael@0: printOutput: "function getElementById() {\n [native code]\n}", michael@0: inspectable: true, michael@0: variablesViewLabel: "getElementById()", michael@0: }, michael@0: michael@0: // 1 - anonymous function michael@0: { michael@0: input: "(function() { return 42; })", michael@0: output: "function ()", michael@0: printOutput: "function () { return 42; }", michael@0: inspectable: true, michael@0: }, michael@0: michael@0: // 2 - named function michael@0: { michael@0: input: "window.testfn1", michael@0: output: "function testfn1()", michael@0: printOutput: "function testfn1() { return 42; }", michael@0: inspectable: true, michael@0: variablesViewLabel: "testfn1()", michael@0: }, michael@0: michael@0: // 3 - anonymous function, but spidermonkey gives us an inferred name. michael@0: { michael@0: input: "testobj1.testfn2", michael@0: output: "function testobj1.testfn2()", michael@0: printOutput: "function () { return 42; }", michael@0: inspectable: true, michael@0: variablesViewLabel: "testobj1.testfn2()", michael@0: }, michael@0: michael@0: // 4 - named function with custom display name michael@0: { michael@0: input: "window.testfn3", michael@0: output: "function testfn3DisplayName()", michael@0: printOutput: "function testfn3() { return 42; }", michael@0: inspectable: true, michael@0: variablesViewLabel: "testfn3DisplayName()", michael@0: }, michael@0: michael@0: // 5 - basic array michael@0: { michael@0: input: "window.array1", michael@0: output: 'Array [ 1, 2, 3, "a", "b", "c", "4", "5" ]', michael@0: printOutput: "1,2,3,a,b,c,4,5", michael@0: inspectable: true, michael@0: variablesViewLabel: "Array[8]", michael@0: }, michael@0: michael@0: // 6 - array with objects michael@0: { michael@0: input: "window.array2", michael@0: output: 'Array [ "a", HTMLDocument \u2192 test-console-output-02.html, , ' + michael@0: "DOMStringMap[0], DOMTokenList[0] ]", michael@0: printOutput: '"a,[object HTMLDocument],[object HTMLBodyElement],' + michael@0: '[object DOMStringMap],"', michael@0: inspectable: true, michael@0: variablesViewLabel: "Array[5]", michael@0: }, michael@0: michael@0: // 7 - array with more than 10 elements michael@0: { michael@0: input: "window.array3", michael@0: output: 'Array [ 1, Window \u2192 test-console-output-02.html, null, "a", "b", ' + michael@0: 'undefined, false, "", -Infinity, testfn3DisplayName(), 3 more\u2026 ]', michael@0: printOutput: '"1,[object Window],,a,b,,false,,-Infinity,' + michael@0: 'function testfn3() { return 42; },[object Object],foo,bar"', michael@0: inspectable: true, michael@0: variablesViewLabel: "Array[13]", michael@0: }, michael@0: michael@0: // 8 - array with holes and a cyclic reference michael@0: { michael@0: input: "window.array4", michael@0: output: 'Array [ , , , , , "test", Array[7] ]', michael@0: printOutput: '",,,,,test,"', michael@0: inspectable: true, michael@0: variablesViewLabel: "Array[7]", michael@0: }, michael@0: michael@0: // 9 michael@0: { michael@0: input: "window.typedarray1", michael@0: output: 'Int32Array [ 1, 287, 8651, 40983, 8754 ]', michael@0: printOutput: "[object Int32Array]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Int32Array[5]", michael@0: }, michael@0: michael@0: // 10 - Set with cyclic reference michael@0: { michael@0: input: "window.set1", michael@0: output: 'Set [ 1, 2, null, Array[13], "a", "b", undefined, , Set[9] ]', michael@0: printOutput: "[object Set]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Set[9]", michael@0: }, michael@0: michael@0: // 11 - Object with cyclic reference and a getter michael@0: { michael@0: input: "window.testobj2", michael@0: output: 'Object { a: "b", c: "d", e: 1, f: "2", foo: Object, bar: Object, ' + michael@0: "getterTest: Getter }", michael@0: printOutput: "[object Object]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Object", michael@0: }, michael@0: michael@0: // 12 - Object with more than 10 properties michael@0: { michael@0: input: "window.testobj3", michael@0: output: 'Object { a: "b", c: "d", e: 1, f: "2", g: true, h: null, i: undefined, ' + michael@0: 'j: "", k: StyleSheetList[0], l: NodeList[5], 2 more\u2026 }', michael@0: printOutput: "[object Object]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Object", michael@0: }, michael@0: michael@0: // 13 - Object with a non-enumerable property that we do not show michael@0: { michael@0: input: "window.testobj4", michael@0: output: 'Object { a: "b", c: "d", 1 more\u2026 }', michael@0: printOutput: "[object Object]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Object", michael@0: }, michael@0: michael@0: // 14 - Map with cyclic references michael@0: { michael@0: input: "window.map1", michael@0: output: 'Map { a: "b", HTMLCollection[2]: Object, Map[3]: Set[9] }', michael@0: printOutput: "[object Map]", michael@0: inspectable: true, michael@0: variablesViewLabel: "Map[3]", michael@0: }, michael@0: ]; michael@0: michael@0: function test() { michael@0: requestLongerTimeout(2); michael@0: Task.spawn(function*() { michael@0: const {tab} = yield loadTab(TEST_URI); michael@0: const hud = yield openConsole(tab); michael@0: yield checkOutputForInputs(hud, inputTests); michael@0: inputTests = null; michael@0: }).then(finishTest); michael@0: }