Title: [225892] trunk
Revision
225892
Author
[email protected]
Date
2017-12-13 20:47:34 -0800 (Wed, 13 Dec 2017)

Log Message

REGRESSION: Web Inspector: Opening inspector crashes page if there are empty resources
https://bugs.webkit.org/show_bug.cgi?id=180787
<rdar://problem/35934838>

Patch by Joseph Pecoraro <[email protected]> on 2017-12-13
Reviewed by Brian Burg.

Source/_javascript_Core:

* inspector/ContentSearchUtilities.cpp:
(Inspector::ContentSearchUtilities::findMagicComment):
For empty / null strings just return. There is no use
trying to search them for a long common syntax.

Source/WebInspectorUI:

* UserInterface/Test/TestUtilities.js:
Add a generic sanitizeURL used by many tests.

* UserInterface/TestStub.html:
Include TestUtilities.

LayoutTests:

* inspector/page/resources/empty.css: Added.
* inspector/page/resources/empty.js: Added.
* inspector/page/empty-or-missing-resources-expected.txt: Added.
* inspector/page/empty-or-missing-resources.html: Added.
Test no crashes inspecting a page with empty/missing resources.
Previously the test would crash.

* inspector/canvas/recording-webgl-snapshots.html:
* inspector/canvas/resources/create-context-utilities.js:
* inspector/canvas/resources/recording-utilities.js:
* inspector/css/getAllStyleSheets.html:
* inspector/css/stylesheet-events-basic.html:
* inspector/css/stylesheet-events-imports.html:
* inspector/css/stylesheet-events-multiple-documents.html:
* inspector/worker/console-basic.html:
* inspector/worker/debugger-scripts.html:
* inspector/worker/resources-in-worker.html:
* inspector/worker/runtime-basic.html:
* inspector/worker/worker-create-and-terminate.html:
Promote sanitizeURL to a TestUtility function since it is common.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225891 => 225892)


--- trunk/LayoutTests/ChangeLog	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/ChangeLog	2017-12-14 04:47:34 UTC (rev 225892)
@@ -1,3 +1,32 @@
+2017-12-13  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION: Web Inspector: Opening inspector crashes page if there are empty resources
+        https://bugs.webkit.org/show_bug.cgi?id=180787
+        <rdar://problem/35934838>
+
+        Reviewed by Brian Burg.
+
+        * inspector/page/resources/empty.css: Added.
+        * inspector/page/resources/empty.js: Added.
+        * inspector/page/empty-or-missing-resources-expected.txt: Added.
+        * inspector/page/empty-or-missing-resources.html: Added.
+        Test no crashes inspecting a page with empty/missing resources.
+        Previously the test would crash.
+
+        * inspector/canvas/recording-webgl-snapshots.html:
+        * inspector/canvas/resources/create-context-utilities.js:
+        * inspector/canvas/resources/recording-utilities.js:
+        * inspector/css/getAllStyleSheets.html:
+        * inspector/css/stylesheet-events-basic.html:
+        * inspector/css/stylesheet-events-imports.html:
+        * inspector/css/stylesheet-events-multiple-documents.html:
+        * inspector/worker/console-basic.html:
+        * inspector/worker/debugger-scripts.html:
+        * inspector/worker/resources-in-worker.html:
+        * inspector/worker/runtime-basic.html:
+        * inspector/worker/worker-create-and-terminate.html:
+        Promote sanitizeURL to a TestUtility function since it is common.
+
 2017-12-13  Daniel Bates  <[email protected]>
 
         Add more auto fill button types

Modified: trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html (225891 => 225892)


--- trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -88,10 +88,6 @@
 function test() {
     let suite = InspectorTest.createAsyncSuite("Canvas.recordingWebGL");
 
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     suite.addTestCase({
         name: "Canvas.recordingWebGL.snapshots",
         description: "Check that the snapshot taken after each visual action is different.",

Modified: trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js (225891 => 225892)


--- trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/canvas/resources/create-context-utilities.js	2017-12-14 04:47:34 UTC (rev 225892)
@@ -30,10 +30,6 @@
 TestPage.registerInitializer(() => {
     let suite = null;
 
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function awaitCanvasAdded(contextType) {
         return WI.canvasManager.awaitEvent(WI.CanvasManager.Event.CanvasAdded)
         .then((event) => {

Modified: trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js (225891 => 225892)


--- trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/canvas/resources/recording-utilities.js	2017-12-14 04:47:34 UTC (rev 225892)
@@ -1,8 +1,4 @@
 TestPage.registerInitializer(() => {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function log(object, indent) {
         for (let key of Object.keys(object)) {
             let value = object[key];

Modified: trunk/LayoutTests/inspector/css/getAllStyleSheets.html (225891 => 225892)


--- trunk/LayoutTests/inspector/css/getAllStyleSheets.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/css/getAllStyleSheets.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -19,10 +19,6 @@
 <script>
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     WI.cssStyleManager.fetchStyleSheetsIfNeeded();
     InspectorBackend.runAfterPendingDispatches(function() {
         let styleSheets = WI.cssStyleManager.styleSheets;

Modified: trunk/LayoutTests/inspector/css/stylesheet-events-basic.html (225891 => 225892)


--- trunk/LayoutTests/inspector/css/stylesheet-events-basic.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-basic.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -44,10 +44,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     let suite = InspectorTest.createAsyncSuite("CSS.StyleSheetEvents.Basic");
 
     suite.addTestCase({

Modified: trunk/LayoutTests/inspector/css/stylesheet-events-imports.html (225891 => 225892)


--- trunk/LayoutTests/inspector/css/stylesheet-events-imports.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-imports.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -21,10 +21,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function collectEvents(n, then) {
         let remaining = n;
         let collection = [];

Modified: trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html (225891 => 225892)


--- trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/css/stylesheet-events-multiple-documents.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -17,10 +17,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function logStyleSheets() {
         WI.cssStyleManager.styleSheets.sort((a, b) => a.url.localeCompare(b.url)).forEach((styleSheet) => {
             let frameString = styleSheet.parentFrame.id === WI.frameResourceManager.mainFrame.id ? "<mainframe>" : "<childframe>";

Added: trunk/LayoutTests/inspector/page/empty-or-missing-resources-expected.txt (0 => 225892)


--- trunk/LayoutTests/inspector/page/empty-or-missing-resources-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/page/empty-or-missing-resources-expected.txt	2017-12-14 04:47:34 UTC (rev 225892)
@@ -0,0 +1,10 @@
+Test that Page.getResourceTree does not crash with empty or missing resources.
+
+
+== Running test suite: Page.getResourceTree.EmptyResources
+-- Running test case: Page.getResourceTree.EmptyResources
+inspector/page/empty.js
+inspector/page/missing.js
+inspector/page/resources/empty.css
+inspector/page/resources/missing.css
+

Added: trunk/LayoutTests/inspector/page/empty-or-missing-resources.html (0 => 225892)


--- trunk/LayoutTests/inspector/page/empty-or-missing-resources.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/page/empty-or-missing-resources.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<link rel="stylesheet" href=""
+<link rel="stylesheet" href=""
+<script src=""
+<script src=""
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Page.getResourceTree.EmptyResources");
+
+    suite.addTestCase({
+        name: "Page.getResourceTree.EmptyResources",
+        description: "Should not crash if there are empty or missing resources.",
+        async test(resolve, reject) {
+            let resources = [...WI.frameResourceManager.mainFrame.resourceCollection.items];
+            let resourceURLs = resources.map(x => x.url).filter(x => /(empty|missing)/.test(x)).sort();
+            for (let url of resourceURLs)
+                InspectorTest.log(sanitizeURL(url));
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test that Page.getResourceTree does not crash with empty or missing resources.</p>
+</body>
+</html>

Modified: trunk/LayoutTests/inspector/worker/console-basic.html (225891 => 225892)


--- trunk/LayoutTests/inspector/worker/console-basic.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/worker/console-basic.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -11,10 +11,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function consoleMessageJSONFilter(key, value) {
         if (key === "_target" || key === "_hasChildren" || key === "_listeners")
             return undefined;

Modified: trunk/LayoutTests/inspector/worker/debugger-scripts.html (225891 => 225892)


--- trunk/LayoutTests/inspector/worker/debugger-scripts.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/worker/debugger-scripts.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -7,10 +7,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     let mainTarget = WI.mainTarget;
     let workerTarget = Array.from(WI.targets).find((target) => target.type === WI.Target.Type.Worker);
     let mainDebuggerData = WI.debuggerManager.dataForTarget(mainTarget);

Modified: trunk/LayoutTests/inspector/worker/resources-in-worker.html (225891 => 225892)


--- trunk/LayoutTests/inspector/worker/resources-in-worker.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/worker/resources-in-worker.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -39,10 +39,6 @@
     let workerTarget = null;
     let mainTarget = WI.mainTarget;
 
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     function dumpWorkerResources() {
         InspectorTest.log("RESOURCES:");
         for (let resource of workerTarget.resourceCollection.items)

Modified: trunk/LayoutTests/inspector/worker/runtime-basic.html (225891 => 225892)


--- trunk/LayoutTests/inspector/worker/runtime-basic.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/worker/runtime-basic.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -8,10 +8,6 @@
 
 function test()
 {
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
-
     let mainTarget = WI.mainTarget;
     let workerTarget = Array.from(WI.targets).find((target) => target.type === WI.Target.Type.Worker);
     if (!workerTarget) {

Modified: trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html (225891 => 225892)


--- trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/LayoutTests/inspector/worker/worker-create-and-terminate.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -43,11 +43,7 @@
             ProtocolTest.log("No Workers");
     }
 
-    function sanitizeURL(url) {
-        return url.replace(/^.*?LayoutTests\//, "");
-    }
 
-
     let triggerNextCreate;
     let triggerNextTerminate;
 

Modified: trunk/Source/_javascript_Core/ChangeLog (225891 => 225892)


--- trunk/Source/_javascript_Core/ChangeLog	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-12-14 04:47:34 UTC (rev 225892)
@@ -1,3 +1,16 @@
+2017-12-13  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION: Web Inspector: Opening inspector crashes page if there are empty resources
+        https://bugs.webkit.org/show_bug.cgi?id=180787
+        <rdar://problem/35934838>
+
+        Reviewed by Brian Burg.
+
+        * inspector/ContentSearchUtilities.cpp:
+        (Inspector::ContentSearchUtilities::findMagicComment):
+        For empty / null strings just return. There is no use
+        trying to search them for a long common syntax.
+
 2017-12-13  Saam Barati  <[email protected]>
 
         Arrow functions need their own structure because they have different properties than sloppy functions

Modified: trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp (225891 => 225892)


--- trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/Source/_javascript_Core/inspector/ContentSearchUtilities.cpp	2017-12-14 04:47:34 UTC (rev 225892)
@@ -174,7 +174,9 @@
 
 static String findMagicComment(const String& content, const String& patternString)
 {
-    ASSERT(!content.isNull());
+    if (content.isEmpty())
+        return String();
+
     const char* error = nullptr;
     YarrPattern pattern(patternString, JSC::RegExpFlags::FlagMultiline, &error);
     ASSERT(!error);

Modified: trunk/Source/WebInspectorUI/ChangeLog (225891 => 225892)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-12-14 04:47:34 UTC (rev 225892)
@@ -1,3 +1,17 @@
+2017-12-13  Joseph Pecoraro  <[email protected]>
+
+        REGRESSION: Web Inspector: Opening inspector crashes page if there are empty resources
+        https://bugs.webkit.org/show_bug.cgi?id=180787
+        <rdar://problem/35934838>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Test/TestUtilities.js:
+        Add a generic sanitizeURL used by many tests.
+
+        * UserInterface/TestStub.html:
+        Include TestUtilities.
+
 2017-12-13  Devin Rousso  <[email protected]>
 
         Web Inspector: add instrumentation for ImageBitmapRenderingContext

Modified: trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js (225891 => 225892)


--- trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/TestUtilities.js	2017-12-14 04:47:34 UTC (rev 225892)
@@ -52,3 +52,7 @@
         }
     });
 }
+
+function sanitizeURL(url) {
+    return url.replace(/^.*?LayoutTests\//, "");
+}

Modified: trunk/Source/WebInspectorUI/UserInterface/TestStub.html (225891 => 225892)


--- trunk/Source/WebInspectorUI/UserInterface/TestStub.html	2017-12-14 04:10:02 UTC (rev 225891)
+++ trunk/Source/WebInspectorUI/UserInterface/TestStub.html	2017-12-14 04:47:34 UTC (rev 225892)
@@ -42,6 +42,7 @@
     <script src=""
     <script src=""
     <script src=""
+    <script src=""
 
     <script src=""
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to