Fix API change of findInPage API
This commit is contained in:
parent
937ae7ef8f
commit
5708e86a05
2 changed files with 17 additions and 27 deletions
|
@ -532,19 +532,13 @@ void WebContents::FindReply(content::WebContents* web_contents,
|
||||||
v8::HandleScope handle_scope(isolate());
|
v8::HandleScope handle_scope(isolate());
|
||||||
|
|
||||||
mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
|
mate::Dictionary result = mate::Dictionary::CreateEmpty(isolate());
|
||||||
if (number_of_matches == -1) {
|
|
||||||
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);
|
result.Set("requestId", request_id);
|
||||||
result.Set("matches", number_of_matches);
|
result.Set("matches", number_of_matches);
|
||||||
result.Set("finalUpdate", final_update);
|
result.Set("finalUpdate", final_update);
|
||||||
|
result.Set("selectionArea", selection_rect);
|
||||||
|
result.Set("activeMatchOrdinal", active_match_ordinal);
|
||||||
Emit("found-in-page", result);
|
Emit("found-in-page", result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool WebContents::CheckMediaAccessPermission(
|
bool WebContents::CheckMediaAccessPermission(
|
||||||
content::WebContents* web_contents,
|
content::WebContents* web_contents,
|
||||||
|
|
|
@ -780,25 +780,21 @@ 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
|
let requestId = null
|
||||||
var totalMatches = null
|
let activeMatchOrdinal = []
|
||||||
var activeMatchOrdinal = []
|
const listener = function (e) {
|
||||||
var listener = function (e) {
|
|
||||||
assert.equal(e.result.requestId, requestId)
|
assert.equal(e.result.requestId, requestId)
|
||||||
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)
|
activeMatchOrdinal.push(e.result.activeMatchOrdinal)
|
||||||
if (e.result.activeMatchOrdinal === totalMatches) {
|
if (e.result.activeMatchOrdinal === e.result.matches) {
|
||||||
assert.deepEqual(activeMatchOrdinal, [1, 2, 3])
|
assert.deepEqual(activeMatchOrdinal, [1, 2, 3])
|
||||||
webview.stopFindInPage('clearSelection')
|
webview.stopFindInPage('clearSelection')
|
||||||
done()
|
done()
|
||||||
|
} else {
|
||||||
|
listener2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
const listener2 = function () {
|
||||||
var listener2 = function () {
|
|
||||||
requestId = webview.findInPage('virtual')
|
requestId = webview.findInPage('virtual')
|
||||||
}
|
}
|
||||||
webview.addEventListener('found-in-page', listener)
|
webview.addEventListener('found-in-page', listener)
|
||||||
|
|
Loading…
Reference in a new issue