Wed, 31 Dec 2014 06:09:35 +0100
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 = "http://example.com/browser/browser/devtools/webconsole/test/test-console-output-02.html"; |
michael@0 | 9 | |
michael@0 | 10 | let inputTests = [ |
michael@0 | 11 | // 0 - native named function |
michael@0 | 12 | { |
michael@0 | 13 | input: "document.getElementById", |
michael@0 | 14 | output: "function getElementById()", |
michael@0 | 15 | printOutput: "function getElementById() {\n [native code]\n}", |
michael@0 | 16 | inspectable: true, |
michael@0 | 17 | variablesViewLabel: "getElementById()", |
michael@0 | 18 | }, |
michael@0 | 19 | |
michael@0 | 20 | // 1 - anonymous function |
michael@0 | 21 | { |
michael@0 | 22 | input: "(function() { return 42; })", |
michael@0 | 23 | output: "function ()", |
michael@0 | 24 | printOutput: "function () { return 42; }", |
michael@0 | 25 | inspectable: true, |
michael@0 | 26 | }, |
michael@0 | 27 | |
michael@0 | 28 | // 2 - named function |
michael@0 | 29 | { |
michael@0 | 30 | input: "window.testfn1", |
michael@0 | 31 | output: "function testfn1()", |
michael@0 | 32 | printOutput: "function testfn1() { return 42; }", |
michael@0 | 33 | inspectable: true, |
michael@0 | 34 | variablesViewLabel: "testfn1()", |
michael@0 | 35 | }, |
michael@0 | 36 | |
michael@0 | 37 | // 3 - anonymous function, but spidermonkey gives us an inferred name. |
michael@0 | 38 | { |
michael@0 | 39 | input: "testobj1.testfn2", |
michael@0 | 40 | output: "function testobj1.testfn2()", |
michael@0 | 41 | printOutput: "function () { return 42; }", |
michael@0 | 42 | inspectable: true, |
michael@0 | 43 | variablesViewLabel: "testobj1.testfn2()", |
michael@0 | 44 | }, |
michael@0 | 45 | |
michael@0 | 46 | // 4 - named function with custom display name |
michael@0 | 47 | { |
michael@0 | 48 | input: "window.testfn3", |
michael@0 | 49 | output: "function testfn3DisplayName()", |
michael@0 | 50 | printOutput: "function testfn3() { return 42; }", |
michael@0 | 51 | inspectable: true, |
michael@0 | 52 | variablesViewLabel: "testfn3DisplayName()", |
michael@0 | 53 | }, |
michael@0 | 54 | |
michael@0 | 55 | // 5 - basic array |
michael@0 | 56 | { |
michael@0 | 57 | input: "window.array1", |
michael@0 | 58 | output: 'Array [ 1, 2, 3, "a", "b", "c", "4", "5" ]', |
michael@0 | 59 | printOutput: "1,2,3,a,b,c,4,5", |
michael@0 | 60 | inspectable: true, |
michael@0 | 61 | variablesViewLabel: "Array[8]", |
michael@0 | 62 | }, |
michael@0 | 63 | |
michael@0 | 64 | // 6 - array with objects |
michael@0 | 65 | { |
michael@0 | 66 | input: "window.array2", |
michael@0 | 67 | output: 'Array [ "a", HTMLDocument \u2192 test-console-output-02.html, <body>, ' + |
michael@0 | 68 | "DOMStringMap[0], DOMTokenList[0] ]", |
michael@0 | 69 | printOutput: '"a,[object HTMLDocument],[object HTMLBodyElement],' + |
michael@0 | 70 | '[object DOMStringMap],"', |
michael@0 | 71 | inspectable: true, |
michael@0 | 72 | variablesViewLabel: "Array[5]", |
michael@0 | 73 | }, |
michael@0 | 74 | |
michael@0 | 75 | // 7 - array with more than 10 elements |
michael@0 | 76 | { |
michael@0 | 77 | input: "window.array3", |
michael@0 | 78 | output: 'Array [ 1, Window \u2192 test-console-output-02.html, null, "a", "b", ' + |
michael@0 | 79 | 'undefined, false, "", -Infinity, testfn3DisplayName(), 3 more\u2026 ]', |
michael@0 | 80 | printOutput: '"1,[object Window],,a,b,,false,,-Infinity,' + |
michael@0 | 81 | 'function testfn3() { return 42; },[object Object],foo,bar"', |
michael@0 | 82 | inspectable: true, |
michael@0 | 83 | variablesViewLabel: "Array[13]", |
michael@0 | 84 | }, |
michael@0 | 85 | |
michael@0 | 86 | // 8 - array with holes and a cyclic reference |
michael@0 | 87 | { |
michael@0 | 88 | input: "window.array4", |
michael@0 | 89 | output: 'Array [ , , , , , "test", Array[7] ]', |
michael@0 | 90 | printOutput: '",,,,,test,"', |
michael@0 | 91 | inspectable: true, |
michael@0 | 92 | variablesViewLabel: "Array[7]", |
michael@0 | 93 | }, |
michael@0 | 94 | |
michael@0 | 95 | // 9 |
michael@0 | 96 | { |
michael@0 | 97 | input: "window.typedarray1", |
michael@0 | 98 | output: 'Int32Array [ 1, 287, 8651, 40983, 8754 ]', |
michael@0 | 99 | printOutput: "[object Int32Array]", |
michael@0 | 100 | inspectable: true, |
michael@0 | 101 | variablesViewLabel: "Int32Array[5]", |
michael@0 | 102 | }, |
michael@0 | 103 | |
michael@0 | 104 | // 10 - Set with cyclic reference |
michael@0 | 105 | { |
michael@0 | 106 | input: "window.set1", |
michael@0 | 107 | output: 'Set [ 1, 2, null, Array[13], "a", "b", undefined, <head>, Set[9] ]', |
michael@0 | 108 | printOutput: "[object Set]", |
michael@0 | 109 | inspectable: true, |
michael@0 | 110 | variablesViewLabel: "Set[9]", |
michael@0 | 111 | }, |
michael@0 | 112 | |
michael@0 | 113 | // 11 - Object with cyclic reference and a getter |
michael@0 | 114 | { |
michael@0 | 115 | input: "window.testobj2", |
michael@0 | 116 | output: 'Object { a: "b", c: "d", e: 1, f: "2", foo: Object, bar: Object, ' + |
michael@0 | 117 | "getterTest: Getter }", |
michael@0 | 118 | printOutput: "[object Object]", |
michael@0 | 119 | inspectable: true, |
michael@0 | 120 | variablesViewLabel: "Object", |
michael@0 | 121 | }, |
michael@0 | 122 | |
michael@0 | 123 | // 12 - Object with more than 10 properties |
michael@0 | 124 | { |
michael@0 | 125 | input: "window.testobj3", |
michael@0 | 126 | output: 'Object { a: "b", c: "d", e: 1, f: "2", g: true, h: null, i: undefined, ' + |
michael@0 | 127 | 'j: "", k: StyleSheetList[0], l: NodeList[5], 2 more\u2026 }', |
michael@0 | 128 | printOutput: "[object Object]", |
michael@0 | 129 | inspectable: true, |
michael@0 | 130 | variablesViewLabel: "Object", |
michael@0 | 131 | }, |
michael@0 | 132 | |
michael@0 | 133 | // 13 - Object with a non-enumerable property that we do not show |
michael@0 | 134 | { |
michael@0 | 135 | input: "window.testobj4", |
michael@0 | 136 | output: 'Object { a: "b", c: "d", 1 more\u2026 }', |
michael@0 | 137 | printOutput: "[object Object]", |
michael@0 | 138 | inspectable: true, |
michael@0 | 139 | variablesViewLabel: "Object", |
michael@0 | 140 | }, |
michael@0 | 141 | |
michael@0 | 142 | // 14 - Map with cyclic references |
michael@0 | 143 | { |
michael@0 | 144 | input: "window.map1", |
michael@0 | 145 | output: 'Map { a: "b", HTMLCollection[2]: Object, Map[3]: Set[9] }', |
michael@0 | 146 | printOutput: "[object Map]", |
michael@0 | 147 | inspectable: true, |
michael@0 | 148 | variablesViewLabel: "Map[3]", |
michael@0 | 149 | }, |
michael@0 | 150 | ]; |
michael@0 | 151 | |
michael@0 | 152 | function test() { |
michael@0 | 153 | requestLongerTimeout(2); |
michael@0 | 154 | Task.spawn(function*() { |
michael@0 | 155 | const {tab} = yield loadTab(TEST_URI); |
michael@0 | 156 | const hud = yield openConsole(tab); |
michael@0 | 157 | yield checkOutputForInputs(hud, inputTests); |
michael@0 | 158 | inputTests = null; |
michael@0 | 159 | }).then(finishTest); |
michael@0 | 160 | } |