browser/devtools/debugger/test/browser_dbg_variables-view-webidl.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 correctly displays WebIDL attributes in DOM
     6  * objects.
     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(performTest)
    28       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    29       .then(null, aError => {
    30         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    31       });
    33     EventUtils.sendMouseEvent({ type: "click" },
    34       gDebuggee.document.querySelector("button"),
    35       gDebuggee);
    36   });
    37 }
    39 function expandGlobalScope() {
    40   let deferred = promise.defer();
    42   let globalScope = gVariables.getScopeAtIndex(1);
    43   is(globalScope.expanded, false,
    44     "The global scope should not be expanded by default.");
    46   gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve);
    48   EventUtils.sendMouseEvent({ type: "mousedown" },
    49     globalScope.target.querySelector(".name"),
    50     gDebugger);
    52   return deferred.promise;
    53 }
    55 function performTest() {
    56   let deferred = promise.defer();
    57   let globalScope = gVariables.getScopeAtIndex(1);
    59   let buttonVar = globalScope.get("button");
    60   let buttonAsProtoVar = globalScope.get("buttonAsProto");
    61   let documentVar = globalScope.get("document");
    63   is(buttonVar.target.querySelector(".name").getAttribute("value"), "button",
    64     "Should have the right property name for 'button'.");
    65   is(buttonVar.target.querySelector(".value").getAttribute("value"), "<button>",
    66     "Should have the right property value for 'button'.");
    67   ok(buttonVar.target.querySelector(".value").className.contains("token-domnode"),
    68     "Should have the right token class for 'button'.");
    70   is(buttonAsProtoVar.target.querySelector(".name").getAttribute("value"), "buttonAsProto",
    71     "Should have the right property name for 'buttonAsProto'.");
    72   is(buttonAsProtoVar.target.querySelector(".value").getAttribute("value"), "Object",
    73     "Should have the right property value for 'buttonAsProto'.");
    74   ok(buttonAsProtoVar.target.querySelector(".value").className.contains("token-other"),
    75     "Should have the right token class for 'buttonAsProto'.");
    77   is(documentVar.target.querySelector(".name").getAttribute("value"), "document",
    78     "Should have the right property name for 'document'.");
    79   is(documentVar.target.querySelector(".value").getAttribute("value"),
    80     "HTMLDocument \u2192 doc_frame-parameters.html",
    81     "Should have the right property value for 'document'.");
    82   ok(documentVar.target.querySelector(".value").className.contains("token-domnode"),
    83     "Should have the right token class for 'document'.");
    85   is(buttonVar.expanded, false,
    86     "The buttonVar should not be expanded at this point.");
    87   is(buttonAsProtoVar.expanded, false,
    88     "The buttonAsProtoVar should not be expanded at this point.");
    89   is(documentVar.expanded, false,
    90     "The documentVar should not be expanded at this point.");
    92   waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => {
    93     is(buttonVar.get("type").target.querySelector(".name").getAttribute("value"), "type",
    94       "Should have the right property name for 'type'.");
    95     is(buttonVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"",
    96       "Should have the right property value for 'type'.");
    97     ok(buttonVar.get("type").target.querySelector(".value").className.contains("token-string"),
    98       "Should have the right token class for 'type'.");
   100     is(buttonVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
   101       "Should have the right property name for 'childNodes'.");
   102     is(buttonVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]",
   103       "Should have the right property value for 'childNodes'.");
   104     ok(buttonVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
   105       "Should have the right token class for 'childNodes'.");
   107     is(buttonVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
   108       "Should have the right property name for 'onclick'.");
   109     is(buttonVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)",
   110       "Should have the right property value for 'onclick'.");
   111     ok(buttonVar.get("onclick").target.querySelector(".value").className.contains("token-other"),
   112       "Should have the right token class for 'onclick'.");
   114     is(documentVar.get("title").target.querySelector(".name").getAttribute("value"), "title",
   115       "Should have the right property name for 'title'.");
   116     is(documentVar.get("title").target.querySelector(".value").getAttribute("value"), "\"Debugger test page\"",
   117       "Should have the right property value for 'title'.");
   118     ok(documentVar.get("title").target.querySelector(".value").className.contains("token-string"),
   119       "Should have the right token class for 'title'.");
   121     is(documentVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
   122       "Should have the right property name for 'childNodes'.");
   123     is(documentVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[3]",
   124       "Should have the right property value for 'childNodes'.");
   125     ok(documentVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
   126       "Should have the right token class for 'childNodes'.");
   128     is(documentVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
   129       "Should have the right property name for 'onclick'.");
   130     is(documentVar.get("onclick").target.querySelector(".value").getAttribute("value"), "null",
   131       "Should have the right property value for 'onclick'.");
   132     ok(documentVar.get("onclick").target.querySelector(".value").className.contains("token-null"),
   133       "Should have the right token class for 'onclick'.");
   135     let buttonProtoVar = buttonVar.get("__proto__");
   136     let buttonAsProtoProtoVar = buttonAsProtoVar.get("__proto__");
   137     let documentProtoVar = documentVar.get("__proto__");
   139     is(buttonProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   140       "Should have the right property name for '__proto__'.");
   141     is(buttonProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype",
   142       "Should have the right property value for '__proto__'.");
   143     ok(buttonProtoVar.target.querySelector(".value").className.contains("token-other"),
   144       "Should have the right token class for '__proto__'.");
   146     is(buttonAsProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   147       "Should have the right property name for '__proto__'.");
   148     is(buttonAsProtoProtoVar.target.querySelector(".value").getAttribute("value"), "<button>",
   149       "Should have the right property value for '__proto__'.");
   150     ok(buttonAsProtoProtoVar.target.querySelector(".value").className.contains("token-domnode"),
   151       "Should have the right token class for '__proto__'.");
   153     is(documentProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   154       "Should have the right property name for '__proto__'.");
   155     is(documentProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLDocumentPrototype",
   156       "Should have the right property value for '__proto__'.");
   157     ok(documentProtoVar.target.querySelector(".value").className.contains("token-other"),
   158       "Should have the right token class for '__proto__'.");
   160     is(buttonProtoVar.expanded, false,
   161       "The buttonProtoVar should not be expanded at this point.");
   162     is(buttonAsProtoProtoVar.expanded, false,
   163       "The buttonAsProtoProtoVar should not be expanded at this point.");
   164     is(documentProtoVar.expanded, false,
   165       "The documentProtoVar should not be expanded at this point.");
   167     waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 3).then(() => {
   168       is(buttonAsProtoProtoVar.get("type").target.querySelector(".name").getAttribute("value"), "type",
   169         "Should have the right property name for 'type'.");
   170       is(buttonAsProtoProtoVar.get("type").target.querySelector(".value").getAttribute("value"), "\"submit\"",
   171         "Should have the right property value for 'type'.");
   172       ok(buttonAsProtoProtoVar.get("type").target.querySelector(".value").className.contains("token-string"),
   173         "Should have the right token class for 'type'.");
   175       is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".name").getAttribute("value"), "childNodes",
   176         "Should have the right property name for 'childNodes'.");
   177       is(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").getAttribute("value"), "NodeList[1]",
   178         "Should have the right property value for 'childNodes'.");
   179       ok(buttonAsProtoProtoVar.get("childNodes").target.querySelector(".value").className.contains("token-other"),
   180         "Should have the right token class for 'childNodes'.");
   182       is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".name").getAttribute("value"), "onclick",
   183         "Should have the right property name for 'onclick'.");
   184       is(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").getAttribute("value"), "onclick(event)",
   185         "Should have the right property value for 'onclick'.");
   186       ok(buttonAsProtoProtoVar.get("onclick").target.querySelector(".value").className.contains("token-other"),
   187         "Should have the right token class for 'onclick'.");
   189       let buttonProtoProtoVar = buttonProtoVar.get("__proto__");
   190       let buttonAsProtoProtoProtoVar = buttonAsProtoProtoVar.get("__proto__");
   191       let documentProtoProtoVar = documentProtoVar.get("__proto__");
   193       is(buttonProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   194         "Should have the right property name for '__proto__'.");
   195       is(buttonProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLElementPrototype",
   196         "Should have the right property value for '__proto__'.");
   197       ok(buttonProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
   198         "Should have the right token class for '__proto__'.");
   200       is(buttonAsProtoProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   201         "Should have the right property name for '__proto__'.");
   202       is(buttonAsProtoProtoProtoVar.target.querySelector(".value").getAttribute("value"), "HTMLButtonElementPrototype",
   203         "Should have the right property value for '__proto__'.");
   204       ok(buttonAsProtoProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
   205         "Should have the right token class for '__proto__'.");
   207       is(documentProtoProtoVar.target.querySelector(".name").getAttribute("value"), "__proto__",
   208         "Should have the right property name for '__proto__'.");
   209       is(documentProtoProtoVar.target.querySelector(".value").getAttribute("value"), "DocumentPrototype",
   210         "Should have the right property value for '__proto__'.");
   211       ok(documentProtoProtoVar.target.querySelector(".value").className.contains("token-other"),
   212         "Should have the right token class for '__proto__'.")
   214       is(buttonAsProtoProtoProtoVar.expanded, false,
   215         "The buttonAsProtoProtoProtoVar should not be expanded at this point.");
   216       is(buttonAsProtoProtoProtoVar.expanded, false,
   217         "The buttonAsProtoProtoProtoVar should not be expanded at this point.");
   218       is(documentProtoProtoVar.expanded, false,
   219         "The documentProtoProtoVar should not be expanded at this point.");
   221       deferred.resolve();
   222     });
   224     // Similarly, expand the 'button.__proto__', 'buttonAsProto.__proto__' and
   225     // 'document.__proto__' variables view nodes.
   226     buttonProtoVar.expand();
   227     buttonAsProtoProtoVar.expand();
   228     documentProtoVar.expand();
   230     is(buttonProtoVar.expanded, true,
   231       "The buttonProtoVar should be immediately marked as expanded.");
   232     is(buttonAsProtoProtoVar.expanded, true,
   233       "The buttonAsProtoProtoVar should be immediately marked as expanded.");
   234     is(documentProtoVar.expanded, true,
   235       "The documentProtoVar should be immediately marked as expanded.");
   236   });
   238   // Expand the 'button', 'buttonAsProto' and 'document' variables view nodes.
   239   // This causes their properties to be retrieved and displayed.
   240   buttonVar.expand();
   241   buttonAsProtoVar.expand();
   242   documentVar.expand();
   244   is(buttonVar.expanded, true,
   245     "The buttonVar should be immediately marked as expanded.");
   246   is(buttonAsProtoVar.expanded, true,
   247     "The buttonAsProtoVar should be immediately marked as expanded.");
   248   is(documentVar.expanded, true,
   249     "The documentVar should be immediately marked as expanded.");
   251   return deferred.promise;
   252 }
   254 registerCleanupFunction(function() {
   255   gTab = null;
   256   gDebuggee = null;
   257   gPanel = null;
   258   gDebugger = null;
   259   gVariables = null;
   260 });

mercurial