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("requestId", request_id);
|
||||||
result.Set("selectionArea", selection_rect);
|
result.Set("selectionArea", selection_rect);
|
||||||
result.Set("finalUpdate", final_update);
|
result.Set("finalUpdate", final_update);
|
||||||
|
result.Set("activeMatchOrdinal", active_match_ordinal);
|
||||||
Emit("found-in-page", result);
|
Emit("found-in-page", result);
|
||||||
} else if (final_update) {
|
} else if (final_update) {
|
||||||
result.Set("requestId", request_id);
|
result.Set("requestId", request_id);
|
||||||
|
|
|
@ -259,6 +259,7 @@ Returns:
|
||||||
* `result` Object
|
* `result` Object
|
||||||
* `requestId` Integer
|
* `requestId` Integer
|
||||||
* `finalUpdate` Boolean - Indicates if more responses are to follow.
|
* `finalUpdate` Boolean - Indicates if more responses are to follow.
|
||||||
|
* `activeMatchOrdinal` Integer (optional) - Position of the active match.
|
||||||
* `matches` Integer (optional) - Number of Matches.
|
* `matches` Integer (optional) - Number of Matches.
|
||||||
* `selectionArea` Object (optional) - Coordinates of first match region.
|
* `selectionArea` Object (optional) - Coordinates of first match region.
|
||||||
|
|
||||||
|
|
|
@ -573,6 +573,7 @@ Returns:
|
||||||
* `result` Object
|
* `result` Object
|
||||||
* `requestId` Integer
|
* `requestId` Integer
|
||||||
* `finalUpdate` Boolean - Indicates if more responses are to follow.
|
* `finalUpdate` Boolean - Indicates if more responses are to follow.
|
||||||
|
* `activeMatchOrdinal` Integer (optional) - Position of the active match.
|
||||||
* `matches` Integer (optional) - Number of Matches.
|
* `matches` Integer (optional) - Number of Matches.
|
||||||
* `selectionArea` Object (optional) - Coordinates of first match region.
|
* `selectionArea` Object (optional) - Coordinates of first match region.
|
||||||
|
|
||||||
|
|
|
@ -642,13 +642,22 @@ describe('<webview> tag', function() {
|
||||||
describe('found-in-page event', function() {
|
describe('found-in-page event', function() {
|
||||||
it('emits when a request is made', function(done) {
|
it('emits when a request is made', function(done) {
|
||||||
var requestId = null;
|
var requestId = null;
|
||||||
|
var totalMatches = null;
|
||||||
|
var activeMatchOrdinal = [];
|
||||||
var listener = function(e) {
|
var listener = function(e) {
|
||||||
assert.equal(e.result.requestId, requestId);
|
assert.equal(e.result.requestId, requestId);
|
||||||
if (e.result.finalUpdate) {
|
if (e.result.finalUpdate) {
|
||||||
assert.equal(e.result.matches, 3);
|
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");
|
webview.stopFindInPage("clearSelection");
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
var listener2 = function() {
|
var listener2 = function() {
|
||||||
requestId = webview.findInPage("virtual");
|
requestId = webview.findInPage("virtual");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue