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 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Make sure that the variables view correctly displays WebIDL attributes in DOM |
michael@0 | 6 | * objects. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gVariables; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | // Debug test slaves are a bit slow at this test. |
michael@0 | 16 | requestLongerTimeout(2); |
michael@0 | 17 | |
michael@0 | 18 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 19 | gTab = aTab; |
michael@0 | 20 | gDebuggee = aDebuggee; |
michael@0 | 21 | gPanel = aPanel; |
michael@0 | 22 | gDebugger = gPanel.panelWin; |
michael@0 | 23 | gVariables = gDebugger.DebuggerView.Variables; |
michael@0 | 24 | |
michael@0 | 25 | waitForSourceAndCaretAndScopes(gPanel, ".html", 24) |
michael@0 | 26 | .then(expandGlobalScope) |
michael@0 | 27 | .then(performTest) |
michael@0 | 28 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 29 | .then(null, aError => { |
michael@0 | 30 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 31 | }); |
michael@0 | 32 | |
michael@0 | 33 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 34 | gDebuggee.document.querySelector("button"), |
michael@0 | 35 | gDebuggee); |
michael@0 | 36 | }); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function expandGlobalScope() { |
michael@0 | 40 | let deferred = promise.defer(); |
michael@0 | 41 | |
michael@0 | 42 | let globalScope = gVariables.getScopeAtIndex(1); |
michael@0 | 43 | is(globalScope.expanded, false, |
michael@0 | 44 | "The global scope should not be expanded by default."); |
michael@0 | 45 | |
michael@0 | 46 | gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve); |
michael@0 | 47 | |
michael@0 | 48 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 49 | globalScope.target.querySelector(".name"), |
michael@0 | 50 | gDebugger); |
michael@0 | 51 | |
michael@0 | 52 | return deferred.promise; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function performTest() { |
michael@0 | 56 | let deferred = promise.defer(); |
michael@0 | 57 | let globalScope = gVariables.getScopeAtIndex(1); |
michael@0 | 58 | |
michael@0 | 59 | let buttonVar = globalScope.get("button"); |
michael@0 | 60 | let buttonAsProtoVar = globalScope.get("buttonAsProto"); |
michael@0 | 61 | let documentVar = globalScope.get("document"); |
michael@0 | 62 | |
michael@0 | 63 | is(buttonVar.target.querySelector(".name").getAttribute("value"), "button", |
michael@0 | 64 | "Should have the right property name for 'button'."); |
michael@0 | 65 | is(buttonVar.target.querySelector(".value").getAttribute("value"), "<button>", |
michael@0 | 66 | "Should have the right property value for 'button'."); |
michael@0 | 67 | ok(buttonVar.target.querySelector(".value").className.contains("token-domnode"), |
michael@0 | 68 | "Should have the right token class for 'button'."); |
michael@0 | 69 | |
michael@0 | 70 | is(buttonAsProtoVar.target.querySelector(".name").getAttribute("value"), "buttonAsProto", |
michael@0 | 71 | "Should have the right property name for 'buttonAsProto'."); |
michael@0 | 72 | is(buttonAsProtoVar.target.querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 73 | "Should have the right property value for 'buttonAsProto'."); |
michael@0 | 74 | ok(buttonAsProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 75 | "Should have the right token class for 'buttonAsProto'."); |
michael@0 | 76 | |
michael@0 | 77 | is(documentVar.target.querySelector(".name").getAttribute("value"), "document", |
michael@0 | 78 | "Should have the right property name for 'document'."); |
michael@0 | 79 | is(documentVar.target.querySelector(".value").getAttribute("value"), |
michael@0 | 80 | "HTMLDocument \u2192 doc_frame-parameters.html", |
michael@0 | 81 | "Should have the right property value for 'document'."); |
michael@0 | 82 | ok(documentVar.target.querySelector(".value").className.contains("token-domnode"), |
michael@0 | 83 | "Should have the right token class for 'document'."); |
michael@0 | 84 | |
michael@0 | 85 | is(buttonVar.expanded, false, |
michael@0 | 86 | "The buttonVar should not be expanded at this point."); |
michael@0 | 87 | is(buttonAsProtoVar.expanded, false, |
michael@0 | 88 | "The buttonAsProtoVar should not be expanded at this point."); |
michael@0 | 89 | is(documentVar.expanded, false, |
michael@0 | 90 | "The documentVar should not be expanded at this point."); |
michael@0 | 91 | |
michael@0 | 92 | waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => { |
michael@0 | 93 | is(buttonVar.get("type").target.querySelector(".name").getAttribute("value"), "type", |
michael@0 | 94 | "Should have the right property name for 'type'."); |
michael@0 | 95 | is(buttonVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"", |
michael@0 | 96 | "Should have the right property value for 'type'."); |
michael@0 | 97 | ok(buttonVar.get("type").target.querySelector(".value").className.contains("token-string"), |
michael@0 | 98 | "Should have the right token class for 'type'."); |
michael@0 | 99 | |
michael@0 | 100 | is(buttonVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes", |
michael@0 | 101 | "Should have the right property name for 'childNodes'."); |
michael@0 | 102 | is(buttonVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]", |
michael@0 | 103 | "Should have the right property value for 'childNodes'."); |
michael@0 | 104 | ok(buttonVar.get("childNodes").target.querySelector(".value").className.contains("token-other"), |
michael@0 | 105 | "Should have the right token class for 'childNodes'."); |
michael@0 | 106 | |
michael@0 | 107 | is(buttonVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick", |
michael@0 | 108 | "Should have the right property name for 'onclick'."); |
michael@0 | 109 | is(buttonVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)", |
michael@0 | 110 | "Should have the right property value for 'onclick'."); |
michael@0 | 111 | ok(buttonVar.get("onclick").target.querySelector(".value").className.contains("token-other"), |
michael@0 | 112 | "Should have the right token class for 'onclick'."); |
michael@0 | 113 | |
michael@0 | 114 | is(documentVar.get("title").target.querySelector(".name").getAttribute("value"), "title", |
michael@0 | 115 | "Should have the right property name for 'title'."); |
michael@0 | 116 | is(documentVar.get("title").target.querySelector(".value").getAttribute("value"), "\"Debugger test page\"", |
michael@0 | 117 | "Should have the right property value for 'title'."); |
michael@0 | 118 | ok(documentVar.get("title").target.querySelector(".value").className.contains("token-string"), |
michael@0 | 119 | "Should have the right token class for 'title'."); |
michael@0 | 120 | |
michael@0 | 121 | is(documentVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes", |
michael@0 | 122 | "Should have the right property name for 'childNodes'."); |
michael@0 | 123 | is(documentVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[3]", |
michael@0 | 124 | "Should have the right property value for 'childNodes'."); |
michael@0 | 125 | ok(documentVar.get("childNodes").target.querySelector(".value").className.contains("token-other"), |
michael@0 | 126 | "Should have the right token class for 'childNodes'."); |
michael@0 | 127 | |
michael@0 | 128 | is(documentVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick", |
michael@0 | 129 | "Should have the right property name for 'onclick'."); |
michael@0 | 130 | is(documentVar.get("onclick").target.querySelector(".value").getAttribute("value"), "null", |
michael@0 | 131 | "Should have the right property value for 'onclick'."); |
michael@0 | 132 | ok(documentVar.get("onclick").target.querySelector(".value").className.contains("token-null"), |
michael@0 | 133 | "Should have the right token class for 'onclick'."); |
michael@0 | 134 | |
michael@0 | 135 | let buttonProtoVar = buttonVar.get("__proto__"); |
michael@0 | 136 | let buttonAsProtoProtoVar = buttonAsProtoVar.get("__proto__"); |
michael@0 | 137 | let documentProtoVar = documentVar.get("__proto__"); |
michael@0 | 138 | |
michael@0 | 139 | is(buttonProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 140 | "Should have the right property name for '__proto__'."); |
michael@0 | 141 | is(buttonProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype", |
michael@0 | 142 | "Should have the right property value for '__proto__'."); |
michael@0 | 143 | ok(buttonProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 144 | "Should have the right token class for '__proto__'."); |
michael@0 | 145 | |
michael@0 | 146 | is(buttonAsProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 147 | "Should have the right property name for '__proto__'."); |
michael@0 | 148 | is(buttonAsProtoProtoVar.target.querySelector(".value").getAttribute("value"), "<button>", |
michael@0 | 149 | "Should have the right property value for '__proto__'."); |
michael@0 | 150 | ok(buttonAsProtoProtoVar.target.querySelector(".value").className.contains("token-domnode"), |
michael@0 | 151 | "Should have the right token class for '__proto__'."); |
michael@0 | 152 | |
michael@0 | 153 | is(documentProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 154 | "Should have the right property name for '__proto__'."); |
michael@0 | 155 | is(documentProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLDocumentPrototype", |
michael@0 | 156 | "Should have the right property value for '__proto__'."); |
michael@0 | 157 | ok(documentProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 158 | "Should have the right token class for '__proto__'."); |
michael@0 | 159 | |
michael@0 | 160 | is(buttonProtoVar.expanded, false, |
michael@0 | 161 | "The buttonProtoVar should not be expanded at this point."); |
michael@0 | 162 | is(buttonAsProtoProtoVar.expanded, false, |
michael@0 | 163 | "The buttonAsProtoProtoVar should not be expanded at this point."); |
michael@0 | 164 | is(documentProtoVar.expanded, false, |
michael@0 | 165 | "The documentProtoVar should not be expanded at this point."); |
michael@0 | 166 | |
michael@0 | 167 | waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => { |
michael@0 | 168 | is(buttonAsProtoProtoVar.get("type").target.querySelector(".name").getAttribute("value"), "type", |
michael@0 | 169 | "Should have the right property name for 'type'."); |
michael@0 | 170 | is(buttonAsProtoProtoVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"", |
michael@0 | 171 | "Should have the right property value for 'type'."); |
michael@0 | 172 | ok(buttonAsProtoProtoVar.get("type").target.querySelector(".value").className.contains("token-string"), |
michael@0 | 173 | "Should have the right token class for 'type'."); |
michael@0 | 174 | |
michael@0 | 175 | is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes", |
michael@0 | 176 | "Should have the right property name for 'childNodes'."); |
michael@0 | 177 | is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]", |
michael@0 | 178 | "Should have the right property value for 'childNodes'."); |
michael@0 | 179 | ok(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").className.contains("token-other"), |
michael@0 | 180 | "Should have the right token class for 'childNodes'."); |
michael@0 | 181 | |
michael@0 | 182 | is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick", |
michael@0 | 183 | "Should have the right property name for 'onclick'."); |
michael@0 | 184 | is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)", |
michael@0 | 185 | "Should have the right property value for 'onclick'."); |
michael@0 | 186 | ok(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").className.contains("token-other"), |
michael@0 | 187 | "Should have the right token class for 'onclick'."); |
michael@0 | 188 | |
michael@0 | 189 | let buttonProtoProtoVar = buttonProtoVar.get("__proto__"); |
michael@0 | 190 | let buttonAsProtoProtoProtoVar = buttonAsProtoProtoVar.get("__proto__"); |
michael@0 | 191 | let documentProtoProtoVar = documentProtoVar.get("__proto__"); |
michael@0 | 192 | |
michael@0 | 193 | is(buttonProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 194 | "Should have the right property name for '__proto__'."); |
michael@0 | 195 | is(buttonProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLElementPrototype", |
michael@0 | 196 | "Should have the right property value for '__proto__'."); |
michael@0 | 197 | ok(buttonProtoProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 198 | "Should have the right token class for '__proto__'."); |
michael@0 | 199 | |
michael@0 | 200 | is(buttonAsProtoProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 201 | "Should have the right property name for '__proto__'."); |
michael@0 | 202 | is(buttonAsProtoProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype", |
michael@0 | 203 | "Should have the right property value for '__proto__'."); |
michael@0 | 204 | ok(buttonAsProtoProtoProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 205 | "Should have the right token class for '__proto__'."); |
michael@0 | 206 | |
michael@0 | 207 | is(documentProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 208 | "Should have the right property name for '__proto__'."); |
michael@0 | 209 | is(documentProtoProtoVar.target.querySelector(".value").getAttribute("value"), "DocumentPrototype", |
michael@0 | 210 | "Should have the right property value for '__proto__'."); |
michael@0 | 211 | ok(documentProtoProtoVar.target.querySelector(".value").className.contains("token-other"), |
michael@0 | 212 | "Should have the right token class for '__proto__'.") |
michael@0 | 213 | |
michael@0 | 214 | is(buttonAsProtoProtoProtoVar.expanded, false, |
michael@0 | 215 | "The buttonAsProtoProtoProtoVar should not be expanded at this point."); |
michael@0 | 216 | is(buttonAsProtoProtoProtoVar.expanded, false, |
michael@0 | 217 | "The buttonAsProtoProtoProtoVar should not be expanded at this point."); |
michael@0 | 218 | is(documentProtoProtoVar.expanded, false, |
michael@0 | 219 | "The documentProtoProtoVar should not be expanded at this point."); |
michael@0 | 220 | |
michael@0 | 221 | deferred.resolve(); |
michael@0 | 222 | }); |
michael@0 | 223 | |
michael@0 | 224 | // Similarly, expand the 'button.__proto__', 'buttonAsProto.__proto__' and |
michael@0 | 225 | // 'document.__proto__' variables view nodes. |
michael@0 | 226 | buttonProtoVar.expand(); |
michael@0 | 227 | buttonAsProtoProtoVar.expand(); |
michael@0 | 228 | documentProtoVar.expand(); |
michael@0 | 229 | |
michael@0 | 230 | is(buttonProtoVar.expanded, true, |
michael@0 | 231 | "The buttonProtoVar should be immediately marked as expanded."); |
michael@0 | 232 | is(buttonAsProtoProtoVar.expanded, true, |
michael@0 | 233 | "The buttonAsProtoProtoVar should be immediately marked as expanded."); |
michael@0 | 234 | is(documentProtoVar.expanded, true, |
michael@0 | 235 | "The documentProtoVar should be immediately marked as expanded."); |
michael@0 | 236 | }); |
michael@0 | 237 | |
michael@0 | 238 | // Expand the 'button', 'buttonAsProto' and 'document' variables view nodes. |
michael@0 | 239 | // This causes their properties to be retrieved and displayed. |
michael@0 | 240 | buttonVar.expand(); |
michael@0 | 241 | buttonAsProtoVar.expand(); |
michael@0 | 242 | documentVar.expand(); |
michael@0 | 243 | |
michael@0 | 244 | is(buttonVar.expanded, true, |
michael@0 | 245 | "The buttonVar should be immediately marked as expanded."); |
michael@0 | 246 | is(buttonAsProtoVar.expanded, true, |
michael@0 | 247 | "The buttonAsProtoVar should be immediately marked as expanded."); |
michael@0 | 248 | is(documentVar.expanded, true, |
michael@0 | 249 | "The documentVar should be immediately marked as expanded."); |
michael@0 | 250 | |
michael@0 | 251 | return deferred.promise; |
michael@0 | 252 | } |
michael@0 | 253 | |
michael@0 | 254 | registerCleanupFunction(function() { |
michael@0 | 255 | gTab = null; |
michael@0 | 256 | gDebuggee = null; |
michael@0 | 257 | gPanel = null; |
michael@0 | 258 | gDebugger = null; |
michael@0 | 259 | gVariables = null; |
michael@0 | 260 | }); |