Bug 1605209 - Testing JSWindowActor crash annotations;r=gsvelto

Differential Revision: https://phabricator.services.mozilla.com/D70175
This commit is contained in:
David Teller 2020-04-16 08:05:45 +00:00
Родитель a6bda985ed
Коммит b59500d568
2 изменённых файлов: 105 добавлений и 0 удалений

Просмотреть файл

@ -2,6 +2,7 @@
support-files =
head.js
[browser_crash_report.js]
[browser_destroy_callbacks.js]
[browser_event_listener.js]
[browser_getActor.js]

Просмотреть файл

@ -0,0 +1,104 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
declTest("crash actor", {
allFrames: true,
async test(browser) {
if (!("@mozilla.org/toolkit/crash-reporter;1" in Cc)) {
info("Cannot test crash annotations without a crash reporter");
return;
}
{
info("Creating a new tab.");
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
let newTabBrowser = newTab.linkedBrowser;
let parent = newTabBrowser.browsingContext.currentWindowGlobal.getActor(
"Test"
);
ok(parent, "JSWindowActorParent should have value.");
await SpecialPowers.spawn(newTabBrowser, [], async function() {
let child = content.windowGlobalChild;
ok(child, "WindowGlobalChild should have value.");
is(
child.isInProcess,
false,
"Actor should be loaded in the content process."
);
// Make sure that the actor is loaded.
let actorChild = child.getActor("Test");
is(actorChild.show(), "TestChild", "actor show should have value.");
is(
actorChild.manager,
child,
"manager should match WindowGlobalChild."
);
});
info(
"Crashing from withing an actor. We should have an actor name and a message name."
);
let report = await BrowserTestUtils.crashFrame(
newTabBrowser,
/* shouldShowTabCrashPage = */ false,
/* shouldClearMinidumps = */ true,
/* browsingContext = */ null,
{ asyncCrash: false }
);
is(report.JSActorName, "BrowserTestUtils");
is(report.JSActorMessage, "BrowserTestUtils:CrashFrame");
BrowserTestUtils.removeTab(newTab);
}
{
info("Creating a new tab for async crash");
let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
let newTabBrowser = newTab.linkedBrowser;
let parent = newTabBrowser.browsingContext.currentWindowGlobal.getActor(
"Test"
);
ok(parent, "JSWindowActorParent should have value.");
await SpecialPowers.spawn(newTabBrowser, [], async function() {
let child = content.windowGlobalChild;
ok(child, "WindowGlobalChild should have value.");
is(
child.isInProcess,
false,
"Actor should be loaded in the content process."
);
// Make sure that the actor is loaded.
let actorChild = child.getActor("Test");
is(actorChild.show(), "TestChild", "actor show should have value.");
is(
actorChild.manager,
child,
"manager should match WindowGlobalChild."
);
});
info(
"Crashing from without an actor. We should have neither an actor name nor a message name."
);
let report = await BrowserTestUtils.crashFrame(
newTabBrowser,
/* shouldShowTabCrashPage = */ false,
/* shouldClearMinidumps = */ true,
/* browsingContext = */ null,
{ asyncCrash: true }
);
is(report.JSActorName, null);
is(report.JSActorMessage, null);
BrowserTestUtils.removeTab(newTab);
}
},
});