mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1621813 - Remove nsIScriptError.exceptionFlag. r=mccr8
I made some changes in preparation for removing nsIScriptError.flags in favor of nsIConsoleMessage.logLevel. Differential Revision: https://phabricator.services.mozilla.com/D66878 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
07f98c5f66
commit
5eb9932e47
@ -274,19 +274,17 @@ function testExceptionHook(ex) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Convert an nsIScriptError 'flags' value into an appropriate string.
|
||||
function scriptErrorFlagsToKind(flags) {
|
||||
let kind;
|
||||
if (flags & Ci.nsIScriptError.warningFlag) {
|
||||
kind = "warning";
|
||||
// Convert an nsIScriptError 'logLevel' value into an appropriate string.
|
||||
function scriptErrorLogLevel(message) {
|
||||
switch (message.logLevel) {
|
||||
case Ci.nsIConsoleMessage.info:
|
||||
return "info";
|
||||
case Ci.nsIConsoleMessage.warn:
|
||||
return "warning";
|
||||
default:
|
||||
Assert.equal(message.logLevel, Ci.nsIConsoleMessage.error);
|
||||
return "error";
|
||||
}
|
||||
if (flags & Ci.nsIScriptError.exceptionFlag) {
|
||||
kind = "exception";
|
||||
} else {
|
||||
kind = "error";
|
||||
}
|
||||
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Register a console listener, so console messages don't just disappear
|
||||
@ -306,7 +304,7 @@ var listener = {
|
||||
":" +
|
||||
message.lineNumber +
|
||||
": " +
|
||||
scriptErrorFlagsToKind(message.flags) +
|
||||
scriptErrorLogLevel(message) +
|
||||
": " +
|
||||
message.errorMessage
|
||||
);
|
||||
|
@ -33,19 +33,17 @@ Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
|
||||
// Fast timeout for TLS tests
|
||||
Services.prefs.setIntPref("devtools.remote.tls-handshake-timeout", 1000);
|
||||
|
||||
// Convert an nsIScriptError 'flags' value into an appropriate string.
|
||||
function scriptErrorFlagsToKind(flags) {
|
||||
let kind;
|
||||
if (flags & Ci.nsIScriptError.warningFlag) {
|
||||
kind = "warning";
|
||||
// Convert an nsIScriptError 'logLevel' value into an appropriate string.
|
||||
function scriptErrorLogLevel(message) {
|
||||
switch (message.logLevel) {
|
||||
case Ci.nsIConsoleMessage.info:
|
||||
return "info";
|
||||
case Ci.nsIConsoleMessage.warn:
|
||||
return "warning";
|
||||
default:
|
||||
Assert.equal(message.logLevel, Ci.nsIConsoleMessage.error);
|
||||
return "error";
|
||||
}
|
||||
if (flags & Ci.nsIScriptError.exceptionFlag) {
|
||||
kind = "exception";
|
||||
} else {
|
||||
kind = "error";
|
||||
}
|
||||
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Register a console listener, so console messages don't just disappear
|
||||
@ -60,7 +58,7 @@ var listener = {
|
||||
":" +
|
||||
message.lineNumber +
|
||||
": " +
|
||||
scriptErrorFlagsToKind(message.flags) +
|
||||
scriptErrorLogLevel(message) +
|
||||
": " +
|
||||
message.errorMessage +
|
||||
"\n"
|
||||
|
@ -31,19 +31,17 @@ const { DevToolsServer } = require("devtools/server/devtools-server");
|
||||
const { DevToolsClient } = require("devtools/shared/client/devtools-client");
|
||||
const { SocketListener } = require("devtools/shared/security/socket");
|
||||
|
||||
// Convert an nsIScriptError 'flags' value into an appropriate string.
|
||||
function scriptErrorFlagsToKind(flags) {
|
||||
let kind;
|
||||
if (flags & Ci.nsIScriptError.warningFlag) {
|
||||
kind = "warning";
|
||||
// Convert an nsIScriptError 'logLevel' value into an appropriate string.
|
||||
function scriptErrorLogLevel(message) {
|
||||
switch (message.logLevel) {
|
||||
case Ci.nsIConsoleMessage.info:
|
||||
return "info";
|
||||
case Ci.nsIConsoleMessage.warn:
|
||||
return "warning";
|
||||
default:
|
||||
Assert.equal(message.logLevel, Ci.nsIConsoleMessage.error);
|
||||
return "error";
|
||||
}
|
||||
if (flags & Ci.nsIScriptError.exceptionFlag) {
|
||||
kind = "exception";
|
||||
} else {
|
||||
kind = "error";
|
||||
}
|
||||
|
||||
return kind;
|
||||
}
|
||||
|
||||
// Register a console listener, so console messages don't just disappear
|
||||
@ -62,7 +60,7 @@ var listener = {
|
||||
":" +
|
||||
message.lineNumber +
|
||||
": " +
|
||||
scriptErrorFlagsToKind(message.flags) +
|
||||
scriptErrorLogLevel(message) +
|
||||
": " +
|
||||
message.errorMessage +
|
||||
"\n"
|
||||
|
@ -44,9 +44,6 @@ interface nsIScriptError : nsIConsoleMessage
|
||||
/** message is warning */
|
||||
const unsigned long warningFlag = 0x1;
|
||||
|
||||
/** exception was thrown for this case - exception-aware hosts can ignore */
|
||||
const unsigned long exceptionFlag = 0x2;
|
||||
|
||||
/** just a log message */
|
||||
const unsigned long infoFlag = 0x8;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
static_assert(nsIScriptError::errorFlag == JSREPORT_ERROR &&
|
||||
nsIScriptError::warningFlag == JSREPORT_WARNING &&
|
||||
nsIScriptError::exceptionFlag == JSREPORT_EXCEPTION &&
|
||||
nsIScriptError::infoFlag == JSREPORT_USER_1,
|
||||
"flags should be consistent");
|
||||
|
||||
|
@ -114,7 +114,6 @@ void ConsoleReportCollector::FlushReportsToConsoleForServiceWorkerScope(
|
||||
ConsoleUtils::Level level = ConsoleUtils::eLog;
|
||||
switch (report.mErrorFlags) {
|
||||
case nsIScriptError::errorFlag:
|
||||
case nsIScriptError::exceptionFlag:
|
||||
level = ConsoleUtils::eError;
|
||||
break;
|
||||
case nsIScriptError::warningFlag:
|
||||
|
@ -820,7 +820,7 @@ class RTCPeerConnection {
|
||||
e.message,
|
||||
e.fileName,
|
||||
e.lineNumber,
|
||||
Ci.nsIScriptError.exceptionFlag
|
||||
Ci.nsIScriptError.errorFlag
|
||||
);
|
||||
|
||||
// Safely call onerror directly if present (necessary for testing)
|
||||
|
@ -26,7 +26,6 @@ ConsoleListener.prototype = {
|
||||
innerWindowID: aMsg.innerWindowID,
|
||||
isScriptError: true,
|
||||
isWarning: (aMsg.flags & Ci.nsIScriptError.warningFlag) === 1,
|
||||
isException: (aMsg.flags & Ci.nsIScriptError.exceptionFlag) === 1,
|
||||
};
|
||||
|
||||
sendAsyncMessage("monitor", msg);
|
||||
|
@ -4322,7 +4322,7 @@ void WorkerPrivate::ReportError(JSContext* aCx,
|
||||
if (aReport) {
|
||||
report->AssignErrorReport(aReport);
|
||||
} else {
|
||||
report->mFlags = nsIScriptError::errorFlag | nsIScriptError::exceptionFlag;
|
||||
report->mFlags = nsIScriptError::errorFlag;
|
||||
}
|
||||
|
||||
JS::RootedObject stack(aCx), stackGlobal(aCx);
|
||||
|
@ -248,7 +248,7 @@ void xpc::ErrorReport::Init(JSContext* aCx, mozilla::dom::Exception* aException,
|
||||
mLineNumber = aException->LineNumber(aCx);
|
||||
mColumn = aException->ColumnNumber();
|
||||
|
||||
mFlags = JSREPORT_EXCEPTION;
|
||||
mFlags = JSREPORT_ERROR;
|
||||
}
|
||||
|
||||
static LazyLogModule gJSDiagnostics("JSDiagnostics");
|
||||
|
@ -33,48 +33,39 @@ var expectedErrors = [
|
||||
{ errorMessage: "The character encoding of a framed document was not declared. The document may appear different if viewed without the document framing it.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_not_declared.html",
|
||||
lineNumber: 0,
|
||||
isWarning: true,
|
||||
isException: false },
|
||||
isWarning: true },
|
||||
{ errorMessage: "The character encoding declaration of the framed HTML document was not found when prescanning the first 1024 bytes of the file. When viewed without the document framing it, the page will reload automatically. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_late_meta.html",
|
||||
lineNumber: 1028,
|
||||
isWarning: true,
|
||||
isException: false },
|
||||
isWarning: true },
|
||||
{ errorMessage: "The page was reloaded, because the character encoding declaration of the HTML document was not found when prescanning the first 1024 bytes of the file. The encoding declaration needs to be moved to be within the first 1024 bytes of the file.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_restart.html",
|
||||
lineNumber: 1028,
|
||||
isWarning: true,
|
||||
isException: false },
|
||||
isWarning: true },
|
||||
{ errorMessage: "An unsupported character encoding was declared for the HTML document using a meta tag. The declaration was ignored.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_unsupported.html",
|
||||
lineNumber: 1,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
{ errorMessage: "An unsupported character encoding was declared on the transfer protocol level. The declaration was ignored.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_http_unsupported.html",
|
||||
lineNumber: 0,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
{ errorMessage: "Detected UTF-16-encoded Basic Latin-only text without a byte order mark and without a transfer protocol-level declaration. Encoding this content in UTF-16 is inefficient and the character encoding should have been declared in any case.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_bomless_utf16.html",
|
||||
lineNumber: 0,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
{ errorMessage: "A meta tag was used to declare the character encoding as UTF-16. This was interpreted as an UTF-8 declaration instead.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_utf16.html",
|
||||
lineNumber: 1,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
{ errorMessage: "An unsupported character encoding was declared for the HTML document using a meta tag. The declaration was ignored.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_non_superset.html",
|
||||
lineNumber: 1,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
{ errorMessage: "A meta tag was used to declare the character encoding as x-user-defined. This was interpreted as a windows-1252 declaration instead for compatibility with intentionally mis-encoded legacy fonts. This site should migrate to Unicode.",
|
||||
sourceName: "http://mochi.test:8888/tests/parser/htmlparser/tests/mochitest/file_bug672453_meta_userdefined.html",
|
||||
lineNumber: 1,
|
||||
isWarning: false,
|
||||
isException: false },
|
||||
isWarning: false },
|
||||
];
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
@ -69,14 +69,15 @@ class Log extends ContentProcessDomain {
|
||||
}
|
||||
}
|
||||
|
||||
const MESSAGE_LEVELS = {
|
||||
[Ci.nsIConsoleMessage.debug]: "verbose",
|
||||
[Ci.nsIConsoleMessage.info]: "info",
|
||||
[Ci.nsIConsoleMessage.warn]: "warning",
|
||||
[Ci.nsIConsoleMessage.error]: "error",
|
||||
};
|
||||
|
||||
function fromConsoleMessage(message) {
|
||||
const levels = {
|
||||
[Ci.nsIConsoleMessage.debug]: "verbose",
|
||||
[Ci.nsIConsoleMessage.info]: "info",
|
||||
[Ci.nsIConsoleMessage.warn]: "warning",
|
||||
[Ci.nsIConsoleMessage.error]: "error",
|
||||
};
|
||||
const level = levels[message.logLevel];
|
||||
const level = MESSAGE_LEVELS[message.logLevel];
|
||||
|
||||
return {
|
||||
source: "javascript",
|
||||
@ -113,20 +114,8 @@ function fromConsoleAPI(message) {
|
||||
}
|
||||
|
||||
function fromScriptError(error) {
|
||||
const { flags, errorMessage, sourceName, lineNumber, stack } = error;
|
||||
|
||||
// lossy reduction from bitmask to CDP string level
|
||||
let level = "verbose";
|
||||
if (
|
||||
flags & Ci.nsIScriptError.exceptionFlag ||
|
||||
flags & Ci.nsIScriptError.errorFlag
|
||||
) {
|
||||
level = "error";
|
||||
} else if (flags & Ci.nsIScriptError.warningFlag) {
|
||||
level = "warning";
|
||||
} else if (flags & Ci.nsIScriptError.infoFlag) {
|
||||
level = "info";
|
||||
}
|
||||
const { logLevel, errorMessage, sourceName, lineNumber, stack } = error;
|
||||
const level = MESSAGE_LEVELS[logLevel];
|
||||
|
||||
return {
|
||||
source: "javascript",
|
||||
|
@ -1505,7 +1505,7 @@ SimpleTest.finish = function() {
|
||||
* message, errorMessage, sourceName, sourceLine, category:
|
||||
* string or regexp
|
||||
* lineNumber, columnNumber: number
|
||||
* isScriptError, isWarning, isException: boolean
|
||||
* isScriptError, isWarning: boolean
|
||||
* Strings, numbers, and booleans must compare equal to the named
|
||||
* property of the Nth console message. Regexps must match. Any
|
||||
* fields present in the message but not in the pattern object are ignored.
|
||||
|
@ -98,7 +98,6 @@ SPConsoleListener.prototype = {
|
||||
isScriptError: false,
|
||||
isConsoleEvent: false,
|
||||
isWarning: false,
|
||||
isException: false,
|
||||
};
|
||||
if (msg instanceof Ci.nsIScriptError) {
|
||||
m.errorMessage = msg.errorMessage;
|
||||
@ -112,7 +111,6 @@ SPConsoleListener.prototype = {
|
||||
m.innerWindowID = msg.innerWindowID;
|
||||
m.isScriptError = true;
|
||||
m.isWarning = (msg.flags & Ci.nsIScriptError.warningFlag) === 1;
|
||||
m.isException = (msg.flags & Ci.nsIScriptError.exceptionFlag) === 1;
|
||||
} else if (topic === "console-api-log-event") {
|
||||
// This is a dom/console event.
|
||||
let unwrapped = msg.wrappedJSObject;
|
||||
|
Loading…
Reference in New Issue
Block a user