Bug 1614462: Part 2e - Migrate desktop-only CrashService_crash test to browser test. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D70746
This commit is contained in:
Kris Maglione 2020-04-20 20:11:46 +00:00
Родитель d1639bbfcd
Коммит e1b1f20547
10 изменённых файлов: 74 добавлений и 111 удалений

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

@ -37,14 +37,6 @@ void MessageManagerGlobal::Dump(const nsAString& aStr) {
fflush(stdout);
}
void MessageManagerGlobal::PrivateNoteIntentionalCrash(ErrorResult& aError) {
if (XRE_IsContentProcess()) {
NoteIntentionalCrash("tab");
return;
}
aError.Throw(NS_ERROR_NOT_IMPLEMENTED);
}
void MessageManagerGlobal::Atob(const nsAString& aAsciiString,
nsAString& aBase64Data, ErrorResult& aError) {
aError = nsContentUtils::Atob(aAsciiString, aBase64Data);

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

@ -110,7 +110,6 @@ class MessageManagerGlobal {
// MessageManagerGlobal
void Dump(const nsAString& aStr);
void PrivateNoteIntentionalCrash(ErrorResult& aError);
void Atob(const nsAString& aAsciiString, nsAString& aBase64Data,
ErrorResult& aError);
void Btoa(const nsAString& aBase64Data, nsAString& aAsciiString,

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

@ -388,13 +388,6 @@ interface mixin MessageManagerGlobal
*/
void dump(DOMString str);
/**
* If leak detection is enabled, print a note to the leak log that this
* process will intentionally crash.
*/
[Throws]
void privateNoteIntentionalCrash();
/**
* Ascii base64 data to binary data and vice versa
*/

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

@ -6,6 +6,8 @@ support-files =
../../media/test/short.mp4
../../media/test/owl.mp3
[browser_CrashService_crash.js]
skip-if = !crashreporter
[browser_ProcessPriorityManager.js]
skip-if = os != "win" # The Process Priority Manager is only enabled for Windows so far. Bug 1522879.
[browser_crash_oopiframe.js]

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

@ -0,0 +1,71 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Ensures that content crashes are reported to the crash service
// (nsICrashService and CrashManager.jsm).
/* eslint-disable mozilla/no-arbitrary-setTimeout */
SimpleTest.requestFlakyTimeout("untriaged");
add_task(async function() {
let tab = await BrowserTestUtils.openNewForegroundTab({
gBrowser,
forceNewProcess: true,
});
SimpleTest.expectChildProcessCrash();
let crashMan = Services.crashmanager;
// First, clear the crash record store.
info("Waiting for pruneOldCrashes");
var future = new Date(Date.now() + 1000 * 60 * 60 * 24);
await crashMan.pruneOldCrashes(future);
var crashDateMS = Date.now();
let crashPromise = BrowserTestUtils.crashFrame(tab.linkedBrowser);
// Finally, poll for the new crash record.
await new Promise((resolve, reject) => {
function tryGetCrash() {
info("Waiting for getCrashes");
crashMan.getCrashes().then(
function(crashes) {
if (crashes.length) {
is(crashes.length, 1, "There should be only one record");
var crash = crashes[0];
ok(
crash.isOfType(
crashMan.PROCESS_TYPE_CONTENT,
crashMan.CRASH_TYPE_CRASH
),
"Record should be a content crash"
);
ok(!!crash.id, "Record should have an ID");
ok(!!crash.crashDate, "Record should have a crash date");
var dateMS = crash.crashDate.valueOf();
var twoMin = 1000 * 60 * 2;
ok(
crashDateMS - twoMin <= dateMS && dateMS <= crashDateMS + twoMin,
`Record's crash date should be nowish: ` +
`now=${crashDateMS} recordDate=${dateMS}`
);
resolve();
} else {
setTimeout(tryGetCrash, 1000);
}
},
function(err) {
reject(err);
}
);
}
setTimeout(tryGetCrash, 1000);
});
await crashPromise;
await BrowserTestUtils.removeTab(tab);
});

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

@ -1,7 +1,5 @@
[DEFAULT]
[test_CrashService_crash.html]
skip-if = !(crashreporter && !e10s && (toolkit == 'gtk' || toolkit == 'cocoa' || toolkit == 'windows'))
[test_temporaryfile_stream.html]
skip-if = !e10s || toolkit == 'android' || (os == "win" && processor == "aarch64") # Bug 1525959, aarch64 due to 1531150
support-files =

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

@ -1,90 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
Ensures that content crashes are reported to the crash service
(nsICrashService and CrashManager.jsm).
-->
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">
"use strict";
SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
SpecialPowers.addPermission("browser", true, document);
SpecialPowers.pushPrefEnv({"set": [
["dom.mozBrowserFramesEnabled", true],
["network.disable.ipc.security", true],
["dom.ipc.tabs.disabled", false],
]}, function() {
var iframe = document.createElementNS("http://www.w3.org/1999/xhtml", "iframe");
iframe.setAttribute("remote", "true");
SpecialPowers.wrap(iframe).mozbrowser = true;
document.documentElement.appendChild(iframe);
SimpleTest.expectChildProcessCrash();
var crashMan =
SpecialPowers.Cu.import("resource://gre/modules/Services.jsm").
Services.crashmanager;
// First, clear the crash record store.
info("Waiting for pruneOldCrashes");
var future = new Date(Date.now() + 1000 * 60 * 60 * 24);
crashMan.pruneOldCrashes(future).then(function() {
var crashDateMS = Date.now();
// Inject a frame script that crashes the content process.
var mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
mm.loadFrameScript("data:,new " + function ContentScriptScope() {
const {ctypes} = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
let crash = function() {
let zero = new ctypes.intptr_t(8);
let badptr = ctypes.cast(zero, ctypes.PointerType(ctypes.int32_t));
badptr.contents;
};
privateNoteIntentionalCrash();
crash();
}, false);
// Finally, poll for the new crash record.
function tryGetCrash() {
info("Waiting for getCrashes");
crashMan.getCrashes().then(SpecialPowers.wrapCallback(function(crashes) {
if (crashes.length) {
is(crashes.length, 1, "There should be only one record");
var crash = crashes[0];
ok(crash.isOfType(crashMan.PROCESS_TYPE_CONTENT,
crashMan.CRASH_TYPE_CRASH),
"Record should be a content crash");
ok(!!crash.id, "Record should have an ID");
ok(!!crash.crashDate, "Record should have a crash date");
var dateMS = crash.crashDate.valueOf();
var twoMin = 1000 * 60 * 2;
ok(crashDateMS - twoMin <= dateMS &&
dateMS <= crashDateMS + twoMin,
"Record's crash date should be nowish: " +
"now=" + crashDateMS + " recordDate=" + dateMS);
SimpleTest.finish();
} else {
setTimeout(tryGetCrash, 1000);
}
}), function(err) {
ok(false, "Error getting crashes: " + err);
SimpleTest.finish();
});
}
setTimeout(tryGetCrash, 1000);
}, function() {
ok(false, "pruneOldCrashes error");
SimpleTest.finish();
});
});
</script>
</body>
</html>

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

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/* global Services, requestLongerTimeout, TestUtils, BrowserTestUtils,
ok, info, dump, is, Ci, Cu, Components, ctypes, privateNoteIntentionalCrash,
ok, info, dump, is, Ci, Cu, Components, ctypes,
gBrowser, add_task, addEventListener, removeEventListener, ContentTask */
"use strict";

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

@ -41,7 +41,6 @@ module.exports = {
is: false,
isnot: false,
ok: false,
privateNoteIntentionalCrash: false,
record: false,
registerCleanupFunction: false,
requestLongerTimeout: false,

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

@ -17,7 +17,6 @@ module.exports = {
chromeOuterWindowID: false,
content: false,
docShell: false,
privateNoteIntentionalCrash: false,
processMessageManager: false,
removeMessageListener: false,
removeWeakMessageListener: false,