Commit 2991f43a authored by stkhapugin's avatar stkhapugin Committed by Commit bot

Fix Find in Page on iOS 10.3.

In iOS 10.3, an error is generated when trying to find in page on a page
with iframe:

SecurityError (DOM Exception 18): Blocked a frame with origin "https://w
ww.reddit.com" from accessing a frame with origin "https://www.redditmed
ia.com". Protocols, domains, and ports must match.

As a result, the search results are not highlighted on the page.

The fix is wrapping the offending line in try/catch.

BUG=702566
TEST=On iOS 10.3 device, open cnn.com, select tools>Find in Page" and
type any string that is present on the page. The string should be found
and highglighted, and the number of results should be correct, and
next/previous buttons should scroll the page to the next/prev result.

Review-Url: https://codereview.chromium.org/2755123002
Cr-Commit-Position: refs/heads/master@{#457845}
parent 8fca3127
...@@ -953,9 +953,21 @@ __gCrWeb['findInPage'].frameDocuments = function() { ...@@ -953,9 +953,21 @@ __gCrWeb['findInPage'].frameDocuments = function() {
while (windowsToSearch.length != 0) { while (windowsToSearch.length != 0) {
var win = windowsToSearch.pop(); var win = windowsToSearch.pop();
for (var i = win.frames.length - 1; i >= 0; i--) { for (var i = win.frames.length - 1; i >= 0; i--) {
if (win.frames[i].document) { // The following try/catch catches a webkit error when searching a page
documents.push(win.frames[i].document); // with iframes. See crbug.com/702566 for details.
windowsToSearch.push(win.frames[i]); // To verify that this is still necessary:
// 1. Remove this try/catch.
// 2. Go to a page with iframes.
// 3. Search for anything.
// 4. Check if the webkit debugger spits out SecurityError (DOM Exception)
// and the search fails. If it doesn't, feel free to remove this.
try {
if (win.frames[i].document) {
documents.push(win.frames[i].document);
windowsToSearch.push(win.frames[i]);
}
} catch (e) {
// Do nothing.
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment