webcontents: provide position of match with found-in-page event
This commit is contained in:
parent
b2059ec8af
commit
8378cbb1e8
4 changed files with 14 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -642,12 +642,21 @@ 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);
|
||||
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() {
|
||||
|
|
Loading…
Reference in a new issue