OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Based heavily on code from the Google iOS app. | 6 * Based heavily on code from the Google iOS app. |
7 * | 7 * |
8 * @fileoverview A find in page tool. It scans the DOM for elements with the | 8 * @fileoverview A find in page tool. It scans the DOM for elements with the |
9 * text being search for, and wraps them with a span that highlights them. | 9 * text being search for, and wraps them with a span that highlights them. |
10 */ | 10 */ |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 /** | 946 /** |
947 * Gather all iframes in the main window. | 947 * Gather all iframes in the main window. |
948 * @return {Array<Document>} frames. | 948 * @return {Array<Document>} frames. |
949 */ | 949 */ |
950 __gCrWeb['findInPage'].frameDocuments = function() { | 950 __gCrWeb['findInPage'].frameDocuments = function() { |
951 var windowsToSearch = [window]; | 951 var windowsToSearch = [window]; |
952 var documents = []; | 952 var documents = []; |
953 while (windowsToSearch.length != 0) { | 953 while (windowsToSearch.length != 0) { |
954 var win = windowsToSearch.pop(); | 954 var win = windowsToSearch.pop(); |
955 for (var i = win.frames.length - 1; i >= 0; i--) { | 955 for (var i = win.frames.length - 1; i >= 0; i--) { |
956 if (win.frames[i].document) { | 956 // The following try/catch catches a webkit error when searching a page |
957 documents.push(win.frames[i].document); | 957 // with iframes. See crbug.com/702566 for details. |
958 windowsToSearch.push(win.frames[i]); | 958 // To verify that this is still necessary: |
| 959 // 1. Remove this try/catch. |
| 960 // 2. Go to a page with iframes. |
| 961 // 3. Search for anything. |
| 962 // 4. Check if the webkit debugger spits out SecurityError (DOM Exception) |
| 963 // and the search fails. If it doesn't, feel free to remove this. |
| 964 try { |
| 965 if (win.frames[i].document) { |
| 966 documents.push(win.frames[i].document); |
| 967 windowsToSearch.push(win.frames[i]); |
| 968 } |
| 969 } catch (e) { |
| 970 // Do nothing. |
959 } | 971 } |
960 } | 972 } |
961 } | 973 } |
962 return documents; | 974 return documents; |
963 }; | 975 }; |
964 | 976 |
965 window.addEventListener('pagehide', __gCrWeb['findInPage']['disable']); | 977 window.addEventListener('pagehide', __gCrWeb['findInPage']['disable']); |
OLD | NEW |