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.

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

mercurial