Title: [225908] trunk/Source/WebInspectorUI
Revision
225908
Author
commit-qu...@webkit.org
Date
2017-12-14 09:09:13 -0800 (Thu, 14 Dec 2017)

Log Message

Web Inspector: UncaughtExceptionReporter fails on early errors
https://bugs.webkit.org/show_bug.cgi?id=180776

Patch by Joseph Pecoraro <pecor...@apple.com> on 2017-12-14
Reviewed by Brian Burg.

* UserInterface/Debug/UncaughtExceptionReporter.js:
(urlLastPathComponent):
(handleError):
(handleUncaughtException):
URLUtilities parseURL might not be available, so have a small
helper for getting a good name from a URL / filename.

(handleUncaughtExceptionRecord):
(dismissErrorSheet):
Wrap `WI` namespace accesses in a try/catch since `WI` might not be available.
Safely check global variables there were `Foo` as `window.Foo` to avoid errors
if they are not actually available.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (225907 => 225908)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-12-14 17:08:52 UTC (rev 225907)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-12-14 17:09:13 UTC (rev 225908)
@@ -1,3 +1,23 @@
+2017-12-14  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: UncaughtExceptionReporter fails on early errors
+        https://bugs.webkit.org/show_bug.cgi?id=180776
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Debug/UncaughtExceptionReporter.js:
+        (urlLastPathComponent):
+        (handleError):
+        (handleUncaughtException):
+        URLUtilities parseURL might not be available, so have a small
+        helper for getting a good name from a URL / filename.
+
+        (handleUncaughtExceptionRecord):
+        (dismissErrorSheet):
+        Wrap `WI` namespace accesses in a try/catch since `WI` might not be available.
+        Safely check global variables there were `Foo` as `window.Foo` to avoid errors
+        if they are not actually available.
+
 2017-12-13  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Network Tab - Make text filter just a URL filter and update incrementally

Modified: trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js (225907 => 225908)


--- trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js	2017-12-14 17:08:52 UTC (rev 225907)
+++ trunk/Source/WebInspectorUI/UserInterface/Debug/UncaughtExceptionReporter.js	2017-12-14 17:09:13 UTC (rev 225908)
@@ -50,10 +50,21 @@
         document.removeEventListener(name, stopEventPropagation, true);
 }
 
+function urlLastPathComponent(url) {
+    if (!url)
+        return "";
+
+    let slashIndex = url.lastIndexOf("/");
+    if (slashIndex === -1)
+        return url;
+
+    return url.slice(slashIndex + 1);
+}
+
 function handleError(error) {
     handleUncaughtExceptionRecord({
         message: error.message,
-        url: parseURL(error.sourceURL).lastPathComponent,
+        url: urlLastPathComponent(error.sourceURL),
         lineNumber: error.line,
         columnNumber: error.column,
         stack: error.stack,
@@ -64,7 +75,7 @@
 function handleUncaughtException(event) {
     handleUncaughtExceptionRecord({
         message: event.message,
-        url: parseURL(event.filename).lastPathComponent,
+        url: urlLastPathComponent(event.filename),
         lineNumber: event.lineno,
         columnNumber: event.colno,
         stack: typeof event.error === "object" && event.error !== null ? event.error.stack : null,
@@ -72,8 +83,10 @@
 }
 
 function handleUncaughtExceptionRecord(exceptionRecord) {
-    if (!WI.settings.enableUncaughtExceptionReporter.value)
-        return;
+    try {
+        if (!WI.settings.enableUncaughtExceptionReporter.value)
+            return;
+    } catch { }
 
     if (!window.__uncaughtExceptions)
         window.__uncaughtExceptions = [];
@@ -97,7 +110,7 @@
         // Signal that loading is done even though we can't guarantee that
         // evaluating code on the inspector page will do anything useful.
         // Without this, the frontend host may never show the window.
-        if (InspectorFrontendHost)
+        if (window.InspectorFrontendHost)
             InspectorFrontendHost.loaded();
 
         // Don't tell InspectorFrontendAPI that loading is done, since it can
@@ -115,7 +128,9 @@
     window.__uncaughtExceptions = [];
 
     // Do this last in case WebInspector's internal state is corrupted.
-    WI.updateWindowTitle();
+    try {
+        WI.updateWindowTitle();
+    } catch { }
 
     // FIXME (151959): tell the frontend host to hide a draggable title bar.
 }
@@ -127,7 +142,7 @@
         document.write("<body></body></html>");
 
     // FIXME (151959): tell the frontend host to show a draggable title bar.
-    if (InspectorFrontendHost)
+    if (window.InspectorFrontendHost)
         InspectorFrontendHost.inspectedURLChanged("Internal Error");
 
     // Only allow one sheet element at a time.
@@ -195,7 +210,7 @@
         return string.length > 500 ? string.substr(0, 500) + "…" : string;
     }
 
-    if (InspectorBackend && InspectorBackend.currentDispatchState) {
+    if (window.InspectorBackend && InspectorBackend.currentDispatchState) {
         let state = InspectorBackend.currentDispatchState;
         if (state.event) {
             topLevelItems.push("Dispatch Source:      Protocol Event");
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to