diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index c8b597704cd0..4a548cb4a33e 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -456,6 +456,7 @@ void WebContents::FindReply(content::WebContents* web_contents, result.Set("requestId", request_id); result.Set("selectionArea", selection_rect); result.Set("finalUpdate", final_update); + result.Set("activeMatchOrdinal", active_match_ordinal); Emit("found-in-page", result); } else if (final_update) { result.Set("requestId", request_id); diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 8eda16b68602..5295b79ceb30 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -259,6 +259,7 @@ Returns: * `result` Object * `requestId` Integer * `finalUpdate` Boolean - Indicates if more responses are to follow. + * `activeMatchOrdinal` Integer (optional) - Position of the active match. * `matches` Integer (optional) - Number of Matches. * `selectionArea` Object (optional) - Coordinates of first match region. diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index fa48ef60f3f7..cba48e40db17 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -573,6 +573,7 @@ Returns: * `result` Object * `requestId` Integer * `finalUpdate` Boolean - Indicates if more responses are to follow. + * `activeMatchOrdinal` Integer (optional) - Position of the active match. * `matches` Integer (optional) - Number of Matches. * `selectionArea` Object (optional) - Coordinates of first match region. diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 5963709e6f0c..2d0a6282be34 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -642,12 +642,21 @@ describe(' tag', function() { describe('found-in-page event', function() { it('emits when a request is made', function(done) { var requestId = null; + var totalMatches = null; + var activeMatchOrdinal = []; var listener = function(e) { assert.equal(e.result.requestId, requestId); if (e.result.finalUpdate) { assert.equal(e.result.matches, 3); - webview.stopFindInPage("clearSelection"); - done(); + totalMatches = e.result.matches; + listener2(); + } else { + activeMatchOrdinal.push(e.result.activeMatchOrdinal); + if (e.result.activeMatchOrdinal == totalMatches) { + assert.deepEqual(activeMatchOrdinal, [1, 2, 3]); + webview.stopFindInPage("clearSelection"); + done(); + } } }; var listener2 = function() {