- Revision
- 199031
- Author
- [email protected]
- Date
- 2016-04-04 17:12:35 -0700 (Mon, 04 Apr 2016)
Log Message
Web Inspector: Uncaught exception in CSS with string "constructor" (WebInspector.Color.fromString())
https://bugs.webkit.org/show_bug.cgi?id=156183
<rdar://problem/25539279>
Patch by Joseph Pecoraro <[email protected]> on 2016-04-04
Reviewed by Brian Burg.
* UserInterface/Models/Color.js:
(WebInspector.Color.fromString):
Fix the uncaught exception issue. Only look at own properties of
our keyword map to avoid values like "toString" and "constructor".
* UserInterface/Debug/UncaughtExceptionReporter.js:
(handleError):
(handleUncaughtException):
(handleUncaughtExceptionRecord):
Generalize uncaught exception handler error sheet to get
exception records from both uncaught exceptions (window.onerror)
and general Runtime Error objects (TypeError, etc).
* UserInterface/Base/Utilities.js:
(window.promiseLogError.window.promiseLogError):
Add a fallback log exception helper.
* UserInterface/Controllers/AnalyzerManager.js:
(WebInspector.AnalyzerManager.prototype.getAnalyzerMessagesForSourceCode):
* UserInterface/Views/SourceCodeTextEditor.js:
(WebInspector.SourceCodeTextEditor):
Add catch handlers to Promises to log exceptions.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (199030 => 199031)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-04-05 00:12:35 UTC (rev 199031)
@@ -1,3 +1,34 @@
+2016-04-04 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Uncaught exception in CSS with string "constructor" (WebInspector.Color.fromString())
+ https://bugs.webkit.org/show_bug.cgi?id=156183
+ <rdar://problem/25539279>
+
+ Reviewed by Brian Burg.
+
+ * UserInterface/Models/Color.js:
+ (WebInspector.Color.fromString):
+ Fix the uncaught exception issue. Only look at own properties of
+ our keyword map to avoid values like "toString" and "constructor".
+
+ * UserInterface/Debug/UncaughtExceptionReporter.js:
+ (handleError):
+ (handleUncaughtException):
+ (handleUncaughtExceptionRecord):
+ Generalize uncaught exception handler error sheet to get
+ exception records from both uncaught exceptions (window.onerror)
+ and general Runtime Error objects (TypeError, etc).
+
+ * UserInterface/Base/Utilities.js:
+ (window.promiseLogError.window.promiseLogError):
+ Add a fallback log exception helper.
+
+ * UserInterface/Controllers/AnalyzerManager.js:
+ (WebInspector.AnalyzerManager.prototype.getAnalyzerMessagesForSourceCode):
+ * UserInterface/Views/SourceCodeTextEditor.js:
+ (WebInspector.SourceCodeTextEditor):
+ Add catch handlers to Promises to log exceptions.
+
2016-04-01 Joseph Pecoraro <[email protected]>
Unreviewed follow-up to r198968. Remove debug statements.
Modified: trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js (199030 => 199031)
--- trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/UserInterface/Base/Utilities.js 2016-04-05 00:12:35 UTC (rev 199031)
@@ -1244,3 +1244,10 @@
{
return window.performance ? performance.now() : Date.now();
}
+
+if (!window.handlePromiseException) {
+ window.handlePromiseException = function handlePromiseException(error)
+ {
+ console.error("Uncaught exception in Promise", error);
+ };
+}
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/AnalyzerManager.js (199030 => 199031)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/AnalyzerManager.js 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/AnalyzerManager.js 2016-04-05 00:12:35 UTC (rev 199031)
@@ -96,7 +96,7 @@
resolve(analyzerMessages);
}
- sourceCode.requestContent().then(retrieveAnalyzerMessages.bind(this));
+ sourceCode.requestContent().then(retrieveAnalyzerMessages.bind(this)).catch(handlePromiseException);
}.bind(this));
}
Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js (199030 => 199031)
--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js 2016-04-05 00:12:35 UTC (rev 199031)
@@ -50,14 +50,25 @@
document.removeEventListener(name, stopEventPropagation, true);
}
+function handleError(error) {
+ handleUncaughtExceptionRecord({
+ message: error.message,
+ url: parseURL(error.sourceURL).lastPathComponent,
+ lineNumber: error.line,
+ columnNumber: error.column,
+ });
+}
+
function handleUncaughtException(event) {
- let exceptionRecord = {
+ handleUncaughtExceptionRecord({
message: event.message,
url: parseURL(event.filename).lastPathComponent,
lineNumber: event.lineno,
- columnNumber: event.colno
- };
+ columnNumber: event.colno,
+ });
+}
+function handleUncaughtExceptionRecord(exceptionRecord) {
if (!window.__uncaughtExceptions)
window.__uncaughtExceptions = [];
@@ -199,5 +210,6 @@
}
window.addEventListener("error", handleUncaughtException);
+window.handlePromiseException = handleError;
})();
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/Color.js (199030 => 199031)
--- trunk/Source/WebInspectorUI/UserInterface/Models/Color.js 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/Color.js 2016-04-05 00:12:35 UTC (rev 199031)
@@ -103,7 +103,7 @@
]);
} else if (match[3]) { // keyword
let keyword = match[3].toLowerCase();
- if (!WebInspector.Color.Keywords[keyword])
+ if (!WebInspector.Color.Keywords.hasOwnProperty(keyword))
return null;
let color = new WebInspector.Color(WebInspector.Color.Format.Keyword, WebInspector.Color.Keywords[keyword].concat(1));
color.keyword = keyword;
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js (199030 => 199031)
--- trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2016-04-04 23:17:59 UTC (rev 199030)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/SourceCodeTextEditor.js 2016-04-05 00:12:35 UTC (rev 199031)
@@ -78,9 +78,9 @@
else
this._sourceCode.addEventListener(WebInspector.SourceCode.Event.SourceMapAdded, this._sourceCodeSourceMapAdded, this);
- sourceCode.requestContent().then(this._contentAvailable.bind(this));
+ sourceCode.requestContent().then(this._contentAvailable.bind(this)).catch(handlePromiseException);
- // FIXME: Cmd+L shorcut doesn't actually work.
+ // FIXME: Cmd+L shortcut doesn't actually work.
new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Command, "L", this.showGoToLineDialog.bind(this), this.element);
new WebInspector.KeyboardShortcut(WebInspector.KeyboardShortcut.Modifier.Control, "G", this.showGoToLineDialog.bind(this), this.element);
}