webcontents: provide position of match with found-in-page event

This commit is contained in:
Robo 2016-03-14 06:49:45 +05:30
parent b2059ec8af
commit 8378cbb1e8
4 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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.

View file

@ -642,13 +642,22 @@ describe('<webview> 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);
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() {
requestId = webview.findInPage("virtual");