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.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 /**
     5  * Make sure that the variables view displays the right variables and
     6  * properties in the global scope when debugger is paused.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gVariables;
    14 function test() {
    15   // Debug test slaves are a bit slow at this test.
    16   requestLongerTimeout(2);
    18   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    19     gTab = aTab;
    20     gDebuggee = aDebuggee;
    21     gPanel = aPanel;
    22     gDebugger = gPanel.panelWin;
    23     gVariables = gDebugger.DebuggerView.Variables;
    25     waitForSourceAndCaretAndScopes(gPanel, ".html", 24)
    26       .then(expandGlobalScope)
    27       .then(testGlobalScope)
    28       .then(expandWindowVariable)
    29       .then(testWindowVariable)
    30       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    31       .then(null, aError => {
    32         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    33       });
    35     EventUtils.sendMouseEvent({ type: "click" },
    36       gDebuggee.document.querySelector("button"),
    37       gDebuggee);
    38   });
    39 }
    41 function expandGlobalScope() {
    42   let deferred = promise.defer();
    44   let globalScope = gVariables.getScopeAtIndex(1);
    45   is(globalScope.expanded, false,
    46     "The global scope should not be expanded by default.");
    48   gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve);
    50   EventUtils.sendMouseEvent({ type: "mousedown" },
    51     globalScope.target.querySelector(".name"),
    52     gDebugger);
    54   return deferred.promise;
    55 }
    57 function testGlobalScope() {
    58   let globalScope = gVariables.getScopeAtIndex(1);
    59   is(globalScope.expanded, true,
    60     "The global scope should now be expanded.");
    62   is(globalScope.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger",
    63     "Should have the right property name for 'InstallTrigger'.");
    64   is(globalScope.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl",
    65     "Should have the right property value for 'InstallTrigger'.");
    67   is(globalScope.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers",
    68     "Should have the right property name for 'SpecialPowers'.");
    69   is(globalScope.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object",
    70     "Should have the right property value for 'SpecialPowers'.");
    72   is(globalScope.get("window").target.querySelector(".name").getAttribute("value"), "window",
    73     "Should have the right property name for 'window'.");
    74   is(globalScope.get("window").target.querySelector(".value").getAttribute("value"),
    75     "Window \u2192 doc_frame-parameters.html",
    76     "Should have the right property value for 'window'.");
    78   is(globalScope.get("document").target.querySelector(".name").getAttribute("value"), "document",
    79     "Should have the right property name for 'document'.");
    80   is(globalScope.get("document").target.querySelector(".value").getAttribute("value"),
    81     "HTMLDocument \u2192 doc_frame-parameters.html",
    82     "Should have the right property value for 'document'.");
    84   is(globalScope.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined",
    85     "Should have the right property name for 'undefined'.");
    86   is(globalScope.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined",
    87     "Should have the right property value for 'undefined'.");
    89   is(globalScope.get("undefined").target.querySelector(".enum").childNodes.length, 0,
    90     "Should have no child enumerable properties for 'undefined'.");
    91   is(globalScope.get("undefined").target.querySelector(".nonenum").childNodes.length, 0,
    92     "Should have no child non-enumerable properties for 'undefined'.");
    93 }
    95 function expandWindowVariable() {
    96   let deferred = promise.defer();
    98   let windowVar = gVariables.getScopeAtIndex(1).get("window");
    99   is(windowVar.expanded, false,
   100     "The window variable should not be expanded by default.");
   102   gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, deferred.resolve);
   104   EventUtils.sendMouseEvent({ type: "mousedown" },
   105     windowVar.target.querySelector(".name"),
   106     gDebugger);
   108   return deferred.promise;
   109 }
   111 function testWindowVariable() {
   112   let windowVar = gVariables.getScopeAtIndex(1).get("window");
   113   is(windowVar.expanded, true,
   114     "The window variable should now be expanded.");
   116   is(windowVar.get("InstallTrigger").target.querySelector(".name").getAttribute("value"), "InstallTrigger",
   117     "Should have the right property name for 'InstallTrigger'.");
   118   is(windowVar.get("InstallTrigger").target.querySelector(".value").getAttribute("value"), "InstallTriggerImpl",
   119     "Should have the right property value for 'InstallTrigger'.");
   121   is(windowVar.get("SpecialPowers").target.querySelector(".name").getAttribute("value"), "SpecialPowers",
   122     "Should have the right property name for 'SpecialPowers'.");
   123   is(windowVar.get("SpecialPowers").target.querySelector(".value").getAttribute("value"), "Object",
   124     "Should have the right property value for 'SpecialPowers'.");
   126   is(windowVar.get("window").target.querySelector(".name").getAttribute("value"), "window",
   127     "Should have the right property name for 'window'.");
   128   is(windowVar.get("window").target.querySelector(".value").getAttribute("value"),
   129     "Window \u2192 doc_frame-parameters.html",
   130     "Should have the right property value for 'window'.");
   132   is(windowVar.get("document").target.querySelector(".name").getAttribute("value"), "document",
   133     "Should have the right property name for 'document'.");
   134   is(windowVar.get("document").target.querySelector(".value").getAttribute("value"),
   135     "HTMLDocument \u2192 doc_frame-parameters.html",
   136     "Should have the right property value for 'document'.");
   138   is(windowVar.get("undefined").target.querySelector(".name").getAttribute("value"), "undefined",
   139     "Should have the right property name for 'undefined'.");
   140   is(windowVar.get("undefined").target.querySelector(".value").getAttribute("value"), "undefined",
   141     "Should have the right property value for 'undefined'.");
   143   is(windowVar.get("undefined").target.querySelector(".enum").childNodes.length, 0,
   144     "Should have no child enumerable properties for 'undefined'.");
   145   is(windowVar.get("undefined").target.querySelector(".nonenum").childNodes.length, 0,
   146     "Should have no child non-enumerable properties for 'undefined'.");
   147 }
   149 registerCleanupFunction(function() {
   150   gTab = null;
   151   gDebuggee = null;
   152   gPanel = null;
   153   gDebugger = null;
   154   gVariables = null;
   155 });

mercurial