зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1502128 - Migrate promises actor tests to server tests. r=yulia
MozReview-Commit-ID: JobfpedA88C Differential Revision: https://phabricator.services.mozilla.com/D13823 --HG-- rename : devtools/client/debugger/test/mochitest/doc_promise-get-allocation-stack.html => devtools/server/tests/browser/doc_promise-get-allocation-stack.html rename : devtools/client/debugger/test/mochitest/doc_promise-get-fulfillment-stack.html => devtools/server/tests/browser/doc_promise-get-fulfillment-stack.html rename : devtools/client/debugger/test/mochitest/doc_promise-get-rejection-stack.html => devtools/server/tests/browser/doc_promise-get-rejection-stack.html extra : moz-landing-system : lando
This commit is contained in:
Родитель
c091d9b683
Коммит
1b70409821
|
@ -3,25 +3,10 @@ tags = devtools
|
|||
subsuite = devtools
|
||||
skip-if = (os == 'linux' && debug && bits == 32)
|
||||
support-files =
|
||||
doc_promise-get-allocation-stack.html
|
||||
doc_promise-get-fulfillment-stack.html
|
||||
doc_promise-get-rejection-stack.html
|
||||
doc_terminate-on-tab-close.html
|
||||
head.js
|
||||
!/devtools/client/shared/test/shared-head.js
|
||||
!/devtools/client/shared/test/telemetry-test-helpers.js
|
||||
[browser_dbg_promises-allocation-stack.js]
|
||||
uses-unsafe-cpows = true
|
||||
skip-if = true
|
||||
[browser_dbg_promises-chrome-allocation-stack.js]
|
||||
uses-unsafe-cpows = true
|
||||
skip-if = true # Bug 1177730
|
||||
[browser_dbg_promises-fulfillment-stack.js]
|
||||
uses-unsafe-cpows = true
|
||||
skip-if = true
|
||||
[browser_dbg_promises-rejection-stack.js]
|
||||
uses-unsafe-cpows = true
|
||||
skip-if = true
|
||||
[browser_dbg_terminate-on-tab-close.js]
|
||||
uses-unsafe-cpows = true
|
||||
skip-if = true
|
||||
skip-if = true
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 } = require("devtools/shared/fronts/promises");
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
function test() {
|
||||
Task.spawn(function* () {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
|
||||
let options = {
|
||||
source: TAB_URL,
|
||||
line: 1
|
||||
};
|
||||
const [ tab, panel ] = yield initDebugger(TAB_URL, options);
|
||||
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
yield connect(client);
|
||||
|
||||
let { tabs } = yield listTabs(client);
|
||||
let targetTab = findTab(tabs, TAB_URL);
|
||||
yield attachTarget(client, targetTab);
|
||||
|
||||
yield testGetAllocationStack(client, targetTab, tab);
|
||||
|
||||
yield close(client);
|
||||
yield closeDebuggerAndFinish(panel);
|
||||
}).catch(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 => {
|
||||
EventEmitter.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();
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 in the chrome
|
||||
* process.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const SOURCE_URL = "browser_dbg_promises-chrome-allocation-stack.js";
|
||||
const PromisesFront = require("devtools/shared/fronts/promises");
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
const STACK_DATA = [
|
||||
{ functionDisplayName: "test/</<" },
|
||||
{ functionDisplayName: "testGetAllocationStack" },
|
||||
];
|
||||
|
||||
function test() {
|
||||
Task.spawn(function* () {
|
||||
requestLongerTimeout(10);
|
||||
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
DebuggerServer.allowChromeProcess = true;
|
||||
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
yield connect(client);
|
||||
let targetFront = yield client.mainRoot.getMainProcess();
|
||||
yield targetFront.attach();
|
||||
yield targetFront.attachThread();
|
||||
|
||||
yield testGetAllocationStack(client, chrome.form, () => {
|
||||
let p = new Promise(() => {});
|
||||
p.name = "p";
|
||||
let q = p.then();
|
||||
q.name = "q";
|
||||
let r = p.catch(() => {});
|
||||
r.name = "r";
|
||||
});
|
||||
|
||||
yield close(client);
|
||||
finish();
|
||||
}).catch(error => {
|
||||
ok(false, "Got an error: " + error.message + "\n" + error.stack);
|
||||
});
|
||||
}
|
||||
|
||||
function* testGetAllocationStack(client, form, makePromises) {
|
||||
let front = PromisesFront(client, form);
|
||||
|
||||
yield front.attach();
|
||||
yield front.listPromises();
|
||||
|
||||
// Get the grip for promise p
|
||||
let onNewPromise = new Promise(resolve => {
|
||||
EventEmitter.on(front, "new-promises", promises => {
|
||||
for (let p of promises) {
|
||||
if (p.preview.ownProperties.name &&
|
||||
p.preview.ownProperties.name.value === "p") {
|
||||
resolve(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
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 i = 0; i < STACK_DATA.length; i++) {
|
||||
let data = STACK_DATA[i];
|
||||
let stack = response.allocationStack[i];
|
||||
|
||||
ok(stack.source.url.startsWith("chrome:"), "Got a chrome source URL");
|
||||
ok(stack.source.url.endsWith(SOURCE_URL), "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"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();
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 fulfillment point.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_promise-get-fulfillment-stack.html";
|
||||
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
const TEST_DATA = [
|
||||
{
|
||||
functionDisplayName: "returnPromise/<",
|
||||
line: 19,
|
||||
column: 37
|
||||
},
|
||||
{
|
||||
functionDisplayName: "returnPromise",
|
||||
line: 19,
|
||||
column: 14
|
||||
},
|
||||
{
|
||||
functionDisplayName: "makePromise",
|
||||
line: 14,
|
||||
column: 15
|
||||
},
|
||||
];
|
||||
|
||||
function test() {
|
||||
Task.spawn(function* () {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
|
||||
let options = {
|
||||
source: TAB_URL,
|
||||
line: 1
|
||||
};
|
||||
const [ tab, panel ] = yield initDebugger(TAB_URL, options);
|
||||
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
yield connect(client);
|
||||
|
||||
let { tabs } = yield listTabs(client);
|
||||
let targetTab = findTab(tabs, TAB_URL);
|
||||
yield attachTarget(client, targetTab);
|
||||
|
||||
yield testGetFulfillmentStack(client, targetTab, tab);
|
||||
|
||||
yield close(client);
|
||||
yield closeDebuggerAndFinish(panel);
|
||||
}).catch(error => {
|
||||
ok(false, "Got an error: " + error.message + "\n" + error.stack);
|
||||
});
|
||||
}
|
||||
|
||||
function* testGetFulfillmentStack(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 => {
|
||||
EventEmitter.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, "makePromise");
|
||||
|
||||
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.getPromiseFulfillmentStack(response => {
|
||||
ok(response.fulfillmentStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (let i = 0; i < TEST_DATA.length; i++) {
|
||||
let stack = response.fulfillmentStack[i];
|
||||
let data = TEST_DATA[i];
|
||||
is(stack.source.url, TAB_URL, "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"Got correct function display name.");
|
||||
is(stack.line, data.line, "Got correct stack line number.");
|
||||
is(stack.column, data.column, "Got correct stack column number.");
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
yield front.detach();
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 rejection point.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_promise-get-rejection-stack.html";
|
||||
const { PromisesFront } = require("devtools/shared/fronts/promises");
|
||||
var EventEmitter = require("devtools/shared/event-emitter");
|
||||
|
||||
// The code in the document above leaves an uncaught rejection. This is only
|
||||
// reported to the testing framework if the code is loaded in the main process.
|
||||
if (!gMultiProcessBrowser) {
|
||||
ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", this);
|
||||
PromiseTestUtils.expectUncaughtRejection(/hello/);
|
||||
}
|
||||
|
||||
const TEST_DATA = [
|
||||
{
|
||||
functionDisplayName: "returnPromise/<",
|
||||
line: 19,
|
||||
column: 47
|
||||
},
|
||||
{
|
||||
functionDisplayName: "returnPromise",
|
||||
line: 19,
|
||||
column: 14
|
||||
},
|
||||
{
|
||||
functionDisplayName: "makePromise",
|
||||
line: 14,
|
||||
column: 15
|
||||
},
|
||||
];
|
||||
|
||||
function test() {
|
||||
Task.spawn(function* () {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
|
||||
let options = {
|
||||
source: TAB_URL,
|
||||
line: 1
|
||||
};
|
||||
const [ tab, panel ] = yield initDebugger(TAB_URL, options);
|
||||
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
yield connect(client);
|
||||
|
||||
let { tabs } = yield listTabs(client);
|
||||
let targetTab = findTab(tabs, TAB_URL);
|
||||
yield attachTarget(client, targetTab);
|
||||
|
||||
yield testGetRejectionStack(client, targetTab, tab);
|
||||
|
||||
yield close(client);
|
||||
yield closeDebuggerAndFinish(panel);
|
||||
}).catch(error => {
|
||||
ok(false, "Got an error: " + error.message + "\n" + error.stack);
|
||||
});
|
||||
}
|
||||
|
||||
function* testGetRejectionStack(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 => {
|
||||
EventEmitter.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, "makePromise");
|
||||
|
||||
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.getPromiseRejectionStack(response => {
|
||||
ok(response.rejectionStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (let i = 0; i < TEST_DATA.length; i++) {
|
||||
let stack = response.rejectionStack[i];
|
||||
let data = TEST_DATA[i];
|
||||
is(stack.source.url, TAB_URL, "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"Got correct function display name.");
|
||||
is(stack.line, data.line, "Got correct stack line number.");
|
||||
is(stack.column, data.column, "Got correct stack column number.");
|
||||
}
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
||||
yield front.detach();
|
||||
}
|
|
@ -16,22 +16,19 @@ if (!gMultiProcessBrowser) {
|
|||
|
||||
const TAB_URL = EXAMPLE_URL + "doc_terminate-on-tab-close.html";
|
||||
|
||||
function test() {
|
||||
let options = {
|
||||
add_task(async () => {
|
||||
const options = {
|
||||
source: TAB_URL,
|
||||
line: 1
|
||||
};
|
||||
initDebugger(TAB_URL, options).then(([aTab, aPanel]) => {
|
||||
const gTab = aTab;
|
||||
const gPanel = aPanel;
|
||||
const gDebugger = gPanel.panelWin;
|
||||
const { tab, panel } = await initDebugger(TAB_URL, options);
|
||||
const { gThreadClient } = panel.panelWin;
|
||||
|
||||
gDebugger.gThreadClient.addOneTimeListener("paused", () => {
|
||||
resumeDebuggerThenCloseAndFinish(gPanel).then(function () {
|
||||
ok(true, "should not throw after this point");
|
||||
});
|
||||
gThreadClient.addOneTimeListener("paused", () => {
|
||||
resumeDebuggerThenCloseAndFinish(gPanel).then(function () {
|
||||
ok(true, "should not throw after this point");
|
||||
});
|
||||
|
||||
callInTab(gTab, "debuggerThenThrow");
|
||||
});
|
||||
}
|
||||
|
||||
callInTab(gTab, "debuggerThenThrow");
|
||||
});
|
||||
|
|
|
@ -11,6 +11,9 @@ support-files =
|
|||
doc_force_gc.html
|
||||
doc_innerHTML.html
|
||||
doc_perf.html
|
||||
doc_promise-get-allocation-stack.html
|
||||
doc_promise-get-fulfillment-stack.html
|
||||
doc_promise-get-rejection-stack.html
|
||||
error-actor.js
|
||||
grid.html
|
||||
inspectedwindow-reload-target.sjs
|
||||
|
@ -102,3 +105,7 @@ skip-if = (verify && debug && (os == 'mac' || os == 'linux'))
|
|||
[browser_stylesheets_nested-iframes.js]
|
||||
[browser_register_actor.js]
|
||||
[browser_webextension_inspected_window.js]
|
||||
[browser_dbg_promises-allocation-stack.js]
|
||||
[browser_dbg_promises-chrome-allocation-stack.js]
|
||||
[browser_dbg_promises-fulfillment-stack.js]
|
||||
[browser_dbg_promises-rejection-stack.js]
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 = URL_ROOT + "doc_promise-get-allocation-stack.html";
|
||||
|
||||
const ObjectClient = require("devtools/shared/client/object-client");
|
||||
|
||||
add_task(async function test() {
|
||||
const browser = await addTab(TAB_URL);
|
||||
const tab = gBrowser.getTabForBrowser(browser);
|
||||
const target = await TargetFactory.forTab(tab);
|
||||
await target.attach();
|
||||
|
||||
await testGetAllocationStack(tab, target);
|
||||
|
||||
await target.destroy();
|
||||
});
|
||||
|
||||
async function testGetAllocationStack(tab, target) {
|
||||
const front = await target.getFront("promises");
|
||||
|
||||
await front.attach();
|
||||
await front.listPromises();
|
||||
|
||||
// Get the grip for promise p
|
||||
const onNewPromise = new Promise(resolve => {
|
||||
front.on("new-promises", promises => {
|
||||
for (const p of promises) {
|
||||
if (p.preview.ownProperties.name &&
|
||||
p.preview.ownProperties.name.value === "p") {
|
||||
resolve(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await ContentTask.spawn(tab.linkedBrowser, {}, () => {
|
||||
content.wrappedJSObject.makePromises();
|
||||
});
|
||||
|
||||
const form = await onNewPromise;
|
||||
ok(form, "Found our promise p");
|
||||
|
||||
const objectClient = new ObjectClient(target.client, form);
|
||||
ok(objectClient, "Got Object Client");
|
||||
|
||||
const response = await objectClient.getPromiseAllocationStack();
|
||||
ok(response.allocationStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (const 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.");
|
||||
}
|
||||
|
||||
await front.detach();
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 in the chrome
|
||||
* process.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const SOURCE_URL = "browser_dbg_promises-chrome-allocation-stack.js";
|
||||
|
||||
const ObjectClient = require("devtools/shared/client/object-client");
|
||||
|
||||
const STACK_DATA = [
|
||||
{ functionDisplayName: "test/<" },
|
||||
{ functionDisplayName: "testGetAllocationStack" },
|
||||
];
|
||||
|
||||
add_task(async function test() {
|
||||
requestLongerTimeout(10);
|
||||
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.registerAllActors();
|
||||
DebuggerServer.allowChromeProcess = true;
|
||||
|
||||
const client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
await client.connect();
|
||||
const targetFront = await client.mainRoot.getMainProcess();
|
||||
const target = await TargetFactory.forRemoteTab({
|
||||
client,
|
||||
activeTab: targetFront,
|
||||
chrome: true,
|
||||
});
|
||||
await target.attach();
|
||||
|
||||
await testGetAllocationStack(client, target, () => {
|
||||
const p = new Promise(() => {});
|
||||
p.name = "p";
|
||||
const q = p.then();
|
||||
q.name = "q";
|
||||
const r = p.catch(() => {});
|
||||
r.name = "r";
|
||||
});
|
||||
|
||||
await target.destroy();
|
||||
});
|
||||
|
||||
async function testGetAllocationStack(client, target, makePromises) {
|
||||
const front = await target.getFront("promises");
|
||||
|
||||
await front.attach();
|
||||
await front.listPromises();
|
||||
|
||||
// Get the grip for promise p
|
||||
const onNewPromise = new Promise(resolve => {
|
||||
front.on("new-promises", promises => {
|
||||
for (const p of promises) {
|
||||
if (p.preview.ownProperties.name &&
|
||||
p.preview.ownProperties.name.value === "p") {
|
||||
resolve(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
makePromises();
|
||||
|
||||
const form = await onNewPromise;
|
||||
ok(form, "Found our promise p");
|
||||
|
||||
const objectClient = new ObjectClient(client, form);
|
||||
ok(objectClient, "Got Object Client");
|
||||
|
||||
const response = await objectClient.getPromiseAllocationStack();
|
||||
ok(response.allocationStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (let i = 0; i < STACK_DATA.length; i++) {
|
||||
const data = STACK_DATA[i];
|
||||
const stack = response.allocationStack[i];
|
||||
|
||||
ok(stack.source.url.startsWith("chrome:"), "Got a chrome source URL");
|
||||
ok(stack.source.url.endsWith(SOURCE_URL), "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"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.");
|
||||
}
|
||||
|
||||
await front.detach();
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 fulfillment point.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = URL_ROOT + "doc_promise-get-fulfillment-stack.html";
|
||||
|
||||
const ObjectClient = require("devtools/shared/client/object-client");
|
||||
|
||||
const TEST_DATA = [
|
||||
{
|
||||
functionDisplayName: "returnPromise/<",
|
||||
line: 21,
|
||||
column: 37,
|
||||
},
|
||||
{
|
||||
functionDisplayName: "returnPromise",
|
||||
line: 21,
|
||||
column: 14,
|
||||
},
|
||||
{
|
||||
functionDisplayName: "makePromise",
|
||||
line: 16,
|
||||
column: 17,
|
||||
},
|
||||
];
|
||||
|
||||
add_task(async () => {
|
||||
const browser = await addTab(TAB_URL);
|
||||
const tab = gBrowser.getTabForBrowser(browser);
|
||||
const target = await TargetFactory.forTab(tab);
|
||||
await target.attach();
|
||||
|
||||
await testGetFulfillmentStack(tab, target);
|
||||
await target.destroy();
|
||||
});
|
||||
|
||||
async function testGetFulfillmentStack(tab, target) {
|
||||
const front = await target.getFront("promises");
|
||||
|
||||
await front.attach();
|
||||
await front.listPromises();
|
||||
|
||||
// Get the grip for promise p
|
||||
const onNewPromise = new Promise(resolve => {
|
||||
front.on("new-promises", promises => {
|
||||
for (const p of promises) {
|
||||
if (p.preview.ownProperties.name &&
|
||||
p.preview.ownProperties.name.value === "p") {
|
||||
resolve(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
|
||||
content.wrappedJSObject.makePromise();
|
||||
});
|
||||
|
||||
const form = await onNewPromise;
|
||||
ok(form, "Found our promise p");
|
||||
|
||||
const objectClient = new ObjectClient(target.client, form);
|
||||
ok(objectClient, "Got Object Client");
|
||||
|
||||
const response = await objectClient.getPromiseFulfillmentStack();
|
||||
ok(response.fulfillmentStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (let i = 0; i < TEST_DATA.length; i++) {
|
||||
const stack = response.fulfillmentStack[i];
|
||||
const data = TEST_DATA[i];
|
||||
is(stack.source.url, TAB_URL, "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"Got correct function display name.");
|
||||
is(stack.line, data.line, "Got correct stack line number.");
|
||||
is(stack.column, data.column, "Got correct stack column number.");
|
||||
}
|
||||
|
||||
await front.detach();
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
||||
/* 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 rejection point.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = URL_ROOT + "doc_promise-get-rejection-stack.html";
|
||||
|
||||
const ObjectClient = require("devtools/shared/client/object-client");
|
||||
|
||||
// The code in the document above leaves an uncaught rejection. This is only
|
||||
// reported to the testing framework if the code is loaded in the main process.
|
||||
if (!gMultiProcessBrowser) {
|
||||
ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", this);
|
||||
PromiseTestUtils.expectUncaughtRejection(/hello/);
|
||||
}
|
||||
|
||||
const TEST_DATA = [
|
||||
{
|
||||
functionDisplayName: "returnPromise/<",
|
||||
line: 21,
|
||||
column: 47,
|
||||
},
|
||||
{
|
||||
functionDisplayName: "returnPromise",
|
||||
line: 21,
|
||||
column: 14,
|
||||
},
|
||||
{
|
||||
functionDisplayName: "makePromise",
|
||||
line: 16,
|
||||
column: 17,
|
||||
},
|
||||
];
|
||||
|
||||
add_task(async () => {
|
||||
const browser = await addTab(TAB_URL);
|
||||
const tab = gBrowser.getTabForBrowser(browser);
|
||||
const target = await TargetFactory.forTab(tab);
|
||||
await target.attach();
|
||||
|
||||
await testGetRejectionStack(tab, target);
|
||||
await target.destroy();
|
||||
});
|
||||
|
||||
async function testGetRejectionStack(tab, target) {
|
||||
const front = await target.getFront("promises");
|
||||
|
||||
await front.attach();
|
||||
await front.listPromises();
|
||||
|
||||
// Get the grip for promise p
|
||||
const onNewPromise = new Promise(resolve => {
|
||||
front.on("new-promises", promises => {
|
||||
for (const p of promises) {
|
||||
if (p.preview.ownProperties.name &&
|
||||
p.preview.ownProperties.name.value === "p") {
|
||||
resolve(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
await ContentTask.spawn(tab.linkedBrowser, {}, async function() {
|
||||
content.wrappedJSObject.makePromise();
|
||||
});
|
||||
|
||||
const form = await onNewPromise;
|
||||
ok(form, "Found our promise p");
|
||||
|
||||
const objectClient = new ObjectClient(target.client, form);
|
||||
ok(objectClient, "Got Object Client");
|
||||
|
||||
const response = await objectClient.getPromiseRejectionStack();
|
||||
ok(response.rejectionStack.length, "Got promise allocation stack.");
|
||||
|
||||
for (let i = 0; i < TEST_DATA.length; i++) {
|
||||
const stack = response.rejectionStack[i];
|
||||
const data = TEST_DATA[i];
|
||||
is(stack.source.url, TAB_URL, "Got correct source URL.");
|
||||
is(stack.functionDisplayName, data.functionDisplayName,
|
||||
"Got correct function display name.");
|
||||
is(stack.line, data.line, "Got correct stack line number.");
|
||||
is(stack.column, data.column, "Got correct stack column number.");
|
||||
}
|
||||
|
||||
await front.detach();
|
||||
}
|
|
@ -10,12 +10,15 @@
|
|||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function makePromises() {
|
||||
var p = new Promise(() => {});
|
||||
const p = new Promise(() => {});
|
||||
p.name = "p";
|
||||
var q = p.then();
|
||||
const q = p.then();
|
||||
q.name = "q";
|
||||
var r = p.catch(() => {});
|
||||
const r = p.catch(() => {});
|
||||
r.name = "r";
|
||||
}
|
||||
</script>
|
|
@ -10,8 +10,10 @@
|
|||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function makePromise() {
|
||||
var p = returnPromise();
|
||||
const p = returnPromise();
|
||||
p.name = "p";
|
||||
}
|
||||
|
|
@ -10,8 +10,10 @@
|
|||
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
"use strict";
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function makePromise() {
|
||||
var p = returnPromise();
|
||||
const p = returnPromise();
|
||||
p.name = "p";
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче