зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1808500 - Automatically replace Cu.reportError with console.error (devtools). r=nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D165941
This commit is contained in:
Родитель
50d7823c0c
Коммит
c29bf3e394
|
@ -211,7 +211,6 @@ module.exports = {
|
|||
"browser/components/**",
|
||||
"browser/extensions/report-site-issue/**",
|
||||
"browser/extensions/search-detection/**",
|
||||
"devtools/**",
|
||||
"dom/push/test/mockpushserviceparent.js",
|
||||
"toolkit/**",
|
||||
],
|
||||
|
|
|
@ -292,7 +292,7 @@ function exportData(win, headers) {
|
|||
writable: true,
|
||||
});
|
||||
} catch (error) {
|
||||
Cu.reportError(error);
|
||||
console.error(error);
|
||||
}
|
||||
return { json };
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ support-files =
|
|||
shared-head.js
|
||||
test-console-iframes.html
|
||||
test-console.html
|
||||
test-cu-reporterror.js
|
||||
test-iframe1.html
|
||||
test-iframe2.html
|
||||
test-iframe3.html
|
||||
|
|
|
@ -63,7 +63,6 @@ support-files =
|
|||
test-console-table.html
|
||||
test-console-workers.html
|
||||
test-console.html
|
||||
test-cu-reporterror.js
|
||||
test-data.json
|
||||
test-data.json^headers^
|
||||
test-duplicate-error.html
|
||||
|
|
|
@ -11,10 +11,6 @@ const TEST_URI =
|
|||
"http://example.com/browser/devtools/client/webconsole/" +
|
||||
"test/browser/test-console.html?" +
|
||||
Date.now();
|
||||
const TEST_FILE =
|
||||
"chrome://mochitests/content/browser/devtools/client/" +
|
||||
"webconsole/test/browser/" +
|
||||
"test-cu-reporterror.js";
|
||||
|
||||
const TEST_XHR_ERROR_URI = `http://example.com/404.html?${Date.now()}`;
|
||||
|
||||
|
@ -95,10 +91,6 @@ async function testMessages() {
|
|||
URL.createObjectURL(blob)
|
||||
);
|
||||
|
||||
// Check Cu.reportError stack.
|
||||
// Use another js script to not depend on the test file line numbers.
|
||||
Services.scriptloader.loadSubScript(TEST_FILE, hud.iframeWindow);
|
||||
|
||||
const sandbox = new Cu.Sandbox(null, {
|
||||
wantComponents: false,
|
||||
wantGlobalProperties: ["URL", "URLSearchParams"],
|
||||
|
@ -107,12 +99,14 @@ async function testMessages() {
|
|||
`new Error("error from nuked globals");`,
|
||||
sandbox
|
||||
);
|
||||
Cu.reportError(error);
|
||||
console.error(error);
|
||||
Cu.nukeSandbox(sandbox);
|
||||
|
||||
// Check privileged error message from a content process
|
||||
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
|
||||
Cu.reportError("privileged content process error message");
|
||||
(async function() {
|
||||
throw new Error("privileged content process error message");
|
||||
})();
|
||||
});
|
||||
|
||||
// Add a message from a content window.
|
||||
|
@ -197,11 +191,6 @@ async function testMessages() {
|
|||
"message from chrome window",
|
||||
".console-api"
|
||||
);
|
||||
await checkUniqueMessageExists(
|
||||
hud,
|
||||
"error thrown from test-cu-reporterror.js via Cu.reportError()",
|
||||
".error"
|
||||
);
|
||||
await checkUniqueMessageExists(hud, "error from nuked globals", ".error");
|
||||
await checkUniqueMessageExists(
|
||||
hud,
|
||||
|
|
|
@ -87,22 +87,31 @@ add_task(async function() {
|
|||
evaluationContextSelectorButton.classList.contains("checked")
|
||||
);
|
||||
|
||||
// We can't directly throw in the script as it would be treated as an evaluation result
|
||||
// and wouldn't be hidden when switching modes.
|
||||
// Here we use an async-iife in which we throw so this will trigger the proper error
|
||||
// reporting path.
|
||||
await executeAndWaitForResultMessage(
|
||||
hud,
|
||||
`Cu.reportError("${FILTER_PREFIX}Content Cu.reportError");21+21`,
|
||||
`(async function(){
|
||||
throw new Error("${FILTER_PREFIX}Content error")
|
||||
})();
|
||||
21+21`,
|
||||
42
|
||||
);
|
||||
|
||||
// Since we run the non-fission test in second, and given we don't retrieve cached messages
|
||||
// in such case, it's okay to just cause the message to appear in this function.
|
||||
Cu.reportError(FILTER_PREFIX + "Parent Cu.reportError");
|
||||
await waitFor(() => findErrorMessage(hud, "Content error"));
|
||||
ok(true, "Error message from content process is displayed");
|
||||
|
||||
await waitFor(() => findErrorMessage(hud, "Parent Cu.reportError"));
|
||||
// Emit an error message from the parent process
|
||||
executeSoon(() => {
|
||||
expectUncaughtException();
|
||||
throw new Error(`${FILTER_PREFIX}Parent error`);
|
||||
});
|
||||
|
||||
await waitFor(() => findErrorMessage(hud, "Parent error"));
|
||||
ok(true, "Parent process message is displayed");
|
||||
|
||||
await waitFor(() => findErrorMessage(hud, "Content Cu.reportError"));
|
||||
ok(true, "reportError message from content process is displayed");
|
||||
|
||||
const suffix = ` Object { hello: "world" }`;
|
||||
const expectedMessages = [
|
||||
contentArgs.log + suffix,
|
||||
|
@ -190,7 +199,7 @@ add_task(async function() {
|
|||
"Check that message from parent process is still visible in the Browser Console"
|
||||
);
|
||||
ok(
|
||||
!!findErrorMessage(hud, "Parent Cu.reportError"),
|
||||
!!findErrorMessage(hud, "Parent error"),
|
||||
"Parent process message is still displayed"
|
||||
);
|
||||
|
||||
|
@ -223,9 +232,9 @@ add_task(async function() {
|
|||
}
|
||||
|
||||
is(
|
||||
findErrorMessages(hud, "Content Cu.reportError").length,
|
||||
findErrorMessages(hud, "Content error").length,
|
||||
1,
|
||||
"reportError message from content process is only displayed once"
|
||||
"error message from content process is only displayed once"
|
||||
);
|
||||
|
||||
is(
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
"use strict";
|
||||
function a() {
|
||||
Cu.reportError(
|
||||
"error thrown from test-cu-reporterror.js via Cu.reportError()"
|
||||
);
|
||||
}
|
||||
a();
|
|
@ -151,7 +151,7 @@ const WorkerDescriptorActor = protocol.ActorClassWithSpec(
|
|||
},
|
||||
|
||||
_onWorkerError(filename, lineno, message) {
|
||||
Cu.reportError("ERROR:" + filename + ":" + lineno + ":" + message + "\n");
|
||||
console.error("ERROR:", filename, ":", lineno, ":", message);
|
||||
},
|
||||
|
||||
_getServiceWorkerRegistrationInfo() {
|
||||
|
|
|
@ -236,7 +236,7 @@ DevToolsServerConnection.prototype = {
|
|||
const errorString = prefix + ": " + DevToolsUtils.safeErrorString(error);
|
||||
// On worker threads we don't have access to Cu.
|
||||
if (!isWorker) {
|
||||
Cu.reportError(errorString);
|
||||
console.error(errorString);
|
||||
}
|
||||
dumpn(errorString);
|
||||
return {
|
||||
|
|
|
@ -134,7 +134,7 @@ class InspectedWindowCommand {
|
|||
return result;
|
||||
} catch (e) {
|
||||
this._reloadPending = false;
|
||||
Cu.reportError(e);
|
||||
console.error(e);
|
||||
return Promise.reject({
|
||||
message: "An unexpected error occurred",
|
||||
});
|
||||
|
|
|
@ -1243,7 +1243,7 @@ const JsonView = {
|
|||
!message.data.startsWith("blob:null") ||
|
||||
!browser.contentPrincipal.isNullPrincipal
|
||||
) {
|
||||
Cu.reportError("Got invalid request to save JSON data");
|
||||
console.error("Got invalid request to save JSON data");
|
||||
return;
|
||||
}
|
||||
// The following code emulates saveBrowser, but:
|
||||
|
|
Загрузка…
Ссылка в новой задаче