browser/devtools/debugger/test/browser_dbg_variables-view-frame-parameters-03.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 displays the right variables and
michael@0 6 * properties in the global scope when debugger is paused.
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(testGlobalScope)
michael@0 28 .then(expandWindowVariable)
michael@0 29 .then(testWindowVariable)
michael@0 30 .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
michael@0 31 .then(null, aError => {
michael@0 32 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
michael@0 33 });
michael@0 34
michael@0 35 EventUtils.sendMouseEvent({ type: "click" },
michael@0 36 gDebuggee.document.querySelector("button"),
michael@0 37 gDebuggee);
michael@0 38 });
michael@0 39 }
michael@0 40
michael@0 41 function expandGlobalScope() {
michael@0 42 let deferred = promise.defer();
michael@0 43
michael@0 44 let globalScope = gVariables.getScopeAtIndex(1);
michael@0 45 is(globalScope.expanded, false,
michael@0 46 "The global scope should not be expanded by default.");
michael@0 47
michael@0 48 gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve);
michael@0 49
michael@0 50 EventUtils.sendMouseEvent({ type: "mousedown" },
michael@0 51 globalScope.target.querySelector(".name"),
michael@0 52 gDebugger);
michael@0 53
michael@0 54 return deferred.promise;
michael@0 55 }
michael@0 56
michael@0 57 function testGlobalScope() {
michael@0 58 let globalScope = gVariables.getScopeAtIndex(1);
michael@0 59 is(globalScope.expanded, true,
michael@0 60 "The global scope should now be expanded.");
michael@0 61
michael@0 62 is(globalScope.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger",
michael@0 63 "Should have the right property name for 'InstallTrigger'.");
michael@0 64 is(globalScope.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl",
michael@0 65 "Should have the right property value for 'InstallTrigger'.");
michael@0 66
michael@0 67 is(globalScope.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers",
michael@0 68 "Should have the right property name for 'SpecialPowers'.");
michael@0 69 is(globalScope.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object",
michael@0 70 "Should have the right property value for 'SpecialPowers'.");
michael@0 71
michael@0 72 is(globalScope.get("window").target.querySelector(".name").getAttribute("value"), "window",
michael@0 73 "Should have the right property name for 'window'.");
michael@0 74 is(globalScope.get("window").target.querySelector(".value").getAttribute("value"),
michael@0 75 "Window \u2192 doc_frame-parameters.html",
michael@0 76 "Should have the right property value for 'window'.");
michael@0 77
michael@0 78 is(globalScope.get("document").target.querySelector(".name").getAttribute("value"), "document",
michael@0 79 "Should have the right property name for 'document'.");
michael@0 80 is(globalScope.get("document").target.querySelector(".value").getAttribute("value"),
michael@0 81 "HTMLDocument \u2192 doc_frame-parameters.html",
michael@0 82 "Should have the right property value for 'document'.");
michael@0 83
michael@0 84 is(globalScope.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined",
michael@0 85 "Should have the right property name for 'undefined'.");
michael@0 86 is(globalScope.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined",
michael@0 87 "Should have the right property value for 'undefined'.");
michael@0 88
michael@0 89 is(globalScope.get("undefined").target.querySelector(".enum").childNodes.length, 0,
michael@0 90 "Should have no child enumerable properties for 'undefined'.");
michael@0 91 is(globalScope.get("undefined").target.querySelector(".nonenum").childNodes.length, 0,
michael@0 92 "Should have no child non-enumerable properties for 'undefined'.");
michael@0 93 }
michael@0 94
michael@0 95 function expandWindowVariable() {
michael@0 96 let deferred = promise.defer();
michael@0 97
michael@0 98 let windowVar = gVariables.getScopeAtIndex(1).get("window");
michael@0 99 is(windowVar.expanded, false,
michael@0 100 "The window variable should not be expanded by default.");
michael@0 101
michael@0 102 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, deferred.resolve);
michael@0 103
michael@0 104 EventUtils.sendMouseEvent({ type: "mousedown" },
michael@0 105 windowVar.target.querySelector(".name"),
michael@0 106 gDebugger);
michael@0 107
michael@0 108 return deferred.promise;
michael@0 109 }
michael@0 110
michael@0 111 function testWindowVariable() {
michael@0 112 let windowVar = gVariables.getScopeAtIndex(1).get("window");
michael@0 113 is(windowVar.expanded, true,
michael@0 114 "The window variable should now be expanded.");
michael@0 115
michael@0 116 is(windowVar.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger",
michael@0 117 "Should have the right property name for 'InstallTrigger'.");
michael@0 118 is(windowVar.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl",
michael@0 119 "Should have the right property value for 'InstallTrigger'.");
michael@0 120
michael@0 121 is(windowVar.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers",
michael@0 122 "Should have the right property name for 'SpecialPowers'.");
michael@0 123 is(windowVar.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object",
michael@0 124 "Should have the right property value for 'SpecialPowers'.");
michael@0 125
michael@0 126 is(windowVar.get("window").target.querySelector(".name").getAttribute("value"), "window",
michael@0 127 "Should have the right property name for 'window'.");
michael@0 128 is(windowVar.get("window").target.querySelector(".value").getAttribute("value"),
michael@0 129 "Window \u2192 doc_frame-parameters.html",
michael@0 130 "Should have the right property value for 'window'.");
michael@0 131
michael@0 132 is(windowVar.get("document").target.querySelector(".name").getAttribute("value"), "document",
michael@0 133 "Should have the right property name for 'document'.");
michael@0 134 is(windowVar.get("document").target.querySelector(".value").getAttribute("value"),
michael@0 135 "HTMLDocument \u2192 doc_frame-parameters.html",
michael@0 136 "Should have the right property value for 'document'.");
michael@0 137
michael@0 138 is(windowVar.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined",
michael@0 139 "Should have the right property name for 'undefined'.");
michael@0 140 is(windowVar.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined",
michael@0 141 "Should have the right property value for 'undefined'.");
michael@0 142
michael@0 143 is(windowVar.get("undefined").target.querySelector(".enum").childNodes.length, 0,
michael@0 144 "Should have no child enumerable properties for 'undefined'.");
michael@0 145 is(windowVar.get("undefined").target.querySelector(".nonenum").childNodes.length, 0,
michael@0 146 "Should have no child non-enumerable properties for 'undefined'.");
michael@0 147 }
michael@0 148
michael@0 149 registerCleanupFunction(function() {
michael@0 150 gTab = null;
michael@0 151 gDebuggee = null;
michael@0 152 gPanel = null;
michael@0 153 gDebugger = null;
michael@0 154 gVariables = null;
michael@0 155 });

mercurial