browser/devtools/debugger/test/browser_dbg_variables-view-large-array-buffer.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 remains responsive when faced with
     6  * huge ammounts of data.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_large-array-buffer.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    12 let gVariables, gEllipsis;
    14 function test() {
    15   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    16     gTab = aTab;
    17     gDebuggee = aDebuggee;
    18     gPanel = aPanel;
    19     gDebugger = gPanel.panelWin;
    20     gVariables = gDebugger.DebuggerView.Variables;
    21     gEllipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data;
    23     waitForSourceAndCaretAndScopes(gPanel, ".html", 23)
    24       .then(() => initialChecks())
    25       .then(() => verifyFirstLevel())
    26       .then(() => verifyNextLevels())
    27       .then(() => resumeDebuggerThenCloseAndFinish(gPanel))
    28       .then(null, aError => {
    29         ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
    30       });
    32     EventUtils.sendMouseEvent({ type: "click" },
    33       gDebuggee.document.querySelector("button"),
    34       gDebuggee);
    35   });
    36 }
    38 function initialChecks() {
    39   let localScope = gVariables.getScopeAtIndex(0);
    40   let bufferVar = localScope.get("buffer");
    41   let arrayVar = localScope.get("largeArray");
    42   let objectVar = localScope.get("largeObject");
    44   ok(bufferVar, "There should be a 'buffer' variable present in the scope.");
    45   ok(arrayVar, "There should be a 'largeArray' variable present in the scope.");
    46   ok(objectVar, "There should be a 'largeObject' variable present in the scope.");
    48   is(bufferVar.target.querySelector(".name").getAttribute("value"), "buffer",
    49     "Should have the right property name for 'buffer'.");
    50   is(bufferVar.target.querySelector(".value").getAttribute("value"), "ArrayBuffer",
    51     "Should have the right property value for 'buffer'.");
    52   ok(bufferVar.target.querySelector(".value").className.contains("token-other"),
    53     "Should have the right token class for 'buffer'.");
    55   is(arrayVar.target.querySelector(".name").getAttribute("value"), "largeArray",
    56     "Should have the right property name for 'largeArray'.");
    57   is(arrayVar.target.querySelector(".value").getAttribute("value"), "Int8Array[10000]",
    58     "Should have the right property value for 'largeArray'.");
    59   ok(arrayVar.target.querySelector(".value").className.contains("token-other"),
    60     "Should have the right token class for 'largeArray'.");
    62   is(objectVar.target.querySelector(".name").getAttribute("value"), "largeObject",
    63     "Should have the right property name for 'largeObject'.");
    64   is(objectVar.target.querySelector(".value").getAttribute("value"), "Object",
    65     "Should have the right property value for 'largeObject'.");
    66   ok(objectVar.target.querySelector(".value").className.contains("token-other"),
    67     "Should have the right token class for 'largeObject'.");
    69   is(bufferVar.expanded, false,
    70     "The 'buffer' variable shouldn't be expanded.");
    71   is(arrayVar.expanded, false,
    72     "The 'largeArray' variable shouldn't be expanded.");
    73   is(objectVar.expanded, false,
    74     "The 'largeObject' variable shouldn't be expanded.");
    76   let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 2);
    77   arrayVar.expand();
    78   objectVar.expand();
    79   return finished;
    80 }
    82 function verifyFirstLevel() {
    83   let localScope = gVariables.getScopeAtIndex(0);
    84   let arrayVar = localScope.get("largeArray");
    85   let objectVar = localScope.get("largeObject");
    87   let arrayEnums = arrayVar.target.querySelector(".variables-view-element-details.enum").childNodes;
    88   let arrayNonEnums = arrayVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
    89   is(arrayEnums.length, 0,
    90     "The 'largeArray' shouldn't contain any enumerable elements.");
    91   is(arrayNonEnums.length, 9,
    92     "The 'largeArray' should contain all the created non-enumerable elements.");
    94   let objectEnums = objectVar.target.querySelector(".variables-view-element-details.enum").childNodes;
    95   let objectNonEnums = objectVar.target.querySelector(".variables-view-element-details.nonenum").childNodes;
    96   is(objectEnums.length, 0,
    97     "The 'largeObject' shouldn't contain any enumerable elements.");
    98   is(objectNonEnums.length, 5,
    99     "The 'largeObject' should contain all the created non-enumerable elements.");
   101   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
   102     0 + gEllipsis + 1999, "The first page in the 'largeArray' is named correctly.");
   103   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
   104     "", "The first page in the 'largeArray' should not have a corresponding value.");
   105   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
   106     2000 + gEllipsis + 3999, "The second page in the 'largeArray' is named correctly.");
   107   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
   108     "", "The second page in the 'largeArray' should not have a corresponding value.");
   109   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"),
   110     4000 + gEllipsis + 5999, "The third page in the 'largeArray' is named correctly.");
   111   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[2].getAttribute("value"),
   112     "", "The third page in the 'largeArray' should not have a corresponding value.");
   113   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"),
   114     6000 + gEllipsis + 9999, "The fourth page in the 'largeArray' is named correctly.");
   115   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[3].getAttribute("value"),
   116     "", "The fourth page in the 'largeArray' should not have a corresponding value.");
   118   is(objectVar.target.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
   119     0 + gEllipsis + 1999, "The first page in the 'largeObject' is named correctly.");
   120   is(objectVar.target.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
   121     "", "The first page in the 'largeObject' should not have a corresponding value.");
   122   is(objectVar.target.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
   123     2000 + gEllipsis + 3999, "The second page in the 'largeObject' is named correctly.");
   124   is(objectVar.target.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
   125     "", "The second page in the 'largeObject' should not have a corresponding value.");
   126   is(objectVar.target.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"),
   127     4000 + gEllipsis + 5999, "The thrid page in the 'largeObject' is named correctly.");
   128   is(objectVar.target.querySelectorAll(".variables-view-property .value")[2].getAttribute("value"),
   129     "", "The thrid page in the 'largeObject' should not have a corresponding value.");
   130   is(objectVar.target.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"),
   131     6000 + gEllipsis + 9999, "The fourth page in the 'largeObject' is named correctly.");
   132   is(objectVar.target.querySelectorAll(".variables-view-property .value")[3].getAttribute("value"),
   133     "", "The fourth page in the 'largeObject' should not have a corresponding value.");
   135   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[4].getAttribute("value"),
   136     "length", "The other properties 'largeArray' are named correctly.");
   137   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[4].getAttribute("value"),
   138     "10000", "The other properties 'largeArray' have the correct value.");
   139   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[5].getAttribute("value"),
   140     "buffer", "The other properties 'largeArray' are named correctly.");
   141   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[5].getAttribute("value"),
   142     "ArrayBuffer", "The other properties 'largeArray' have the correct value.");
   143   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[6].getAttribute("value"),
   144     "byteLength", "The other properties 'largeArray' are named correctly.");
   145   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[6].getAttribute("value"),
   146     "10000", "The other properties 'largeArray' have the correct value.");
   147   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[7].getAttribute("value"),
   148     "byteOffset", "The other properties 'largeArray' are named correctly.");
   149   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[7].getAttribute("value"),
   150     "0", "The other properties 'largeArray' have the correct value.");
   151   is(arrayVar.target.querySelectorAll(".variables-view-property .name")[8].getAttribute("value"),
   152     "__proto__", "The other properties 'largeArray' are named correctly.");
   153   is(arrayVar.target.querySelectorAll(".variables-view-property .value")[8].getAttribute("value"),
   154     "Int8ArrayPrototype", "The other properties 'largeArray' have the correct value.");
   156   is(objectVar.target.querySelectorAll(".variables-view-property .name")[4].getAttribute("value"),
   157     "__proto__", "The other properties 'largeObject' are named correctly.");
   158   is(objectVar.target.querySelectorAll(".variables-view-property .value")[4].getAttribute("value"),
   159     "Object", "The other properties 'largeObject' have the correct value.");
   160 }
   162 function verifyNextLevels() {
   163   let localScope = gVariables.getScopeAtIndex(0);
   164   let objectVar = localScope.get("largeObject");
   166   let lastPage1 = objectVar.get(6000 + gEllipsis + 9999);
   167   ok(lastPage1, "The last page in the first level was retrieved successfully.");
   168   lastPage1.expand();
   170   let pageEnums1 = lastPage1.target.querySelector(".variables-view-element-details.enum").childNodes;
   171   let pageNonEnums1 = lastPage1.target.querySelector(".variables-view-element-details.nonenum").childNodes;
   172   is(pageEnums1.length, 0,
   173     "The last page in the first level shouldn't contain any enumerable elements.");
   174   is(pageNonEnums1.length, 4,
   175     "The last page in the first level should contain all the created non-enumerable elements.");
   177   is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
   178     6000 + gEllipsis + 6999, "The first page in this level named correctly (1).");
   179   is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
   180     7000 + gEllipsis + 7999, "The second page in this level named correctly (1).");
   181   is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"),
   182     8000 + gEllipsis + 8999, "The third page in this level named correctly (1).");
   183   is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"),
   184     9000 + gEllipsis + 9999, "The fourth page in this level named correctly (1).");
   186   let lastPage2 = lastPage1.get(9000 + gEllipsis + 9999);
   187   ok(lastPage2, "The last page in the second level was retrieved successfully.");
   188   lastPage2.expand();
   190   let pageEnums2 = lastPage2.target.querySelector(".variables-view-element-details.enum").childNodes;
   191   let pageNonEnums2 = lastPage2.target.querySelector(".variables-view-element-details.nonenum").childNodes;
   192   is(pageEnums2.length, 0,
   193     "The last page in the second level shouldn't contain any enumerable elements.");
   194   is(pageNonEnums2.length, 4,
   195     "The last page in the second level should contain all the created non-enumerable elements.");
   197   is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
   198     9000 + gEllipsis + 9199, "The first page in this level named correctly (2).");
   199   is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
   200     9200 + gEllipsis + 9399, "The second page in this level named correctly (2).");
   201   is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"),
   202     9400 + gEllipsis + 9599, "The third page in this level named correctly (2).");
   203   is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"),
   204     9600 + gEllipsis + 9999, "The fourth page in this level named correctly (2).");
   206   let lastPage3 = lastPage2.get(9600 + gEllipsis + 9999);
   207   ok(lastPage3, "The last page in the third level was retrieved successfully.");
   208   lastPage3.expand();
   210   let pageEnums3 = lastPage3.target.querySelector(".variables-view-element-details.enum").childNodes;
   211   let pageNonEnums3 = lastPage3.target.querySelector(".variables-view-element-details.nonenum").childNodes;
   212   is(pageEnums3.length, 400,
   213     "The last page in the third level should contain all the created enumerable elements.");
   214   is(pageNonEnums3.length, 0,
   215     "The last page in the third level shouldn't contain any non-enumerable elements.");
   217   is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"),
   218     9600, "The properties in this level are named correctly (3).");
   219   is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"),
   220     9601, "The properties in this level are named correctly (3).");
   221   is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[398].getAttribute("value"),
   222     9998, "The properties in this level are named correctly (3).");
   223   is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[399].getAttribute("value"),
   224     9999, "The properties in this level are named correctly (3).");
   226   is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"),
   227     399, "The properties in this level have the correct value (3).");
   228   is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"),
   229     398, "The properties in this level have the correct value (3).");
   230   is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[398].getAttribute("value"),
   231     1, "The properties in this level have the correct value (3).");
   232   is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[399].getAttribute("value"),
   233     0, "The properties in this level have the correct value (3).");
   234 }
   236 registerCleanupFunction(function() {
   237   gTab = null;
   238   gDebuggee = null;
   239   gPanel = null;
   240   gDebugger = null;
   241   gVariables = null;
   242   gEllipsis = null;
   243 });

mercurial