add api to webview
This commit is contained in:
		
					parent
					
						
							
								39e615ed87
							
						
					
				
			
			
				commit
				
					
						d162180196
					
				
			
		
					 12 changed files with 138 additions and 39 deletions
				
			
		| 
						 | 
					@ -225,7 +225,8 @@ WebContents::WebContents(content::WebContents* web_contents)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WebContents::WebContents(v8::Isolate* isolate,
 | 
					WebContents::WebContents(v8::Isolate* isolate,
 | 
				
			||||||
                         const mate::Dictionary& options) {
 | 
					                         const mate::Dictionary& options)
 | 
				
			||||||
 | 
					    : request_id_(0) {
 | 
				
			||||||
  // Whether it is a guest WebContents.
 | 
					  // Whether it is a guest WebContents.
 | 
				
			||||||
  bool is_guest = false;
 | 
					  bool is_guest = false;
 | 
				
			||||||
  options.Get("isGuest", &is_guest);
 | 
					  options.Get("isGuest", &is_guest);
 | 
				
			||||||
| 
						 | 
					@ -441,12 +442,12 @@ 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);
 | 
				
			||||||
    Emit("find-in-page-response", result);
 | 
					    Emit("found-in-page", result);
 | 
				
			||||||
  } else if (final_update) {
 | 
					  } 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);
 | 
				
			||||||
    Emit("find-in-page-response", result);
 | 
					    Emit("found-in-page", result);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -926,25 +927,19 @@ void WebContents::ReplaceMisspelling(const base::string16& word) {
 | 
				
			||||||
  web_contents()->ReplaceMisspelling(word);
 | 
					  web_contents()->ReplaceMisspelling(word);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WebContents::FindInPage(mate::Arguments* args) {
 | 
					uint32 WebContents::FindInPage(mate::Arguments* args) {
 | 
				
			||||||
  int request_id;
 | 
					  uint32 request_id = GetNextRequestId();
 | 
				
			||||||
  base::string16 search_text;
 | 
					  base::string16 search_text;
 | 
				
			||||||
  blink::WebFindOptions options;
 | 
					  blink::WebFindOptions options;
 | 
				
			||||||
  if (!args->GetNext(&request_id)) {
 | 
					  if (!args->GetNext(&search_text) || search_text.empty()) {
 | 
				
			||||||
    args->ThrowError("Must provide a request id");
 | 
					 | 
				
			||||||
    return;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (!args->GetNext(&search_text)) {
 | 
					 | 
				
			||||||
    args->ThrowError("Must provide a non-empty search content");
 | 
					    args->ThrowError("Must provide a non-empty search content");
 | 
				
			||||||
    return;
 | 
					    return 0;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  args->GetNext(&options);
 | 
					  args->GetNext(&options);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  web_contents()->Find(request_id, search_text, options);
 | 
					  web_contents()->Find(request_id, search_text, options);
 | 
				
			||||||
  web_contents()->GetMainFrame()
 | 
					  return request_id;
 | 
				
			||||||
                ->ActivateFindInPageResultForAccessibility(request_id);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void WebContents::StopFindInPage(content::StopFindAction action) {
 | 
					void WebContents::StopFindInPage(content::StopFindAction action) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -110,7 +110,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
 | 
				
			||||||
  void Unselect();
 | 
					  void Unselect();
 | 
				
			||||||
  void Replace(const base::string16& word);
 | 
					  void Replace(const base::string16& word);
 | 
				
			||||||
  void ReplaceMisspelling(const base::string16& word);
 | 
					  void ReplaceMisspelling(const base::string16& word);
 | 
				
			||||||
  void FindInPage(mate::Arguments* args);
 | 
					  uint32 FindInPage(mate::Arguments* args);
 | 
				
			||||||
  void StopFindInPage(content::StopFindAction action);
 | 
					  void StopFindInPage(content::StopFindAction action);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Focus.
 | 
					  // Focus.
 | 
				
			||||||
| 
						 | 
					@ -250,6 +250,10 @@ class WebContents : public mate::TrackableObject<WebContents>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AtomBrowserContext* GetBrowserContext() const;
 | 
					  AtomBrowserContext* GetBrowserContext() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint32 GetNextRequestId() {
 | 
				
			||||||
 | 
					    return ++request_id_;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Called when received a message from renderer.
 | 
					  // Called when received a message from renderer.
 | 
				
			||||||
  void OnRendererMessage(const base::string16& channel,
 | 
					  void OnRendererMessage(const base::string16& channel,
 | 
				
			||||||
                         const base::ListValue& args);
 | 
					                         const base::ListValue& args);
 | 
				
			||||||
| 
						 | 
					@ -271,6 +275,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
 | 
				
			||||||
  // The type of current WebContents.
 | 
					  // The type of current WebContents.
 | 
				
			||||||
  Type type_;
 | 
					  Type type_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Request id used for findInPage request.
 | 
				
			||||||
 | 
					  uint32 request_id_;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DISALLOW_COPY_AND_ASSIGN(WebContents);
 | 
					  DISALLOW_COPY_AND_ASSIGN(WebContents);
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -22,9 +22,10 @@ supportedWebViewEvents = [
 | 
				
			||||||
  'page-title-updated'
 | 
					  'page-title-updated'
 | 
				
			||||||
  'page-favicon-updated'
 | 
					  'page-favicon-updated'
 | 
				
			||||||
  'enter-html-full-screen'
 | 
					  'enter-html-full-screen'
 | 
				
			||||||
  'leave-html-full-screen',
 | 
					  'leave-html-full-screen'
 | 
				
			||||||
  'media-started-playing',
 | 
					  'media-started-playing'
 | 
				
			||||||
  'media-paused',
 | 
					  'media-paused'
 | 
				
			||||||
 | 
					  'found-in-page'
 | 
				
			||||||
]
 | 
					]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
nextInstanceId = 0
 | 
					nextInstanceId = 0
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -13,6 +13,7 @@
 | 
				
			||||||
#include "content/public/browser/native_web_keyboard_event.h"
 | 
					#include "content/public/browser/native_web_keyboard_event.h"
 | 
				
			||||||
#include "native_mate/dictionary.h"
 | 
					#include "native_mate/dictionary.h"
 | 
				
			||||||
#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
 | 
					#include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
 | 
				
			||||||
 | 
					#include "third_party/WebKit/public/web/WebFindOptions.h"
 | 
				
			||||||
#include "third_party/WebKit/public/web/WebInputEvent.h"
 | 
					#include "third_party/WebKit/public/web/WebInputEvent.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace {
 | 
					namespace {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -6,7 +6,6 @@
 | 
				
			||||||
#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
 | 
					#define ATOM_COMMON_NATIVE_MATE_CONVERTERS_BLINK_CONVERTER_H_
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "native_mate/converter.h"
 | 
					#include "native_mate/converter.h"
 | 
				
			||||||
#include "third_party/WebKit/public/web/WebFindOptions.h"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace blink {
 | 
					namespace blink {
 | 
				
			||||||
class WebInputEvent;
 | 
					class WebInputEvent;
 | 
				
			||||||
| 
						 | 
					@ -14,6 +13,7 @@ class WebMouseEvent;
 | 
				
			||||||
class WebMouseWheelEvent;
 | 
					class WebMouseWheelEvent;
 | 
				
			||||||
class WebKeyboardEvent;
 | 
					class WebKeyboardEvent;
 | 
				
			||||||
struct WebDeviceEmulationParams;
 | 
					struct WebDeviceEmulationParams;
 | 
				
			||||||
 | 
					struct WebFindOptions;
 | 
				
			||||||
struct WebFloatPoint;
 | 
					struct WebFloatPoint;
 | 
				
			||||||
struct WebPoint;
 | 
					struct WebPoint;
 | 
				
			||||||
struct WebSize;
 | 
					struct WebSize;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -111,8 +111,10 @@ bool Converter<content::StopFindAction>::FromV8(
 | 
				
			||||||
    *out = content::STOP_FIND_ACTION_CLEAR_SELECTION;
 | 
					    *out = content::STOP_FIND_ACTION_CLEAR_SELECTION;
 | 
				
			||||||
  else if (action == "keepSelection")
 | 
					  else if (action == "keepSelection")
 | 
				
			||||||
    *out = content::STOP_FIND_ACTION_KEEP_SELECTION;
 | 
					    *out = content::STOP_FIND_ACTION_KEEP_SELECTION;
 | 
				
			||||||
  else
 | 
					  else if (action == "activateSelection")
 | 
				
			||||||
    *out = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
 | 
					    *out = content::STOP_FIND_ACTION_ACTIVATE_SELECTION;
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    return false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return true;
 | 
					  return true;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -27,6 +27,7 @@ WEB_VIEW_EVENTS =
 | 
				
			||||||
  'page-favicon-updated': ['favicons']
 | 
					  'page-favicon-updated': ['favicons']
 | 
				
			||||||
  'enter-html-full-screen': []
 | 
					  'enter-html-full-screen': []
 | 
				
			||||||
  'leave-html-full-screen': []
 | 
					  'leave-html-full-screen': []
 | 
				
			||||||
 | 
					  'found-in-page': ['result']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
DEPRECATED_EVENTS =
 | 
					DEPRECATED_EVENTS =
 | 
				
			||||||
  'page-title-updated': 'page-title-set'
 | 
					  'page-title-updated': 'page-title-set'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -287,6 +287,8 @@ registerWebViewElement = ->
 | 
				
			||||||
    'unselect'
 | 
					    'unselect'
 | 
				
			||||||
    'replace'
 | 
					    'replace'
 | 
				
			||||||
    'replaceMisspelling'
 | 
					    'replaceMisspelling'
 | 
				
			||||||
 | 
					    'findInPage'
 | 
				
			||||||
 | 
					    'stopFindInPage'
 | 
				
			||||||
    'getId'
 | 
					    'getId'
 | 
				
			||||||
    'downloadURL'
 | 
					    'downloadURL'
 | 
				
			||||||
    'inspectServiceWorker'
 | 
					    'inspectServiceWorker'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,16 +229,16 @@ Emitted when media starts playing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Emitted when media is paused or done playing.
 | 
					Emitted when media is paused or done playing.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Event: 'find-in-page-response'
 | 
					### Event: 'found-in-page'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Returns:
 | 
					Returns:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `event` Event
 | 
					* `event` Event
 | 
				
			||||||
* `result` Object
 | 
					* `result` Object
 | 
				
			||||||
  * `requestId` Integer
 | 
					  * `requestId` Integer
 | 
				
			||||||
  * `matches` Integer __Optional__ - Number of Matches.
 | 
					 | 
				
			||||||
  * `selectionArea` Object __Optional__ - Coordinates of first match region.
 | 
					 | 
				
			||||||
  * `finalUpdate` Boolean - Indicates if more responses are to follow.
 | 
					  * `finalUpdate` Boolean - Indicates if more responses are to follow.
 | 
				
			||||||
 | 
					  * `matches` Integer (Optional) - Number of Matches.
 | 
				
			||||||
 | 
					  * `selectionArea` Object (Optional) - Coordinates of first match region.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Emitted when a result is available for
 | 
					Emitted when a result is available for
 | 
				
			||||||
[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
 | 
					[`webContents.findInPage`](web-contents.md#webcontentsfindinpage) request.
 | 
				
			||||||
| 
						 | 
					@ -434,38 +434,44 @@ Executes the editing command `replace` in web page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Executes the editing command `replaceMisspelling` in web page.
 | 
					Executes the editing command `replaceMisspelling` in web page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### `webContents.findInPage(id, text[, options])`
 | 
					### `webContents.findInPage(text[, options])`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `id` Integer
 | 
					 | 
				
			||||||
* `text` String - Content to be searched, must not be empty.
 | 
					* `text` String - Content to be searched, must not be empty.
 | 
				
			||||||
* `options` Object __Optional__
 | 
					* `options` Object (Optional)
 | 
				
			||||||
  * `forward` Boolean - Whether to search forward or backward.
 | 
					  * `forward` Boolean - Whether to search forward or backward, defaults to `true`.
 | 
				
			||||||
  * `findNext` Boolean - Whether the operation is first request or a follow up.
 | 
					  * `findNext` Boolean - Whether the operation is first request or a follow up,
 | 
				
			||||||
  * `matchCase` Boolean - Whether search should be case-sensitive.
 | 
					    defaults to `false`.
 | 
				
			||||||
 | 
					  * `matchCase` Boolean - Whether search should be case-sensitive,
 | 
				
			||||||
 | 
					    defaults to `false`.
 | 
				
			||||||
  * `wordStart` Boolean - Whether to look only at the start of words.
 | 
					  * `wordStart` Boolean - Whether to look only at the start of words.
 | 
				
			||||||
  * ` medialCapitalAsWordStart` Boolean - When combined with `wordStart`,
 | 
					    defaults to `false`.
 | 
				
			||||||
 | 
					  * `medialCapitalAsWordStart` Boolean - When combined with `wordStart`,
 | 
				
			||||||
    accepts a match in the middle of a word if the match begins with an
 | 
					    accepts a match in the middle of a word if the match begins with an
 | 
				
			||||||
    uppercase letter followed by a lowercase or non-letter.
 | 
					    uppercase letter followed by a lowercase or non-letter.
 | 
				
			||||||
    Accepts several other intra-word matches
 | 
					    Accepts several other intra-word matches, defaults to `false`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Finds all matches for the `text` in the web page.
 | 
					Starts a request to find all matches for the `text` in the web page and returns an `Integer`
 | 
				
			||||||
 | 
					representing the request id used for the request. The result of the request can be
 | 
				
			||||||
 | 
					obtained by subscribing to [`found-in-page`](web-contents.md#event-found-in-page) event.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### `webContents.stopFindInPage(action)`
 | 
					### `webContents.stopFindInPage(action)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* `action` String - Should be called with either `clearSelection` or `keepSelection`.
 | 
					* `action` String - Specifies the action to take place when ending
 | 
				
			||||||
                    By default it keeps the last selection.
 | 
					  [`webContents.findInPage `](web-contents.md#webcontentfindinpage) request.
 | 
				
			||||||
 | 
					  * `clearSelection` - Translate the selection into a normal selection.
 | 
				
			||||||
 | 
					  * `keepSelection` - Clear the selection.
 | 
				
			||||||
 | 
					  * `activateSelection` - Focus and click the selection node.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Stops any `findInPage` request for the `webContents`
 | 
					Stops any `findInPage` request for the `webContents` with the provided `action`.
 | 
				
			||||||
with the provided `action`.
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
```javascript
 | 
					```javascript
 | 
				
			||||||
webContents.on('find-in-page-response', function(event, result) {
 | 
					webContents.on('found-in-page', function(event, result) {
 | 
				
			||||||
  if (result.finalUpdate)
 | 
					  if (result.finalUpdate)
 | 
				
			||||||
    webContents.stopFindInPage("clearSelection");
 | 
					    webContents.stopFindInPage("clearSelection");
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
webContents.findInPage(1, "api");
 | 
					const requestId = webContents.findInPage("api");
 | 
				
			||||||
```.
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### `webContents.hasServiceWorker(callback)`
 | 
					### `webContents.hasServiceWorker(callback)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -348,6 +348,36 @@ Executes editing command `replace` in page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Executes editing command `replaceMisspelling` in page.
 | 
					Executes editing command `replaceMisspelling` in page.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `<webview>.findInPage(text[, options])`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `text` String - Content to be searched, must not be empty.
 | 
				
			||||||
 | 
					* `options` Object (Optional)
 | 
				
			||||||
 | 
					  * `forward` Boolean - Whether to search forward or backward, defaults to `true`.
 | 
				
			||||||
 | 
					  * `findNext` Boolean - Whether the operation is first request or a follow up,
 | 
				
			||||||
 | 
					    defaults to `false`.
 | 
				
			||||||
 | 
					  * `matchCase` Boolean - Whether search should be case-sensitive,
 | 
				
			||||||
 | 
					    defaults to `false`.
 | 
				
			||||||
 | 
					  * `wordStart` Boolean - Whether to look only at the start of words.
 | 
				
			||||||
 | 
					    defaults to `false`.
 | 
				
			||||||
 | 
					  * `medialCapitalAsWordStart` Boolean - When combined with `wordStart`,
 | 
				
			||||||
 | 
					    accepts a match in the middle of a word if the match begins with an
 | 
				
			||||||
 | 
					    uppercase letter followed by a lowercase or non-letter.
 | 
				
			||||||
 | 
					    Accepts several other intra-word matches, defaults to `false`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Starts a request to find all matches for the `text` in the web page and returns an `Integer`
 | 
				
			||||||
 | 
					representing the request id used for the request. The result of the request can be
 | 
				
			||||||
 | 
					obtained by subscribing to [`found-in-page`](web-view-tag.md#event-found-in-page) event.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### `<webview>.stopFindInPage(action)`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `action` String - Specifies the action to take place when ending
 | 
				
			||||||
 | 
					  [`<webview>.findInPage `](web-view-tag.md#webviewtagfindinpage) request.
 | 
				
			||||||
 | 
					  * `clearSelection` - Translate the selection into a normal selection.
 | 
				
			||||||
 | 
					  * `keepSelection` - Clear the selection.
 | 
				
			||||||
 | 
					  * `activateSelection` - Focus and click the selection node.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Stops any `findInPage` request for the `webview` with the provided `action`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### `<webview>.print([options])`
 | 
					### `<webview>.print([options])`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Prints `webview`'s web page. Same with `webContents.print([options])`.
 | 
					Prints `webview`'s web page. Same with `webContents.print([options])`.
 | 
				
			||||||
| 
						 | 
					@ -499,6 +529,28 @@ webview.addEventListener('console-message', function(e) {
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Event: 'found-in-page'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Returns:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* `result` Object
 | 
				
			||||||
 | 
					  * `requestId` Integer
 | 
				
			||||||
 | 
					  * `finalUpdate` Boolean - Indicates if more responses are to follow.
 | 
				
			||||||
 | 
					  * `matches` Integer (Optional) - Number of Matches.
 | 
				
			||||||
 | 
					  * `selectionArea` Object (Optional) - Coordinates of first match region.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Fired when a result is available for
 | 
				
			||||||
 | 
					[`webview.findInPage`](web-view-tag.md#webviewtagfindinpage) request.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```javascript
 | 
				
			||||||
 | 
					webview.addEventListener('found-in-page', function(e) {
 | 
				
			||||||
 | 
					  if (e.result.finalUpdate)
 | 
				
			||||||
 | 
					    webview.stopFindInPage("keepSelection");
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const rquestId = webview.findInPage("test");
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Event: 'new-window'
 | 
					### Event: 'new-window'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Returns:
 | 
					Returns:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										16
									
								
								spec/fixtures/pages/content.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								spec/fixtures/pages/content.html
									
										
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,16 @@
 | 
				
			||||||
 | 
					<p>
 | 
				
			||||||
 | 
					  Virtual member functions are key to the object-oriented paradigm,
 | 
				
			||||||
 | 
					  such as making it easy for old code to call new code.
 | 
				
			||||||
 | 
					  A virtual function allows derived classes to replace the implementation
 | 
				
			||||||
 | 
					  provided by the base class. The compiler makes sure the replacement is
 | 
				
			||||||
 | 
					  always called whenever the object in question is actually of the derived class,
 | 
				
			||||||
 | 
					  even if the object is accessed by a base pointer rather than a derived pointer.
 | 
				
			||||||
 | 
					  This allows algorithms in the base class to be replaced in the derived class,
 | 
				
			||||||
 | 
					  even if users dont know about the derived class.
 | 
				
			||||||
 | 
					  <code>
 | 
				
			||||||
 | 
					    class A {
 | 
				
			||||||
 | 
					     public:
 | 
				
			||||||
 | 
					      virtual void foo() {}
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  </code>
 | 
				
			||||||
 | 
					</p>
 | 
				
			||||||
| 
						 | 
					@ -390,3 +390,19 @@ describe '<webview> tag', ->
 | 
				
			||||||
        done()
 | 
					        done()
 | 
				
			||||||
      webview.src = "file://#{fixtures}/pages/audio.html"
 | 
					      webview.src = "file://#{fixtures}/pages/audio.html"
 | 
				
			||||||
      document.body.appendChild webview
 | 
					      document.body.appendChild webview
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  describe 'found-in-page event', ->
 | 
				
			||||||
 | 
					    it 'emits when a request is made', (done) ->
 | 
				
			||||||
 | 
					      requestId = null
 | 
				
			||||||
 | 
					      listener = (e) ->
 | 
				
			||||||
 | 
					        assert.equal e.result.requestId, requestId
 | 
				
			||||||
 | 
					        if e.result.finalUpdate
 | 
				
			||||||
 | 
					          assert.equal e.result.matches, 3
 | 
				
			||||||
 | 
					          webview.stopFindInPage "clearSelection"
 | 
				
			||||||
 | 
					          done()
 | 
				
			||||||
 | 
					      listener2 = (e) ->
 | 
				
			||||||
 | 
					        requestId = webview.findInPage "virtual"
 | 
				
			||||||
 | 
					      webview.addEventListener 'found-in-page', listener
 | 
				
			||||||
 | 
					      webview.addEventListener 'did-finish-load', listener2
 | 
				
			||||||
 | 
					      webview.src = "file://#{fixtures}/pages/content.html"
 | 
				
			||||||
 | 
					      document.body.appendChild webview
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue