michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Make sure that the variables view remains responsive when faced with michael@0: * huge ammounts of data. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_large-array-buffer.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gVariables, gEllipsis; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gVariables = gDebugger.DebuggerView.Variables; michael@0: gEllipsis = Services.prefs.getComplexValue("intl.ellipsis", Ci.nsIPrefLocalizedString).data; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 23) michael@0: .then(() => initialChecks()) michael@0: .then(() => verifyFirstLevel()) michael@0: .then(() => verifyNextLevels()) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.querySelector("button"), michael@0: gDebuggee); michael@0: }); michael@0: } michael@0: michael@0: function initialChecks() { michael@0: let localScope = gVariables.getScopeAtIndex(0); michael@0: let bufferVar = localScope.get("buffer"); michael@0: let arrayVar = localScope.get("largeArray"); michael@0: let objectVar = localScope.get("largeObject"); michael@0: michael@0: ok(bufferVar, "There should be a 'buffer' variable present in the scope."); michael@0: ok(arrayVar, "There should be a 'largeArray' variable present in the scope."); michael@0: ok(objectVar, "There should be a 'largeObject' variable present in the scope."); michael@0: michael@0: is(bufferVar.target.querySelector(".name").getAttribute("value"), "buffer", michael@0: "Should have the right property name for 'buffer'."); michael@0: is(bufferVar.target.querySelector(".value").getAttribute("value"), "ArrayBuffer", michael@0: "Should have the right property value for 'buffer'."); michael@0: ok(bufferVar.target.querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'buffer'."); michael@0: michael@0: is(arrayVar.target.querySelector(".name").getAttribute("value"), "largeArray", michael@0: "Should have the right property name for 'largeArray'."); michael@0: is(arrayVar.target.querySelector(".value").getAttribute("value"), "Int8Array[10000]", michael@0: "Should have the right property value for 'largeArray'."); michael@0: ok(arrayVar.target.querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'largeArray'."); michael@0: michael@0: is(objectVar.target.querySelector(".name").getAttribute("value"), "largeObject", michael@0: "Should have the right property name for 'largeObject'."); michael@0: is(objectVar.target.querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for 'largeObject'."); michael@0: ok(objectVar.target.querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'largeObject'."); michael@0: michael@0: is(bufferVar.expanded, false, michael@0: "The 'buffer' variable shouldn't be expanded."); michael@0: is(arrayVar.expanded, false, michael@0: "The 'largeArray' variable shouldn't be expanded."); michael@0: is(objectVar.expanded, false, michael@0: "The 'largeObject' variable shouldn't be expanded."); michael@0: michael@0: let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_PROPERTIES, 2); michael@0: arrayVar.expand(); michael@0: objectVar.expand(); michael@0: return finished; michael@0: } michael@0: michael@0: function verifyFirstLevel() { michael@0: let localScope = gVariables.getScopeAtIndex(0); michael@0: let arrayVar = localScope.get("largeArray"); michael@0: let objectVar = localScope.get("largeObject"); michael@0: michael@0: let arrayEnums = arrayVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let arrayNonEnums = arrayVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: is(arrayEnums.length, 0, michael@0: "The 'largeArray' shouldn't contain any enumerable elements."); michael@0: is(arrayNonEnums.length, 9, michael@0: "The 'largeArray' should contain all the created non-enumerable elements."); michael@0: michael@0: let objectEnums = objectVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let objectNonEnums = objectVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: is(objectEnums.length, 0, michael@0: "The 'largeObject' shouldn't contain any enumerable elements."); michael@0: is(objectNonEnums.length, 5, michael@0: "The 'largeObject' should contain all the created non-enumerable elements."); michael@0: michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: 0 + gEllipsis + 1999, "The first page in the 'largeArray' is named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), michael@0: "", "The first page in the 'largeArray' should not have a corresponding value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: 2000 + gEllipsis + 3999, "The second page in the 'largeArray' is named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), michael@0: "", "The second page in the 'largeArray' should not have a corresponding value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"), michael@0: 4000 + gEllipsis + 5999, "The third page in the 'largeArray' is named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[2].getAttribute("value"), michael@0: "", "The third page in the 'largeArray' should not have a corresponding value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"), michael@0: 6000 + gEllipsis + 9999, "The fourth page in the 'largeArray' is named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[3].getAttribute("value"), michael@0: "", "The fourth page in the 'largeArray' should not have a corresponding value."); michael@0: michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: 0 + gEllipsis + 1999, "The first page in the 'largeObject' is named correctly."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), michael@0: "", "The first page in the 'largeObject' should not have a corresponding value."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: 2000 + gEllipsis + 3999, "The second page in the 'largeObject' is named correctly."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), michael@0: "", "The second page in the 'largeObject' should not have a corresponding value."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"), michael@0: 4000 + gEllipsis + 5999, "The thrid page in the 'largeObject' is named correctly."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .value")[2].getAttribute("value"), michael@0: "", "The thrid page in the 'largeObject' should not have a corresponding value."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"), michael@0: 6000 + gEllipsis + 9999, "The fourth page in the 'largeObject' is named correctly."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .value")[3].getAttribute("value"), michael@0: "", "The fourth page in the 'largeObject' should not have a corresponding value."); michael@0: michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[4].getAttribute("value"), michael@0: "length", "The other properties 'largeArray' are named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[4].getAttribute("value"), michael@0: "10000", "The other properties 'largeArray' have the correct value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[5].getAttribute("value"), michael@0: "buffer", "The other properties 'largeArray' are named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[5].getAttribute("value"), michael@0: "ArrayBuffer", "The other properties 'largeArray' have the correct value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[6].getAttribute("value"), michael@0: "byteLength", "The other properties 'largeArray' are named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[6].getAttribute("value"), michael@0: "10000", "The other properties 'largeArray' have the correct value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[7].getAttribute("value"), michael@0: "byteOffset", "The other properties 'largeArray' are named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[7].getAttribute("value"), michael@0: "0", "The other properties 'largeArray' have the correct value."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .name")[8].getAttribute("value"), michael@0: "__proto__", "The other properties 'largeArray' are named correctly."); michael@0: is(arrayVar.target.querySelectorAll(".variables-view-property .value")[8].getAttribute("value"), michael@0: "Int8ArrayPrototype", "The other properties 'largeArray' have the correct value."); michael@0: michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .name")[4].getAttribute("value"), michael@0: "__proto__", "The other properties 'largeObject' are named correctly."); michael@0: is(objectVar.target.querySelectorAll(".variables-view-property .value")[4].getAttribute("value"), michael@0: "Object", "The other properties 'largeObject' have the correct value."); michael@0: } michael@0: michael@0: function verifyNextLevels() { michael@0: let localScope = gVariables.getScopeAtIndex(0); michael@0: let objectVar = localScope.get("largeObject"); michael@0: michael@0: let lastPage1 = objectVar.get(6000 + gEllipsis + 9999); michael@0: ok(lastPage1, "The last page in the first level was retrieved successfully."); michael@0: lastPage1.expand(); michael@0: michael@0: let pageEnums1 = lastPage1.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let pageNonEnums1 = lastPage1.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: is(pageEnums1.length, 0, michael@0: "The last page in the first level shouldn't contain any enumerable elements."); michael@0: is(pageNonEnums1.length, 4, michael@0: "The last page in the first level should contain all the created non-enumerable elements."); michael@0: michael@0: is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: 6000 + gEllipsis + 6999, "The first page in this level named correctly (1)."); michael@0: is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: 7000 + gEllipsis + 7999, "The second page in this level named correctly (1)."); michael@0: is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"), michael@0: 8000 + gEllipsis + 8999, "The third page in this level named correctly (1)."); michael@0: is(lastPage1._nonenum.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"), michael@0: 9000 + gEllipsis + 9999, "The fourth page in this level named correctly (1)."); michael@0: michael@0: let lastPage2 = lastPage1.get(9000 + gEllipsis + 9999); michael@0: ok(lastPage2, "The last page in the second level was retrieved successfully."); michael@0: lastPage2.expand(); michael@0: michael@0: let pageEnums2 = lastPage2.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let pageNonEnums2 = lastPage2.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: is(pageEnums2.length, 0, michael@0: "The last page in the second level shouldn't contain any enumerable elements."); michael@0: is(pageNonEnums2.length, 4, michael@0: "The last page in the second level should contain all the created non-enumerable elements."); michael@0: michael@0: is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: 9000 + gEllipsis + 9199, "The first page in this level named correctly (2)."); michael@0: is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: 9200 + gEllipsis + 9399, "The second page in this level named correctly (2)."); michael@0: is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[2].getAttribute("value"), michael@0: 9400 + gEllipsis + 9599, "The third page in this level named correctly (2)."); michael@0: is(lastPage2._nonenum.querySelectorAll(".variables-view-property .name")[3].getAttribute("value"), michael@0: 9600 + gEllipsis + 9999, "The fourth page in this level named correctly (2)."); michael@0: michael@0: let lastPage3 = lastPage2.get(9600 + gEllipsis + 9999); michael@0: ok(lastPage3, "The last page in the third level was retrieved successfully."); michael@0: lastPage3.expand(); michael@0: michael@0: let pageEnums3 = lastPage3.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let pageNonEnums3 = lastPage3.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: is(pageEnums3.length, 400, michael@0: "The last page in the third level should contain all the created enumerable elements."); michael@0: is(pageNonEnums3.length, 0, michael@0: "The last page in the third level shouldn't contain any non-enumerable elements."); michael@0: michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), michael@0: 9600, "The properties in this level are named correctly (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[1].getAttribute("value"), michael@0: 9601, "The properties in this level are named correctly (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[398].getAttribute("value"), michael@0: 9998, "The properties in this level are named correctly (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .name")[399].getAttribute("value"), michael@0: 9999, "The properties in this level are named correctly (3)."); michael@0: michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[0].getAttribute("value"), michael@0: 399, "The properties in this level have the correct value (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[1].getAttribute("value"), michael@0: 398, "The properties in this level have the correct value (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[398].getAttribute("value"), michael@0: 1, "The properties in this level have the correct value (3)."); michael@0: is(lastPage3._enum.querySelectorAll(".variables-view-property .value")[399].getAttribute("value"), michael@0: 0, "The properties in this level have the correct value (3)."); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gVariables = null; michael@0: gEllipsis = null; michael@0: });