Web Inspector: Global search sometimes returns duplicate results for a resource
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 00:25:52 +0000 (00:25 +0000)
committerjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 7 Aug 2018 00:25:52 +0000 (00:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188270
<rdar://problem/42867498>

Reviewed by Brian Burg.

* UserInterface/Views/SearchSidebarPanel.js:
(WI.SearchSidebarPanel.prototype.performSearch.resourcesCallback):
Avoid duplicate search results in the frontend. We should also fix the backend
but a frontend fix will also be desired for backends that have the issue.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234637 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Views/SearchSidebarPanel.js

index 0da71d6..c7049ab 100644 (file)
@@ -1,3 +1,16 @@
+2018-08-06  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Global search sometimes returns duplicate results for a resource
+        https://bugs.webkit.org/show_bug.cgi?id=188270
+        <rdar://problem/42867498>
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Views/SearchSidebarPanel.js:
+        (WI.SearchSidebarPanel.prototype.performSearch.resourcesCallback):
+        Avoid duplicate search results in the frontend. We should also fix the backend
+        but a frontend fix will also be desired for backends that have the issue.
+
 2018-08-03  Alex Christensen  <achristensen@webkit.org>
 
         Fix spelling of "overridden"
index 130c147..deaf66b 100644 (file)
@@ -170,11 +170,21 @@ WI.SearchSidebarPanel = class SearchSidebarPanel extends WI.NavigationSidebarPan
                 updateEmptyContentPlaceholder.call(this);
             }
 
-            for (var i = 0; i < result.length; ++i) {
-                var searchResult = result[i];
+            let preventDuplicates = new Set;
+
+            for (let i = 0; i < result.length; ++i) {
+                let searchResult = result[i];
                 if (!searchResult.url || !searchResult.frameId)
                     continue;
 
+                // FIXME: Backend sometimes searches files twice.
+                // <https://webkit.org/b/188287> Web Inspector: [Backend] Page.searchInResources sometimes returns duplicate results for a resource
+                // Note we will still want this to fix legacy backends.
+                let key = searchResult.frameId + ":" + searchResult.url;
+                if (preventDuplicates.has(key))
+                    continue;
+                preventDuplicates.add(key);
+
                 // COMPATIBILITY (iOS 9): Page.searchInResources did not have the optional requestId parameter.
                 PageAgent.searchInResource(searchResult.frameId, searchResult.url, searchQuery, isCaseSensitive, isRegex, searchResult.requestId, resourceCallback.bind(this, searchResult.frameId, searchResult.url));
             }