1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,155 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that the variables view displays the right variables and 1.9 + * properties in the global scope when debugger is paused. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 +let gVariables; 1.16 + 1.17 +function test() { 1.18 + // Debug test slaves are a bit slow at this test. 1.19 + requestLongerTimeout(2); 1.20 + 1.21 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.22 + gTab = aTab; 1.23 + gDebuggee = aDebuggee; 1.24 + gPanel = aPanel; 1.25 + gDebugger = gPanel.panelWin; 1.26 + gVariables = gDebugger.DebuggerView.Variables; 1.27 + 1.28 + waitForSourceAndCaretAndScopes(gPanel, ".html", 24) 1.29 + .then(expandGlobalScope) 1.30 + .then(testGlobalScope) 1.31 + .then(expandWindowVariable) 1.32 + .then(testWindowVariable) 1.33 + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) 1.34 + .then(null, aError => { 1.35 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.36 + }); 1.37 + 1.38 + EventUtils.sendMouseEvent({ type: "click" }, 1.39 + gDebuggee.document.querySelector("button"), 1.40 + gDebuggee); 1.41 + }); 1.42 +} 1.43 + 1.44 +function expandGlobalScope() { 1.45 + let deferred = promise.defer(); 1.46 + 1.47 + let globalScope = gVariables.getScopeAtIndex(1); 1.48 + is(globalScope.expanded, false, 1.49 + "The global scope should not be expanded by default."); 1.50 + 1.51 + gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve); 1.52 + 1.53 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.54 + globalScope.target.querySelector(".name"), 1.55 + gDebugger); 1.56 + 1.57 + return deferred.promise; 1.58 +} 1.59 + 1.60 +function testGlobalScope() { 1.61 + let globalScope = gVariables.getScopeAtIndex(1); 1.62 + is(globalScope.expanded, true, 1.63 + "The global scope should now be expanded."); 1.64 + 1.65 + is(globalScope.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger", 1.66 + "Should have the right property name for 'InstallTrigger'."); 1.67 + is(globalScope.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl", 1.68 + "Should have the right property value for 'InstallTrigger'."); 1.69 + 1.70 + is(globalScope.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers", 1.71 + "Should have the right property name for 'SpecialPowers'."); 1.72 + is(globalScope.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object", 1.73 + "Should have the right property value for 'SpecialPowers'."); 1.74 + 1.75 + is(globalScope.get("window").target.querySelector(".name").getAttribute("value"), "window", 1.76 + "Should have the right property name for 'window'."); 1.77 + is(globalScope.get("window").target.querySelector(".value").getAttribute("value"), 1.78 + "Window \u2192 doc_frame-parameters.html", 1.79 + "Should have the right property value for 'window'."); 1.80 + 1.81 + is(globalScope.get("document").target.querySelector(".name").getAttribute("value"), "document", 1.82 + "Should have the right property name for 'document'."); 1.83 + is(globalScope.get("document").target.querySelector(".value").getAttribute("value"), 1.84 + "HTMLDocument \u2192 doc_frame-parameters.html", 1.85 + "Should have the right property value for 'document'."); 1.86 + 1.87 + is(globalScope.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined", 1.88 + "Should have the right property name for 'undefined'."); 1.89 + is(globalScope.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined", 1.90 + "Should have the right property value for 'undefined'."); 1.91 + 1.92 + is(globalScope.get("undefined").target.querySelector(".enum").childNodes.length, 0, 1.93 + "Should have no child enumerable properties for 'undefined'."); 1.94 + is(globalScope.get("undefined").target.querySelector(".nonenum").childNodes.length, 0, 1.95 + "Should have no child non-enumerable properties for 'undefined'."); 1.96 +} 1.97 + 1.98 +function expandWindowVariable() { 1.99 + let deferred = promise.defer(); 1.100 + 1.101 + let windowVar = gVariables.getScopeAtIndex(1).get("window"); 1.102 + is(windowVar.expanded, false, 1.103 + "The window variable should not be expanded by default."); 1.104 + 1.105 + gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, deferred.resolve); 1.106 + 1.107 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.108 + windowVar.target.querySelector(".name"), 1.109 + gDebugger); 1.110 + 1.111 + return deferred.promise; 1.112 +} 1.113 + 1.114 +function testWindowVariable() { 1.115 + let windowVar = gVariables.getScopeAtIndex(1).get("window"); 1.116 + is(windowVar.expanded, true, 1.117 + "The window variable should now be expanded."); 1.118 + 1.119 + is(windowVar.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger", 1.120 + "Should have the right property name for 'InstallTrigger'."); 1.121 + is(windowVar.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl", 1.122 + "Should have the right property value for 'InstallTrigger'."); 1.123 + 1.124 + is(windowVar.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers", 1.125 + "Should have the right property name for 'SpecialPowers'."); 1.126 + is(windowVar.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object", 1.127 + "Should have the right property value for 'SpecialPowers'."); 1.128 + 1.129 + is(windowVar.get("window").target.querySelector(".name").getAttribute("value"), "window", 1.130 + "Should have the right property name for 'window'."); 1.131 + is(windowVar.get("window").target.querySelector(".value").getAttribute("value"), 1.132 + "Window \u2192 doc_frame-parameters.html", 1.133 + "Should have the right property value for 'window'."); 1.134 + 1.135 + is(windowVar.get("document").target.querySelector(".name").getAttribute("value"), "document", 1.136 + "Should have the right property name for 'document'."); 1.137 + is(windowVar.get("document").target.querySelector(".value").getAttribute("value"), 1.138 + "HTMLDocument \u2192 doc_frame-parameters.html", 1.139 + "Should have the right property value for 'document'."); 1.140 + 1.141 + is(windowVar.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined", 1.142 + "Should have the right property name for 'undefined'."); 1.143 + is(windowVar.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined", 1.144 + "Should have the right property value for 'undefined'."); 1.145 + 1.146 + is(windowVar.get("undefined").target.querySelector(".enum").childNodes.length, 0, 1.147 + "Should have no child enumerable properties for 'undefined'."); 1.148 + is(windowVar.get("undefined").target.querySelector(".nonenum").childNodes.length, 0, 1.149 + "Should have no child non-enumerable properties for 'undefined'."); 1.150 +} 1.151 + 1.152 +registerCleanupFunction(function() { 1.153 + gTab = null; 1.154 + gDebuggee = null; 1.155 + gPanel = null; 1.156 + gDebugger = null; 1.157 + gVariables = null; 1.158 +});