Files
palemoon27/toolkit/devtools/debugger/test/browser_dbg_promises-allocation-stack.js
roytam1 a101af758e import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 967319 - Sort object properties in natural order in the Variables View. r=jaws (e604fc318)
- Bug 1023386 - Split and filter properties remotely for objects. r=past (b4889035f)
- Bug 1149115 - Make sure source actors are created before breakpoints are reset;r=jlong (76561a3fd)
- Bug 1154606 - improve error in debugger when loading source fails r=jsantell (3678eca90)
- Bug 1159731 - Move all Addon actor subclasses to a dedicated file. r=ejpbruel (45e012a98)
- Bug 1096294 - Display pseudo-arrays like arrays in the console; r=pbrosset (b4b129b3a)
- Bug 1169064 - Part 1: Move ObjectActor to object.js r=fitzgen (579cb4f86)
- Bug 1169064 - Part 2: Formatted object.js and removed unused protocol request arguments r=fitzgen (4f3178a6a)
- Bug 792063 - Add status console shortcut to return the previous command result;r=past (fc1317f9b)
- Bug 1169064 - Part 3: Refactor LongStringActor, createValueGrip, stringIsLong and longStripGrip from script.js to object.js r=fitzgen (ecdff41b7)
- AltiVec/VMX is 32bit only, use double cast passing uintptr_t to int to fix compilation on PPC64 (93985b589)
- Bug 1084525 - Part 7: Expose Promise life time in object grip r=fitzgen (db5000041)
- Bug 1084525 - Part 8: Expose Promise time to settle in object grip r=fitzgen (65b7beb26)
- Bug 1084525 - Part 9: Implement getDependentPromises method in ObjectClient r=fitzgen (8cc8be31d)
- Bug 1148753 - Update browser content toolbox to create a TabSources instance. r=jryans (df6bf505f)
- Bug 1050691 - Click on a function on the console should go to the debugger. r=jlongster (e0d225db1)
- Bug 1084525 - Part 10: Implement getAllocationStack method in ObjectClient r=fitzgen (199ce4dd9)
- Bug 1084525 - Part 12: Fix eslint complaints in promise.js r=fitzgen (7d0a38afe)
- Bug 1084525 - Part 13: Add test for asserting the Promise allocation stack in chrome debugging r=fitzgen (60278cf1d)
- Bug 1164564 - Refactor Promise-backend.js so it can be required as a CommonJS module on the main thread;r=paolo (7cfe3cdd9)
- Bug 1181506 - Define Cc and Ci. r=Yoric (bc3968be3)
2021-04-20 09:17:23 +08:00

82 lines
2.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that we can get a stack to a promise's allocation point.
*/
"use strict";
const TAB_URL = EXAMPLE_URL + "doc_promise-get-allocation-stack.html";
const { PromisesFront } = devtools.require("devtools/server/actors/promises");
let events = devtools.require("sdk/event/core");
function test() {
Task.spawn(function* () {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
const [ tab,, panel ] = yield initDebugger(TAB_URL);
let client = new DebuggerClient(DebuggerServer.connectPipe());
yield connect(client);
let { tabs } = yield listTabs(client);
let targetTab = findTab(tabs, TAB_URL);
yield attachTab(client, targetTab);
yield testGetAllocationStack(client, targetTab, tab);
yield close(client);
yield closeDebuggerAndFinish(panel);
}).then(null, error => {
ok(false, "Got an error: " + error.message + "\n" + error.stack);
});
}
function* testGetAllocationStack(client, form, tab) {
let front = PromisesFront(client, form);
yield front.attach();
yield front.listPromises();
// Get the grip for promise p
let onNewPromise = new Promise(resolve => {
events.on(front, "new-promises", promises => {
for (let p of promises) {
if (p.preview.ownProperties.name &&
p.preview.ownProperties.name.value === "p") {
resolve(p);
}
}
});
});
callInTab(tab, "makePromises");
let grip = yield onNewPromise;
ok(grip, "Found our promise p");
let objectClient = new ObjectClient(client, grip);
ok(objectClient, "Got Object Client");
yield new Promise(resolve => {
objectClient.getPromiseAllocationStack(response => {
ok(response.allocationStack.length, "Got promise allocation stack.");
for (let stack of response.allocationStack) {
is(stack.source.url, TAB_URL, "Got correct source URL.");
is(stack.functionDisplayName, "makePromises",
"Got correct function display name.");
is(typeof stack.line, "number", "Expect stack line to be a number.");
is(typeof stack.column, "number",
"Expect stack column to be a number.");
}
resolve();
});
});
yield front.detach();
}