Merge pull request #1 from electron/master

Update
This commit is contained in:
christoth 2016-04-12 12:38:40 -04:00
commit 1379e4f2dc
61 changed files with 417 additions and 162 deletions

View file

@ -1 +1 @@
v5.1.1
v5.10.0

View file

@ -14,11 +14,13 @@
#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/native_window.h"
#include "atom/browser/net/atom_network_delegate.h"
#include "atom/browser/web_contents_permission_helper.h"
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_view_guest_delegate.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/mouse_util.h"
#include "atom/common/native_mate_converters/blink_converter.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/content_converter.h"
@ -28,13 +30,14 @@
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/string16_converter.h"
#include "atom/common/native_mate_converters/value_converter.h"
#include "atom/common/mouse_util.h"
#include "atom/common/options_switches.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
#include "chrome/browser/printing/print_view_manager_basic.h"
#include "chrome/browser/printing/print_preview_message_handler.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/common/view_messages.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/native_web_keyboard_event.h"
@ -212,7 +215,9 @@ content::ServiceWorkerContext* GetServiceWorkerContext(
WebContents::WebContents(content::WebContents* web_contents)
: content::WebContentsObserver(web_contents),
type_(REMOTE) {
type_(REMOTE),
request_id_(0),
background_throttling_(true) {
AttachAsUserData(web_contents);
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
}
@ -220,7 +225,11 @@ WebContents::WebContents(content::WebContents* web_contents)
WebContents::WebContents(v8::Isolate* isolate,
const mate::Dictionary& options)
: embedder_(nullptr),
request_id_(0) {
request_id_(0),
background_throttling_(true) {
// Read options.
options.Get("backgroundThrottling", &background_throttling_);
// Whether it is a guest WebContents.
bool is_guest = false;
options.Get("isGuest", &is_guest);
@ -579,7 +588,8 @@ void WebContents::DidGetResourceResponseStart(
details.http_response_code,
details.method,
details.referrer,
details.headers.get());
details.headers.get(),
ResourceTypeToString(details.resource_type));
}
void WebContents::DidGetRedirectForResourceRequest(
@ -625,6 +635,10 @@ void WebContents::DidUpdateFaviconURL(
Emit("page-favicon-updated", unique_urls);
}
void WebContents::DevToolsReloadPage() {
Emit("devtools-reload-page");
}
void WebContents::DevToolsFocused() {
Emit("devtools-focused");
}
@ -744,8 +758,13 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) {
// override the background color set by the user.
// We have to call it right after LoadURL because the RenderViewHost is only
// created after loading a page.
web_contents()->GetRenderViewHost()->GetWidget()->GetView()
->SetBackgroundColor(SK_ColorTRANSPARENT);
const auto view = web_contents()->GetRenderWidgetHostView();
view->SetBackgroundColor(SK_ColorTRANSPARENT);
// For the same reason we can only disable hidden here.
const auto host = static_cast<content::RenderWidgetHostImpl*>(
view->GetRenderWidgetHost());
host->disable_hidden_ = !background_throttling_;
}
void WebContents::DownloadURL(const GURL& url) {

View file

@ -251,6 +251,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
void MediaStoppedPlaying(const MediaPlayerId& id) override;
void DidChangeThemeColor(SkColor theme_color) override;
// brightray::InspectableWebContentsDelegate:
void DevToolsReloadPage() override;
// brightray::InspectableWebContentsViewDelegate:
void DevToolsFocused() override;
void DevToolsOpened() override;
@ -296,6 +299,9 @@ class WebContents : public mate::TrackableObject<WebContents>,
// Request id used for findInPage request.
uint32_t request_id_;
// Whether background throttling is disabled.
bool background_throttling_;
DISALLOW_COPY_AND_ASSIGN(WebContents);
};

View file

@ -5,20 +5,18 @@
#include "atom/browser/net/atom_network_delegate.h"
#include <string>
#include <utility>
#include "atom/common/native_mate_converters/net_converter.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/resource_request_info.h"
#include "net/url_request/url_request.h"
using content::BrowserThread;
namespace atom {
namespace {
const char* ResourceTypeToString(content::ResourceType type) {
switch (type) {
case content::RESOURCE_TYPE_MAIN_FRAME:
@ -40,6 +38,11 @@ const char* ResourceTypeToString(content::ResourceType type) {
}
}
namespace {
using ResponseHeadersContainer =
std::pair<scoped_refptr<net::HttpResponseHeaders>*, const std::string&>;
void RunSimpleListener(const AtomNetworkDelegate::SimpleListener& listener,
scoped_ptr<base::DictionaryValue> details) {
return listener.Run(*(details.get()));
@ -170,10 +173,15 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
}
void ReadFromResponseObject(const base::DictionaryValue& response,
scoped_refptr<net::HttpResponseHeaders>* headers) {
const ResponseHeadersContainer& container) {
const base::DictionaryValue* dict;
std::string status_line;
if (!response.GetString("statusLine", &status_line))
status_line = container.second;
if (response.GetDictionary("responseHeaders", &dict)) {
auto headers = container.first;
*headers = new net::HttpResponseHeaders("");
(*headers)->ReplaceStatusLine(status_line);
for (base::DictionaryValue::Iterator it(*dict);
!it.IsAtEnd();
it.Advance()) {
@ -263,7 +271,8 @@ int AtomNetworkDelegate::OnHeadersReceived(
request, callback, original, override, allowed);
return HandleResponseEvent(
kOnHeadersReceived, request, callback, override, original);
kOnHeadersReceived, request, callback,
std::make_pair(override, original->GetStatusLine()), original);
}
void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,

View file

@ -15,6 +15,7 @@
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "content/public/browser/resource_request_info.h"
namespace extensions {
class URLPattern;
@ -24,6 +25,8 @@ namespace atom {
using URLPatterns = std::set<extensions::URLPattern>;
const char* ResourceTypeToString(content::ResourceType type);
class AtomNetworkDelegate : public brightray::NetworkDelegate {
public:
using ResponseCallback = base::Callback<void(const base::DictionaryValue&)>;

View file

@ -13,7 +13,9 @@
namespace {
bool XDGUtil(const std::string& util, const std::string& arg) {
bool XDGUtil(const std::string& util,
const std::string& arg,
const bool wait_for_exit) {
std::vector<std::string> argv;
argv.push_back(util);
argv.push_back(arg);
@ -30,6 +32,11 @@ bool XDGUtil(const std::string& util, const std::string& arg) {
if (!process.IsValid())
return false;
if (!wait_for_exit) {
base::EnsureProcessGetsReaped(process.Pid());
return true;
}
int exit_code = -1;
if (!process.WaitForExit(&exit_code))
return false;
@ -37,12 +44,12 @@ bool XDGUtil(const std::string& util, const std::string& arg) {
return (exit_code == 0);
}
bool XDGOpen(const std::string& path) {
return XDGUtil("xdg-open", path);
bool XDGOpen(const std::string& path, const bool wait_for_exit) {
return XDGUtil("xdg-open", path, wait_for_exit);
}
bool XDGEmail(const std::string& email) {
return XDGUtil("xdg-email", email);
bool XDGEmail(const std::string& email, const bool wait_for_exit) {
return XDGUtil("xdg-email", email, wait_for_exit);
}
} // namespace
@ -57,22 +64,24 @@ void ShowItemInFolder(const base::FilePath& full_path) {
if (!base::DirectoryExists(dir))
return;
XDGOpen(dir.value());
XDGOpen(dir.value(), true);
}
void OpenItem(const base::FilePath& full_path) {
XDGOpen(full_path.value());
XDGOpen(full_path.value(), true);
}
bool OpenExternal(const GURL& url, bool activate) {
// Don't wait for exit, since we don't want to wait for the browser/email
// client window to close before returning
if (url.SchemeIs("mailto"))
return XDGEmail(url.spec());
return XDGEmail(url.spec(), false);
else
return XDGOpen(url.spec());
return XDGOpen(url.spec(), false);
}
bool MoveItemToTrash(const base::FilePath& full_path) {
return XDGUtil("gvfs-trash", full_path.value());
return XDGUtil("gvfs-trash", full_path.value(), true);
}
void Beep() {

View file

@ -27,6 +27,7 @@
#include "third_party/WebKit/public/web/WebFrame.h"
#include "third_party/WebKit/public/web/WebLocalFrame.h"
#include "third_party/WebKit/public/web/WebKit.h"
#include "third_party/WebKit/public/web/WebScriptSource.h"
#include "third_party/WebKit/public/web/WebView.h"
#include "ui/base/resource/resource_bundle.h"
#include "native_mate/dictionary.h"
@ -88,6 +89,9 @@ void AtomRenderViewObserver::DidCreateDocumentElement(
blink::WebLocalFrame* frame) {
document_created_ = true;
// Make sure every page will get a script context created.
frame->executeScript(blink::WebScriptSource("void 0"));
// Read --zoom-factor from command line.
std::string zoom_factor_str = base::CommandLine::ForCurrentProcess()->
GetSwitchValueASCII(switches::kZoomFactor);

View file

@ -2,8 +2,14 @@
이 모듈은 `Squirrel` 자동 업데이트 프레임워크의 인터페이스를 제공합니다.
[electron-release-server](https://github.com/ArekSredzki/electron-release-server)를
포크하면 어플리케이션을 배포하기 위한 멀티 플랫폼 릴리즈 서버를 손쉽게 구축할 수 있습니다.
다음 프로젝트 중 하나를 택하여 사용하면, 어플리케이션을 배포하기 위한 멀티 플랫폼
릴리즈 서버를 손쉽게 구축할 수 있습니다:
- [electron-release-server][electron-release-server]: *완벽하게 모든 기능을
지원하는 electron 어플리케이션을 위한 자가 호스트 릴리즈 서버입니다. auto-updater와
호환됩니다*
- [squirrel-updates-server][squirrel-updates-server]: *GitHub 릴리즈를 사용하는
Squirrel.Mac 와 Squirrel.Windows를 위한 간단한 node.js 기반 서버입니다*
## 플랫폼별 참고 사항
@ -16,6 +22,9 @@ OS X에선 `auto-updater` 모듈이 [Squirrel.Mac][squirrel-mac]를 기반으로
따라서 이 모듈을 작동시키기 위해 특별히 준비해야 할 작업은 없습니다.
서버 사이드 요구 사항은 [서버 지원][server-support]을 참고하세요.
**참고:** Mac OS X에서 자동 업데이트를 지원하려면 반드시 사인이 되어있어야 합니다.
이것은 `Squirrel.Mac`의 요구사항입니다.
### Windows
Windows에선 `auto-updater` 모듈을 사용하기 전에 어플리케이션을 사용자의 장치에
@ -95,5 +104,7 @@ Returns:
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
[squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows
[installer]: https://github.com/atom/grunt-electron-installer
[installer]: https://github.com/electron/grunt-electron-installer
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
[electron-release-server]: https://github.com/ArekSredzki/electron-release-server
[squirrel-updates-server]: https://github.com/Aluxian/squirrel-updates-server

View file

@ -173,6 +173,8 @@ win.show();
* `defaultMonospaceFontSize` Integer - 기본값 `13`.
* `minimumFontSize` Integer - 기본값 `0`.
* `defaultEncoding` String - 기본값 `ISO-8859-1`.
* `backgroundThrottling` Boolean - 페이지가 백그라운드 상태에 진입할 때 애니메이션과
타이머에 스로틀을 적용할지 여부입니다. 기본값은 `true`입니다.
## Events

View file

@ -20,7 +20,7 @@ crashReporter.start({
있습니다:
* [socorro](https://github.com/mozilla/socorro)
* [mini-breakpad-server](https://github.com/atom/mini-breakpad-server)
* [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
## Methods
@ -43,7 +43,7 @@ crashReporter.start({
**참고:** OS X에선 Windows와 Linux의 `breakpad`와 달리 새로운 `crashpad`
클라이언트를 사용합니다. 오류 수집 기능을 활성화 시키려면 오류를 수집하고 싶은 메인
프로세스나 랜더러 프로세스에서 `crashReporter.start` 메서드를 호출하여 `crashpad`
초기화 해야합니다.
초기화해야 합니다.
### `crashReporter.getLastCrashReport()`

View file

@ -1,6 +1,6 @@
# Frameless Window
Frameless Window는 [창 테두리](https://developer.mozilla.org/en-US/docs/Glossary/Chrome)가
Frameless Window는 [창 테두리](https://developer.mozilla.org/ko/docs/Glossary/Chrome)가
없는 윈도우를 말합니다. 이 기능은 윈도우의 일부분인 툴바와 같이 웹 페이지의 일부분이
아닌 부분을 보이지 않도록 합니다. [`BrowserWindow`](browser-window.md) 클래스의
옵션에서 설정할 수 있습니다.

View file

@ -1,6 +1,6 @@
# Menu
`menu` 클래스는 어플리케이션 메뉴와 [컨텍스트 메뉴](https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/PopupGuide/ContextMenus)를
`menu` 클래스는 어플리케이션 메뉴와 [컨텍스트 메뉴](https://developer.mozilla.org/ko/docs/Mozilla/Tech/XUL/PopupGuide/ContextMenus)를
만들 때 사용됩니다. 이 모듈은 메인 프로세스용 모듈이지만 `remote` 모듈을 통해 랜더러
프로세스에서도 사용할 수 있습니다.
@ -382,4 +382,4 @@ OS X에선 지정한 어플리케이션 메뉴에 상관없이 메뉴의 첫번
```
[AboutInformationPropertyListFiles]: https://developer.apple.com/library/ios/documentation/general/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html
[setMenu]: https://github.com/electron/electron/blob/master/docs-translations/ko-KR/api/browser-window.md#winsetmenumenu-linux-windows
[setMenu]: ./browser-window.md#winsetmenumenu-linux-windows

View file

@ -5,7 +5,7 @@
Electron의 메인 프로세스에선 GUI와 관련 있는(`dialog`, `menu`등) 모듈만 사용할 수
있습니다. 랜더러 프로세스에서 이러한 모듈들을 사용하려면 `ipc` 모듈을 통해 메인
프로세스와 inter-process 통신을 해야합니다. 또한, `remote` 모듈을 사용하면
프로세스와 inter-process 통신을 해야 합니다. 또한, `remote` 모듈을 사용하면
inter-process 통신을 하지 않고도 간단한 API를 통해 직접 메인 프로세스의 모듈과
메서드를 사용할 수 있습니다. 이 개념은 Java의 [RMI][rmi]와 비슷합니다.
@ -34,7 +34,7 @@ win.loadURL('https://github.com');
않습니다. 대신에 이 `BrowserWindow` 객체는 메인 프로세스에서 생성되며 랜더러
프로세스에 `win` 객체와 같이 이에 대응하는 remote 객체를 반환합니다.
참고로 remote를 통해선 [enumerable 속성](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Enumerability_and_ownership_of_properties)을
참고로 remote를 통해선 [enumerable 속성](https://developer.mozilla.org/ko/docs/Web/JavaScript/Enumerability_and_ownership_of_properties)을
가진 프로퍼티에만 접근할 수 있습니다.
## Remote 객체의 생명 주기

View file

@ -78,5 +78,5 @@ require('electron').hideInternalModules()
```
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
[destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
[destructuring-assignment]: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
[issue-387]: https://github.com/electron/electron/issues/387

View file

@ -11,7 +11,7 @@ const Tray = electron.Tray;
var appIcon = null;
app.on('ready', function(){
appIcon = new Tray('/path/to/my/icon'); // 현재 어플리케이션 디렉터리를 기준으로 하려면 `__dirname + '/images/tray.png'` 형식으로 입력해야합니다.
appIcon = new Tray('/path/to/my/icon'); // 현재 어플리케이션 디렉터리를 기준으로 하려면 `__dirname + '/images/tray.png'` 형식으로 입력해야 합니다.
var contextMenu = Menu.buildFromTemplate([
{ label: 'Item1', type: 'radio' },
{ label: 'Item2', type: 'radio' },

View file

@ -67,6 +67,7 @@ Returns:
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
요청한 리소스에 관련된 자세한 정보를 사용할 수 있을 때 발생하는 이벤트입니다.
`status`는 리소스를 다운로드하기 위한 소켓 연결을 나타냅니다.

View file

@ -17,9 +17,15 @@
수 있습니다:
```html
<webview id="foo" src="https://www.github.com/" style="display:inline-block; width:640px; height:480px"></webview>
<webview id="foo" src="https://www.github.com/" style="display:inline-flex; width:640px; height:480px"></webview>
```
주의할 점은 `webview` 태그의 스타일은 전통적인 flexbox 레이아웃을 사용했을 때 자식
`object` 요소가 해당 `webview` 컨테이너의 전체 높이와 넓이를 확실히 채우도록
내부적으로 `display:flex;`를 사용합니다. (v0.36.11 부터) 따라서 인라인 레이아웃을
위해 `display:inline-flex;`를 쓰지 않는 한, 기본 `display:flex;` CSS 속성을
덮어쓰지 않도록 주의해야 합니다.
게스트 컨텐츠를 조작하기 위해 자바스크립트로 `webview` 태그의 이벤트를 리스닝 하여
응답을 받을 수 있습니다. 다음 예제를 참고하세요: 첫번째 리스너는 페이지 로딩 시작시의
이벤트를 확인하고 두번째 리스너는 페이지의 로딩이 끝난시점을 확인합니다. 그리고
@ -495,6 +501,7 @@ Returns:
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
요청한 리소스에 관해 자세한 내용을 알 수 있을 때 발생하는 이벤트입니다.
`status`는 리소스를 다운로드할 소켓 커낵션을 나타냅니다.

View file

@ -16,7 +16,7 @@ main 필드에 메인 웹 페이지(index.html) URL을 지정하면 어플리케
Electron에선 JavaScript를 엔트리 포인트로 사용합니다. URL을 직접 제공하는 대신 API를
사용하여 직접 브라우저 창과 HTML 파일을 로드할 수 있습니다. 또한 윈도우의 종료시기를
결정하는 이벤트를 리스닝해야합니다.
결정하는 이벤트를 리스닝해야 합니다.
Electron은 Node.js 런타임과 비슷하게 작동합니다. Electron의 API는 저수준이기에
브라우저 테스팅을 위해 [PhantomJS](http://phantomjs.org/)를 사용할 수도 있습니다.

View file

@ -26,17 +26,17 @@ C++ 코드는 많은 Chromium의 추상화와 타입을 사용합니다. 따라
* [표준](http://npm.im/standard) JavaScript 코딩 스타일을 사용합니다.
* Google의 코딩 스타일에도 맞추기 위해 파일의 끝에는 **절대** 개행을 삽입해선 안됩니다.
* 파일 이름의 공백은 `_`대신에 `-`을 사용하여야 합니다. 예를 들어
`file_name.js``file-name.js`로 고쳐야합니다. 왜냐하면
`file_name.js``file-name.js`로 고쳐야 합니다. 왜냐하면
[github/atom](https://github.com/github/atom)에서 사용되는 모듈의 이름은 보통
`module-name` 형식이기 때문입니다. 이 규칙은 '.js' 파일에만 적용됩니다.
* 적절한 곳에 새로운 ES6/ES2015 문법을 사용해도 됩니다.
* [`const`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)
* [`const`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/const)
는 requires와 다른 상수에 사용합니다
* [`let`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let)
* [`let`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Statements/let)
은 변수를 정의할 때 사용합니다
* [Arrow functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)
* [Arrow functions](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Functions/Arrow_functions)
`function () { }` 표현 대신에 사용합니다
* [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
* [Template literals](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Template_literals)
`+`로 문자열을 합치는 대신 사용합니다.
## API 이름

View file

@ -14,7 +14,7 @@
공식적인 Electron의 심볼 서버의 URL은
http://54.249.141.255:8086/atom-shell/symbols 입니다. 일단 이 URL에 직접적으로
접근할 수는 없습니다: 디버깅 툴에 심볼의 경로를 추가해야합니다. 아래의 예제를 참고하면
접근할 수는 없습니다: 디버깅 툴에 심볼의 경로를 추가해야 합니다. 아래의 예제를 참고하면
로컬 캐시 디렉터리는 서버로부터 중복되지 않게 PDB를 가져오는데 사용됩니다.
`c:\code\symbols` 캐시 디렉터리를 사용중인 OS에 맞춰 적당한 경로로 변경하세요.
@ -30,7 +30,7 @@ SRV*c:\code\symbols\*http://54.249.141.255:8086/atom-shell/symbols
Windbg 메뉴 또는 `.sympath` 커맨드를 이용하여 환경에 `_NT_SYMBOL_PATH` 문자열을
설정합니다. 만약 Microsoft의 심볼서버로부터 심볼을 받아오려면 다음과 같이 리스팅을
먼저 해야합니다:
먼저해야 합니다:
```
SRV*c:\code\symbols\*http://msdl.microsoft.com/download/symbols;SRV*c:\code\symbols\*http://54.249.141.255:8086/atom-shell/symbols

View file

@ -147,7 +147,7 @@ npm uninstall -g electron
[memory-management]: https://developer.mozilla.org/ko/docs/Web/JavaScript/Memory_Management
[variable-scope]: https://msdn.microsoft.com/library/bzt2dkta(v=vs.94).aspx
[electron-module]: https://www.npmjs.com/package/electron
[storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage
[local-storage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
[session-storage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage
[indexed-db]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
[storage]: https://developer.mozilla.org/ko/docs/Web/API/Storage
[local-storage]: https://developer.mozilla.org/ko/docs/Web/API/Window/localStorage
[session-storage]: https://developer.mozilla.org/ko/docs/Web/API/Window/sessionStorage
[indexed-db]: https://developer.mozilla.org/ko/docs/Web/API/IndexedDB_API

View file

@ -50,7 +50,7 @@ Electron 문서 구조를 이해하는 데 참고할 수 있는 유용한 도움
### Methods
[Method](https://developer.mozilla.org/en-US/docs/Glossary/Method) 문서의
[Method](https://developer.mozilla.org/ko/docs/Glossary/Method) 문서의
예제입니다:
---
@ -66,16 +66,16 @@ Electron 문서 구조를 이해하는 데 참고할 수 있는 유용한 도움
묶어 이 인수가 다른 인수뒤에서 선택적으로 사용될 수 있다는 것을 표시합니다.
메서드 이름 하단에선 각 인수에 대해 자세한 설명을 합니다. 인수의 타입은:
[`String`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String),
[`Number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number),
[`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object),
[`Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
[`String`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/String),
[`Number`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Number),
[`Object`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Object),
[`Array`](https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array)
와 같은 일반적으로 쓰이는 타입 중 하나를 받거나 Electron의 [`webContent`](api/web-content.md)
같은 커스텀 타입을 받습니다.
### Events
[Event](https://developer.mozilla.org/en-US/docs/Web/API/Event) 문서의 예제입니다:
[Event](https://developer.mozilla.org/ko/docs/Web/API/Event) 문서의 예제입니다:
---

View file

@ -30,7 +30,7 @@ electron/resources/app
## asar로 앱 패키징 하기
소스파일 전체를 복사해서 배포하는 것과는 별개로 [asar](https://github.com/atom/asar)
소스파일 전체를 복사해서 배포하는 것과는 별개로 [asar](https://github.com/electron/asar)
아카이브를 통해 어플리케이션의 소스코드가 사용자에게 노출되는 것을 방지할 수 있습니다.
`asar` 아카이브를 사용할 땐 단순히 `app` 폴더 대신에 어플리케이션을 패키징한

View file

@ -179,4 +179,4 @@ $ asar pack app app.asar --unpack *.node
포함되어 있습니다. 사용자에게 어플리케이션을 배포할 때 반드시 해당 폴더도 같이 배포해야
합니다.
[asar]: https://github.com/atom/asar
[asar]: https://github.com/electron/asar

View file

@ -17,7 +17,7 @@ Electron은 v0.34.0 버전부터 앱 패키지를 Mac App Store(MAS)에 제출
다음 몇 가지 간단한 절차에 따라 앱 스토어에 어플리케이션을 등록하는 방법을 알아봅니다.
한가지, 이 절차는 제출한 앱이 Apple로부터 승인되는 것을 보장하지 않습니다. 따라서
여전히 Apple의 [Submitting Your App][submitting-your-app] 가이드를 숙지하고 있어야
하며 앱 스토어 제출 요구 사항을 확실히 인지하고 있어야합니다.
하며 앱 스토어 제출 요구 사항을 확실히 인지하고 있어야 합니다.
### 인증서 취득

View file

@ -11,7 +11,7 @@ Electron의 V8 버전에 맞춰 네이티브 모듈을 다시 빌드하고 헤
node.js의 버전을 확인할 필요가 있습니다. Electron에서 사용하는 node 버전은
[releases](https://github.com/electron/electron/releases)에서 확인할 수 있으며
`process.version`을 출력하여 버전을 확인할 수도 있습니다.
([시작하기](https://github.com/electron/electron/blob/master/docs/tutorial/quick-start.md)의
([시작하기](./quick-start.md)의
예제를 참고하세요)
혹시 직접 만든 네이티브 모듈이 있다면 [NAN](https://github.com/nodejs/nan/) 모듈을

View file

@ -13,7 +13,7 @@ Pepper 플래시 플러그인을 사용하려면 Pepper 플래시 플러그인
플러그인을 사용하려면 Electron 커맨드 라인에 `--ppapi-flash-path`
`ppapi-flash-version` 플래그를 app의 ready 이벤트가 호출되기 전에 추가해야 합니다.
그리고 `browser-window``plugins` 스위치도 추가해야합니다.
그리고 `browser-window``plugins` 스위치도 추가해야 합니다.
```javascript
// 플래시 플러그인의 위치를 설정합니다.

View file

@ -63,6 +63,7 @@ var webContents = win.webContents;
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
当有关请求资源的详细信息可用的时候发出事件.
`status` 标识了 socket链接来下载资源.

View file

@ -457,6 +457,7 @@ Returns:
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
当获得返回详情的时候触发.

View file

@ -27,7 +27,7 @@ electron/resources/app
## 将你的应用程序打包成一个文件
除了通过拷贝所有的资源文件来分发你的应用程序之外,你可以可以通过打包你的应用程序为一个 [asar](https://github.com/atom/asar) 库文件以避免暴露你的源代码。
除了通过拷贝所有的资源文件来分发你的应用程序之外,你可以通过打包你的应用程序为一个 [asar](https://github.com/atom/asar) 库文件以避免暴露你的源代码。
为了使用一个 `asar` 库文件代替 `app` 文件夹,你需要修改这个库文件的名字为 `app.asar`
然后将其放到 Electron 的资源文件夹下,然后 Electron 就会试图读取这个库文件并从中启动。

View file

@ -40,7 +40,7 @@ your-app/
```
**注意**:如果 `main` 字段没有在 `package.json` 声明Electron会优先加载 `index.js`
`main.js` 应该用于创建窗口和处理系统时间,一个典型的例子如下:
`main.js` 应该用于创建窗口和处理系统事件,一个典型的例子如下:
```javascript
var app = require('app'); // 控制应用生命周期的模块。
var BrowserWindow = require('browser-window'); // 创建原生浏览器窗口的模块

View file

@ -19,6 +19,9 @@ On OS X, the `autoUpdater` module is built upon [Squirrel.Mac][squirrel-mac],
meaning you don't need any special setup to make it work. For server-side
requirements, you can read [Server Support][server-support].
**Note:** Your application must be signed for automatic updates on Mac OS X.
This is a requirement of `Squirrel.Mac`.
### Windows
On Windows, you have to install your app into a user's machine before you can

View file

@ -179,6 +179,8 @@ The `webPreferences` option is an object that can have following properties:
* `defaultMonospaceFontSize` Integer - Defaults to `13`.
* `minimumFontSize` Integer - Defaults to `0`.
* `defaultEncoding` String - Defaults to `ISO-8859-1`.
* `backgroundThrottling` Boolean - Whether to throttle animations and timers
when the page becomes background. Defaults to `true`.
## Events

View file

@ -446,6 +446,8 @@ The `callback` has to be called with an `response` object:
* `cancel` Boolean
* `responseHeaders` Object (optional) - When provided, the server is assumed
to have responded with these headers.
* `statusLine` String (optional) - Should be provided when overriding `responseHeaders`
to change header status otherwise original response header's status will be used.
#### `ses.webRequest.onResponseStarted([filter, ]listener)`

View file

@ -68,6 +68,7 @@ Returns:
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
Emitted when details regarding a requested resource are available.
`status` indicates the socket connection to download the resource.

View file

@ -510,6 +510,7 @@ Returns:
* `requestMethod` String
* `referrer` String
* `headers` Object
* `resourceType` String
Fired when details regarding a requested resource is available.
`status` indicates socket connection to download the resource.

View file

@ -39,9 +39,16 @@ etc.
* [Template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals)
instead of string concatenation using `+`
## API Names
## Naming Things
When creating a new API, we should prefer getters and setters instead of
Electron APIs uses the same capitalization scheme as Node.js:
- When the module itself is a class like `BrowserWindow`, use `CamelCase`.
- When the module is a set of APIs, like `globalShortcut`, use `mixedCase`.
- When the API is a property of object, and it is complex enough to be in a separate chapter like `win.webContents`, use `mixedCase`.
- For other non-module APIs, use natural titles, like `<webview> Tag` or `Process Object`.
When creating a new API, it is preferred to use getters and setters instead of
jQuery's one-function style. For example, `.getText()` and `.setText(text)`
are preferred to `.text([text])`. There is a
[discussion](https://github.com/electron/electron/issues/46) on this.

View file

@ -28,7 +28,7 @@ BrowserWindow.prototype._init = function () {
width: 800,
height: 600
}
return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options)
return ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options)
})
// window.resizeTo(...)
@ -80,16 +80,16 @@ BrowserWindow.prototype._init = function () {
// Evented visibilityState changes
this.on('show', () => {
this.webContents.send('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
})
this.on('hide', () => {
this.webContents.send('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
})
this.on('minimize', () => {
this.webContents.send('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
})
this.on('restore', () => {
this.webContents.send('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
this.webContents.send('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', this.isVisible(), this.isMinimized())
})
// Notify the creation of the window.

View file

@ -3,12 +3,12 @@
const ipcMain = require('electron').ipcMain
// The history operation in renderer is redirected to browser.
ipcMain.on('ATOM_SHELL_NAVIGATION_CONTROLLER', function (event, method, ...args) {
ipcMain.on('ELECTRON_NAVIGATION_CONTROLLER', function (event, method, ...args) {
var ref
(ref = event.sender)[method].apply(ref, args)
})
ipcMain.on('ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER', function (event, method, ...args) {
ipcMain.on('ELECTRON_SYNC_NAVIGATION_CONTROLLER', function (event, method, ...args) {
var ref
event.returnValue = (ref = event.sender)[method].apply(ref, args)
})

View file

@ -155,6 +155,11 @@ let wrapWebContents = function (webContents) {
})
})
// The devtools requests the webContents to reload.
webContents.on('devtools-reload-page', function () {
webContents.reload()
})
// Delays the page-title-updated event to next tick.
webContents.on('-page-title-updated', function (...args) {
setImmediate(() => {
@ -168,6 +173,7 @@ let wrapWebContents = function (webContents) {
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function (...args) {
return this.emit.apply(this, ['page-title-set'].concat(args))
})
webContents.printToPDF = function (options, callback) {
var printingSetting
printingSetting = {

View file

@ -10,7 +10,7 @@ var deepEqual = function (opt1, opt2) {
// A queue for holding all requests from renderer process.
var requestsQueue = []
ipcMain.on('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function (event, captureWindow, captureScreen, thumbnailSize, id) {
ipcMain.on('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', function (event, captureWindow, captureScreen, thumbnailSize, id) {
var request
request = {
id: id,
@ -51,7 +51,7 @@ desktopCapturer.emit = function (event, name, sources) {
return results
})()
if ((ref = handledRequest.webContents) != null) {
ref.send('ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_' + handledRequest.id, result)
ref.send('ELECTRON_RENDERER_DESKTOP_CAPTURER_RESULT_' + handledRequest.id, result)
}
// Check the queue to see whether there is other same request. If has, handle
@ -61,7 +61,7 @@ desktopCapturer.emit = function (event, name, sources) {
request = requestsQueue[i]
if (deepEqual(handledRequest.options, request.options)) {
if ((ref1 = request.webContents) != null) {
ref1.send('ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_' + request.id, result)
ref1.send('ELECTRON_RENDERER_DESKTOP_CAPTURER_RESULT_' + request.id, result)
}
} else {
unhandledRequestsQueue.push(request)

View file

@ -137,7 +137,7 @@ var createGuest = function (embedder, params) {
// Dispatch events to embedder.
fn = function (event) {
return guest.on(event, function (_, ...args) {
return embedder.send.apply(embedder, ['ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args))
})
}
for (j = 0, len1 = supportedWebViewEvents.length; j < len1; j++) {
@ -147,12 +147,12 @@ var createGuest = function (embedder, params) {
// Dispatch guest's IPC messages to embedder.
guest.on('ipc-message-host', function (_, [channel, ...args]) {
return embedder.send.apply(embedder, ['ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + guest.viewInstanceId, channel].concat(args))
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + guest.viewInstanceId, channel].concat(args))
})
// Autosize.
guest.on('size-changed', function (_, ...args) {
return embedder.send.apply(embedder, ['ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
return embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
})
return id
}
@ -204,19 +204,19 @@ var destroyGuest = function (embedder, id) {
}
}
ipcMain.on('ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', function (event, params, requestId) {
return event.sender.send('ATOM_SHELL_RESPONSE_' + requestId, createGuest(event.sender, params))
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', function (event, params, requestId) {
return event.sender.send('ELECTRON_RESPONSE_' + requestId, createGuest(event.sender, params))
})
ipcMain.on('ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', function (event, elementInstanceId, guestInstanceId, params) {
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_ATTACH_GUEST', function (event, elementInstanceId, guestInstanceId, params) {
return attachGuest(event.sender, elementInstanceId, guestInstanceId, params)
})
ipcMain.on('ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, id) {
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, id) {
return destroyGuest(event.sender, id)
})
ipcMain.on('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', function (event, id, params) {
ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', function (event, id, params) {
var ref1
return (ref1 = guestInstances[id]) != null ? ref1.guest.setSize(params) : void 0
})

View file

@ -70,7 +70,7 @@ var createGuest = function (embedder, url, frameName, options) {
return guest.destroy()
}
closedByUser = function () {
embedder.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + guestId)
embedder.send('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + guestId)
return embedder.removeListener('render-view-deleted', closedByEmbedder)
}
embedder.once('render-view-deleted', closedByEmbedder)
@ -86,7 +86,7 @@ var createGuest = function (embedder, url, frameName, options) {
}
// Routed window.open messages.
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, disposition, options) {
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, disposition, options) {
options = mergeBrowserWindowOptions(event.sender, options)
event.sender.emit('new-window', event, url, frameName, disposition, options)
if ((event.sender.isGuest() && !event.sender.allowPopups) || event.defaultPrevented) {
@ -96,17 +96,17 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url,
}
})
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestId) {
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', function (event, guestId) {
var ref1
return (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1.destroy() : void 0
})
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guestId, method, ...args) {
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', function (event, guestId, method, ...args) {
var ref1
event.returnValue = (ref1 = BrowserWindow.fromId(guestId)) != null ? ref1[method].apply(ref1, args) : void 0
})
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event, guestId, message, targetOrigin, sourceOrigin) {
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event, guestId, message, targetOrigin, sourceOrigin) {
var guestContents, ref1, ref2, sourceId
sourceId = (ref1 = BrowserWindow.fromWebContents(event.sender)) != null ? ref1.id : void 0
if (sourceId == null) {
@ -114,11 +114,11 @@ ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', function (event
}
guestContents = (ref2 = BrowserWindow.fromId(guestId)) != null ? ref2.webContents : void 0
if ((guestContents != null ? guestContents.getURL().indexOf(targetOrigin) : void 0) === 0 || targetOrigin === '*') {
return guestContents != null ? guestContents.send('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin) : void 0
return guestContents != null ? guestContents.send('ELECTRON_GUEST_WINDOW_POSTMESSAGE', sourceId, message, sourceOrigin) : void 0
}
})
ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) {
ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', function (event, guestId, method, ...args) {
var ref1, ref2
return (ref1 = BrowserWindow.fromId(guestId)) != null ? (ref2 = ref1.webContents) != null ? ref2[method].apply(ref2, args) : void 0 : void 0
})

View file

@ -193,14 +193,14 @@ var unwrapArgs = function (sender, args) {
let callIntoRenderer = function (...args) {
if ((webContentsId in rendererFunctions) && !sender.isDestroyed()) {
sender.send('ATOM_RENDERER_CALLBACK', meta.id, valueToMeta(sender, args))
sender.send('ELECTRON_RENDERER_CALLBACK', meta.id, valueToMeta(sender, args))
} else {
throw new Error(`Attempting to call a function in a renderer window that has been closed or released. Function provided here: ${meta.location}.`)
}
}
v8Util.setDestructor(callIntoRenderer, function () {
if ((webContentsId in rendererFunctions) && !sender.isDestroyed()) {
sender.send('ATOM_RENDERER_RELEASE_CALLBACK', meta.id)
sender.send('ELECTRON_RENDERER_RELEASE_CALLBACK', meta.id)
}
})
callbacks.set(meta.id, callIntoRenderer)
@ -238,7 +238,7 @@ var callFunction = function (event, func, caller, args) {
}
}
ipcMain.on('ATOM_BROWSER_REQUIRE', function (event, module) {
ipcMain.on('ELECTRON_BROWSER_REQUIRE', function (event, module) {
try {
event.returnValue = valueToMeta(event.sender, process.mainModule.require(module))
} catch (error) {
@ -246,7 +246,7 @@ ipcMain.on('ATOM_BROWSER_REQUIRE', function (event, module) {
}
})
ipcMain.on('ATOM_BROWSER_GET_BUILTIN', function (event, module) {
ipcMain.on('ELECTRON_BROWSER_GET_BUILTIN', function (event, module) {
try {
event.returnValue = valueToMeta(event.sender, electron[module])
} catch (error) {
@ -254,7 +254,7 @@ ipcMain.on('ATOM_BROWSER_GET_BUILTIN', function (event, module) {
}
})
ipcMain.on('ATOM_BROWSER_GLOBAL', function (event, name) {
ipcMain.on('ELECTRON_BROWSER_GLOBAL', function (event, name) {
try {
event.returnValue = valueToMeta(event.sender, global[name])
} catch (error) {
@ -262,7 +262,7 @@ ipcMain.on('ATOM_BROWSER_GLOBAL', function (event, name) {
}
})
ipcMain.on('ATOM_BROWSER_CURRENT_WINDOW', function (event) {
ipcMain.on('ELECTRON_BROWSER_CURRENT_WINDOW', function (event) {
try {
event.returnValue = valueToMeta(event.sender, event.sender.getOwnerBrowserWindow())
} catch (error) {
@ -270,11 +270,11 @@ ipcMain.on('ATOM_BROWSER_CURRENT_WINDOW', function (event) {
}
})
ipcMain.on('ATOM_BROWSER_CURRENT_WEB_CONTENTS', function (event) {
ipcMain.on('ELECTRON_BROWSER_CURRENT_WEB_CONTENTS', function (event) {
event.returnValue = valueToMeta(event.sender, event.sender)
})
ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function (event, id, args) {
ipcMain.on('ELECTRON_BROWSER_CONSTRUCTOR', function (event, id, args) {
try {
args = unwrapArgs(event.sender, args)
let constructor = objectsRegistry.get(id)
@ -288,7 +288,7 @@ ipcMain.on('ATOM_BROWSER_CONSTRUCTOR', function (event, id, args) {
}
})
ipcMain.on('ATOM_BROWSER_FUNCTION_CALL', function (event, id, args) {
ipcMain.on('ELECTRON_BROWSER_FUNCTION_CALL', function (event, id, args) {
try {
args = unwrapArgs(event.sender, args)
let func = objectsRegistry.get(id)
@ -298,7 +298,7 @@ ipcMain.on('ATOM_BROWSER_FUNCTION_CALL', function (event, id, args) {
}
})
ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function (event, id, method, args) {
ipcMain.on('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', function (event, id, method, args) {
try {
args = unwrapArgs(event.sender, args)
let constructor = objectsRegistry.get(id)[method]
@ -311,7 +311,7 @@ ipcMain.on('ATOM_BROWSER_MEMBER_CONSTRUCTOR', function (event, id, method, args)
}
})
ipcMain.on('ATOM_BROWSER_MEMBER_CALL', function (event, id, method, args) {
ipcMain.on('ELECTRON_BROWSER_MEMBER_CALL', function (event, id, method, args) {
try {
args = unwrapArgs(event.sender, args)
let obj = objectsRegistry.get(id)
@ -321,7 +321,7 @@ ipcMain.on('ATOM_BROWSER_MEMBER_CALL', function (event, id, method, args) {
}
})
ipcMain.on('ATOM_BROWSER_MEMBER_SET', function (event, id, name, value) {
ipcMain.on('ELECTRON_BROWSER_MEMBER_SET', function (event, id, name, value) {
try {
let obj = objectsRegistry.get(id)
obj[name] = value
@ -331,7 +331,7 @@ ipcMain.on('ATOM_BROWSER_MEMBER_SET', function (event, id, name, value) {
}
})
ipcMain.on('ATOM_BROWSER_MEMBER_GET', function (event, id, name) {
ipcMain.on('ELECTRON_BROWSER_MEMBER_GET', function (event, id, name) {
try {
let obj = objectsRegistry.get(id)
event.returnValue = valueToMeta(event.sender, obj[name])
@ -340,11 +340,11 @@ ipcMain.on('ATOM_BROWSER_MEMBER_GET', function (event, id, name) {
}
})
ipcMain.on('ATOM_BROWSER_DEREFERENCE', function (event, id) {
ipcMain.on('ELECTRON_BROWSER_DEREFERENCE', function (event, id) {
return objectsRegistry.remove(event.sender.getId(), id)
})
ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId) {
ipcMain.on('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId) {
try {
let guestViewManager = require('./guest-view-manager')
event.returnValue = valueToMeta(event.sender, guestViewManager.getGuest(guestInstanceId))
@ -353,13 +353,13 @@ ipcMain.on('ATOM_BROWSER_GUEST_WEB_CONTENTS', function (event, guestInstanceId)
}
})
ipcMain.on('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, requestId, guestInstanceId, method, ...args) {
ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, requestId, guestInstanceId, method, ...args) {
try {
let guestViewManager = require('./guest-view-manager')
let guest = guestViewManager.getGuest(guestInstanceId)
if (requestId) {
const responseCallback = function (result) {
event.sender.send(`ATOM_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, result)
event.sender.send(`ELECTRON_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, result)
}
args.push(responseCallback)
}

View file

@ -1,10 +1,10 @@
;(function () {
return function (process, require, asarSource) {
// Make asar.coffee accessible via "require".
process.binding('natives').ATOM_SHELL_ASAR = asarSource
process.binding('natives').ELECTRON_ASAR = asarSource
// Monkey-patch the fs module.
require('ATOM_SHELL_ASAR').wrapFsWithAsar(require('fs'))
require('ELECTRON_ASAR').wrapFsWithAsar(require('fs'))
// Make graceful-fs work with asar.
var source = process.binding('natives')
@ -13,7 +13,7 @@
var nativeModule = new process.NativeModule('original-fs')
nativeModule.cache()
nativeModule.compile()
var asar = require('ATOM_SHELL_ASAR')
var asar = require('ELECTRON_ASAR')
asar.wrapFsWithAsar(nativeModule.exports)
module.exports = nativeModule.exports`
}

View file

@ -27,8 +27,8 @@ exports.getSources = function (options, callback) {
}
}
id = getNextId()
ipcRenderer.send('ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', captureWindow, captureScreen, options.thumbnailSize, id)
return ipcRenderer.once('ATOM_RENDERER_DESKTOP_CAPTURER_RESULT_' + id, function (event, sources) {
ipcRenderer.send('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', captureWindow, captureScreen, options.thumbnailSize, id)
return ipcRenderer.once('ELECTRON_RENDERER_DESKTOP_CAPTURER_RESULT_' + id, function (event, sources) {
var source
return callback(null, (function () {
var i, len, results

View file

@ -102,11 +102,11 @@ let setObjectMembers = function (ref, object, metaId, members) {
let remoteMemberFunction = function () {
if (this && this.constructor === remoteMemberFunction) {
// Constructor call.
let ret = ipcRenderer.sendSync('ATOM_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(arguments))
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CONSTRUCTOR', metaId, member.name, wrapArgs(arguments))
return metaToValue(ret)
} else {
// Call member function.
let ret = ipcRenderer.sendSync('ATOM_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(arguments))
let ret = ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_CALL', metaId, member.name, wrapArgs(arguments))
return metaToValue(ret)
}
}
@ -122,13 +122,13 @@ let setObjectMembers = function (ref, object, metaId, members) {
descriptor.configurable = true
} else if (member.type === 'get') {
descriptor.get = function () {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_MEMBER_GET', metaId, member.name))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_GET', metaId, member.name))
}
// Only set setter when it is writable.
if (member.writable) {
descriptor.set = function (value) {
ipcRenderer.sendSync('ATOM_BROWSER_MEMBER_SET', metaId, member.name, value)
ipcRenderer.sendSync('ELECTRON_BROWSER_MEMBER_SET', metaId, member.name, value)
return value
}
}
@ -182,14 +182,14 @@ let metaToValue = function (meta) {
let remoteFunction = function () {
if (this && this.constructor === remoteFunction) {
// Constructor call.
let obj = ipcRenderer.sendSync('ATOM_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments))
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_CONSTRUCTOR', meta.id, wrapArgs(arguments))
// Returning object in constructor will replace constructed object
// with the returned object.
// http://stackoverflow.com/questions/1978049/what-values-can-a-constructor-return-to-avoid-returning-this
return metaToValue(obj)
} else {
// Function call.
let obj = ipcRenderer.sendSync('ATOM_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments))
let obj = ipcRenderer.sendSync('ELECTRON_BROWSER_FUNCTION_CALL', meta.id, wrapArgs(arguments))
return metaToValue(obj)
}
}
@ -209,7 +209,7 @@ let metaToValue = function (meta) {
// Track delegate object's life time, and tell the browser to clean up
// when the object is GCed.
v8Util.setDestructor(ret, function () {
ipcRenderer.send('ATOM_BROWSER_DEREFERENCE', meta.id)
ipcRenderer.send('ELECTRON_BROWSER_DEREFERENCE', meta.id)
})
// Remember object's id.
@ -239,12 +239,12 @@ var metaToPlainObject = function (meta) {
}
// Browser calls a callback in renderer.
ipcRenderer.on('ATOM_RENDERER_CALLBACK', function (event, id, args) {
ipcRenderer.on('ELECTRON_RENDERER_CALLBACK', function (event, id, args) {
return callbacksRegistry.apply(id, metaToValue(args))
})
// A callback in browser is released.
ipcRenderer.on('ATOM_RENDERER_RELEASE_CALLBACK', function (event, id) {
ipcRenderer.on('ELECTRON_RENDERER_RELEASE_CALLBACK', function (event, id) {
return callbacksRegistry.remove(id)
})
@ -265,27 +265,27 @@ for (var name in browserModules) {
// Get remote module.
exports.require = function (module) {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_REQUIRE', module))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_REQUIRE', module))
}
// Alias to remote.require('electron').xxx.
exports.getBuiltin = function (module) {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_GET_BUILTIN', module))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GET_BUILTIN', module))
}
// Get current BrowserWindow.
exports.getCurrentWindow = function () {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_CURRENT_WINDOW'))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_CURRENT_WINDOW'))
}
// Get current WebContents object.
exports.getCurrentWebContents = function () {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_CURRENT_WEB_CONTENTS'))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_CURRENT_WEB_CONTENTS'))
}
// Get a global object in browser.
exports.getGlobal = function (name) {
return metaToValue(ipcRenderer.sendSync('ATOM_BROWSER_GLOBAL', name))
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_GLOBAL', name))
}
// Get the process object in browser.
@ -306,6 +306,6 @@ exports.createFunctionWithReturnValue = function (returnValue) {
// Get the guest WebContents from guestInstanceId.
exports.getGuestWebContents = function (guestInstanceId) {
var meta
meta = ipcRenderer.sendSync('ATOM_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId)
meta = ipcRenderer.sendSync('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', guestInstanceId)
return metaToValue(meta)
}

View file

@ -38,30 +38,30 @@ var BrowserWindowProxy = (function () {
function BrowserWindowProxy (guestId1) {
this.guestId = guestId1
this.closed = false
ipcRenderer.once('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + this.guestId, () => {
ipcRenderer.once('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + this.guestId, () => {
BrowserWindowProxy.remove(this.guestId)
this.closed = true
})
}
BrowserWindowProxy.prototype.close = function () {
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', this.guestId)
return ipcRenderer.send('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', this.guestId)
}
BrowserWindowProxy.prototype.focus = function () {
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'focus')
return ipcRenderer.send('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'focus')
}
BrowserWindowProxy.prototype.blur = function () {
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'blur')
return ipcRenderer.send('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'blur')
}
Object.defineProperty(BrowserWindowProxy.prototype, 'location', {
get: function () {
return ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'getURL')
return ipcRenderer.sendSync('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'getURL')
},
set: function (url) {
return ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'loadURL', url)
return ipcRenderer.sendSync('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_METHOD', this.guestId, 'loadURL', url)
}
})
@ -69,11 +69,11 @@ var BrowserWindowProxy = (function () {
if (targetOrigin == null) {
targetOrigin = '*'
}
return ipcRenderer.send('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', this.guestId, message, targetOrigin, window.location.origin)
return ipcRenderer.send('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', this.guestId, message, targetOrigin, window.location.origin)
}
BrowserWindowProxy.prototype['eval'] = function (...args) {
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(args))
return ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', this.guestId, 'executeJavaScript'].concat(args))
}
return BrowserWindowProxy
@ -147,7 +147,7 @@ window.open = function (url, frameName, features) {
options[name] = parseInt(options[name], 10)
}
}
guestId = ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, disposition, options)
guestId = ipcRenderer.sendSync('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, disposition, options)
if (guestId) {
return BrowserWindowProxy.getOrCreate(guestId)
} else {
@ -200,7 +200,7 @@ if (process.openerId != null) {
window.opener = BrowserWindowProxy.getOrCreate(process.openerId)
}
ipcRenderer.on('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, isVisible, isMinimized) {
ipcRenderer.on('ELECTRON_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, isVisible, isMinimized) {
var hasChanged = _isVisible !== isVisible || _isMinimized !== isMinimized
if (hasChanged) {
@ -211,7 +211,7 @@ ipcRenderer.on('ATOM_RENDERER_WINDOW_VISIBILITY_CHANGE', function (event, isVisi
}
})
ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function (event, sourceId, message, sourceOrigin) {
ipcRenderer.on('ELECTRON_GUEST_WINDOW_POSTMESSAGE', function (event, sourceId, message, sourceOrigin) {
// Manually dispatch event instead of using postMessage because we also need to
// set event.source.
event = document.createEvent('Event')
@ -224,11 +224,11 @@ ipcRenderer.on('ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', function (event, sourceId,
// Forward history operations to browser.
var sendHistoryOperation = function (...args) {
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_SHELL_NAVIGATION_CONTROLLER'].concat(args))
return ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_NAVIGATION_CONTROLLER'].concat(args))
}
var getHistoryOperation = function (...args) {
return ipcRenderer.sendSync.apply(ipcRenderer, ['ATOM_SHELL_SYNC_NAVIGATION_CONTROLLER'].concat(args))
return ipcRenderer.sendSync.apply(ipcRenderer, ['ELECTRON_SYNC_NAVIGATION_CONTROLLER'].concat(args))
}
window.history.back = function () {

View file

@ -12,7 +12,7 @@ var WEB_VIEW_EVENTS = {
'did-frame-finish-load': ['isMainFrame'],
'did-start-loading': [],
'did-stop-loading': [],
'did-get-response-details': ['status', 'newURL', 'originalURL', 'httpResponseCode', 'requestMethod', 'referrer', 'headers'],
'did-get-response-details': ['status', 'newURL', 'originalURL', 'httpResponseCode', 'requestMethod', 'referrer', 'headers', 'resourceType'],
'did-get-redirect-request': ['oldURL', 'newURL', 'isMainFrame'],
'dom-ready': [],
'console-message': ['level', 'message', 'line', 'sourceId'],
@ -61,18 +61,18 @@ var dispatchEvent = function (webView, eventName, eventKey, ...args) {
module.exports = {
registerEvents: function (webView, viewInstanceId) {
ipcRenderer.on('ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId, function (event, eventName, ...args) {
ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId, function (event, eventName, ...args) {
return dispatchEvent.apply(null, [webView, eventName, eventName].concat(args))
})
ipcRenderer.on('ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId, function (event, channel, ...args) {
ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId, function (event, channel, ...args) {
var domEvent = new Event('ipc-message')
domEvent.channel = channel
domEvent.args = args
return webView.dispatchEvent(domEvent)
})
return ipcRenderer.on('ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId, function (event, ...args) {
return ipcRenderer.on('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId, function (event, ...args) {
var domEvent, f, i, j, len, ref1
domEvent = new Event('size-changed')
ref1 = ['oldWidth', 'oldHeight', 'newWidth', 'newHeight']
@ -84,23 +84,23 @@ module.exports = {
})
},
deregisterEvents: function (viewInstanceId) {
ipcRenderer.removeAllListeners('ATOM_SHELL_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId)
ipcRenderer.removeAllListeners('ATOM_SHELL_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId)
return ipcRenderer.removeAllListeners('ATOM_SHELL_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId)
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + viewInstanceId)
ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + viewInstanceId)
return ipcRenderer.removeAllListeners('ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + viewInstanceId)
},
createGuest: function (params, callback) {
requestId++
ipcRenderer.send('ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId)
return ipcRenderer.once('ATOM_SHELL_RESPONSE_' + requestId, callback)
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', params, requestId)
return ipcRenderer.once('ELECTRON_RESPONSE_' + requestId, callback)
},
attachGuest: function (elementInstanceId, guestInstanceId, params) {
ipcRenderer.send('ATOM_SHELL_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params)
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_ATTACH_GUEST', elementInstanceId, guestInstanceId, params)
return webFrame.attachGuest(elementInstanceId)
},
destroyGuest: function (guestInstanceId) {
return ipcRenderer.send('ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId)
return ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', guestInstanceId)
},
setSize: function (guestInstanceId, params) {
return ipcRenderer.send('ATOM_SHELL_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params)
return ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', guestInstanceId, params)
}
}

View file

@ -404,7 +404,7 @@ var registerWebViewElement = function () {
createNonBlockHandler = function (m) {
return function (...args) {
const internal = v8Util.getHiddenValue(this, 'internal')
return ipcRenderer.send.apply(ipcRenderer, ['ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
return ipcRenderer.send.apply(ipcRenderer, ['ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', null, internal.guestInstanceId, m].concat(args))
}
}
for (j = 0, len1 = nonblockMethods.length; j < len1; j++) {
@ -419,8 +419,8 @@ var registerWebViewElement = function () {
hasUserGesture = false
}
let requestId = getNextId()
ipcRenderer.send('ATOM_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', requestId, internal.guestInstanceId, 'executeJavaScript', code, hasUserGesture)
ipcRenderer.once(`ATOM_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, function (event, result) {
ipcRenderer.send('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', requestId, internal.guestInstanceId, 'executeJavaScript', code, hasUserGesture)
ipcRenderer.once(`ELECTRON_RENDERER_ASYNC_CALL_TO_GUEST_VIEW_RESPONSE_${requestId}`, function (event, result) {
if (callback) callback(result)
})
}

View file

@ -2,7 +2,7 @@
"name": "electron",
"version": "0.37.5",
"devDependencies": {
"asar": "^0.10.0",
"asar": "^0.11.0",
"request": "*",
"standard": "^6.0.8"
},

View file

@ -32,6 +32,9 @@ LINUX_DEPS_ARM = [
def main():
os.environ['CI'] = '1'
if os.environ.has_key('JANKY_SHA1'):
setup_nodenv()
target_arch = 'x64'
if os.environ.has_key('TARGET_ARCH'):
target_arch = os.environ['TARGET_ARCH']
@ -56,6 +59,8 @@ def main():
npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
execute([npm, 'install', 'npm@2.12.1'])
log_versions()
is_release = os.environ.has_key('ELECTRON_RELEASE')
args = ['--target_arch=' + target_arch]
if not is_release:
@ -86,5 +91,23 @@ def run_script(script, args=[]):
subprocess.check_call([sys.executable, script] + args)
def log_versions():
sys.stderr.write('\nnode --version\n')
sys.stderr.flush()
subprocess.call(['node', '--version'])
sys.stderr.write('\nnpm --version\n')
sys.stderr.flush()
npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm'
subprocess.call([npm, '--version'])
def setup_nodenv():
if os.path.isdir('/usr/local/share/nodenv'):
os.environ['NODENV_ROOT'] = '/usr/local/share/nodenv'
os.environ['PATH'] = '/usr/local/share/nodenv/bin:/usr/local/share/nodenv/shims:' + os.environ['PATH']
os.environ['NODENV_VERSION'] = 'v0.10.21'
if __name__ == '__main__':
sys.exit(main())

View file

@ -8,7 +8,7 @@ import sys
BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \
'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent'
LIBCHROMIUMCONTENT_COMMIT = '9229f39b44ca1dde25db9c648547861286b61935'
LIBCHROMIUMCONTENT_COMMIT = '4e506867ad95907e0a9cbec4ab3ee0f84214de94'
PLATFORM = {
'cygwin': 'win32',

View file

@ -101,6 +101,32 @@ describe('browser-window module', function () {
w.loadURL('about:blank')
})
it('should emit did-get-response-details event', function (done) {
// expected {fileName: resourceType} pairs
var expectedResources = {
'did-get-response-details.html': 'mainFrame',
'logo.png': 'image'
}
var responses = 0;
w.webContents.on('did-get-response-details', function (event, status, newUrl, oldUrl, responseCode, method, referrer, headers, resourceType) {
responses++
var fileName = newUrl.slice(newUrl.lastIndexOf('/') + 1)
var expectedType = expectedResources[fileName]
assert(!!expectedType, `Unexpected response details for ${newUrl}`)
assert(typeof status === 'boolean', 'status should be boolean')
assert.equal(responseCode, 200)
assert.equal(method, 'GET')
assert(typeof referrer === 'string', 'referrer should be string')
assert(!!headers, 'headers should be present')
assert(typeof headers === 'object', 'headers should be object')
assert.equal(resourceType, expectedType, 'Incorrect resourceType')
if (responses === Object.keys(expectedResources).length) {
done()
}
})
w.loadURL('file://' + path.join(fixtures, 'pages', 'did-get-response-details.html'))
})
it('should emit did-fail-load event for files that do not exist', function (done) {
w.webContents.on('did-fail-load', function (event, code, desc, url, isMainFrame) {
assert.equal(code, -6)

View file

@ -7,12 +7,18 @@ const session = remote.session
describe('webRequest module', function () {
var ses = session.defaultSession
var server = http.createServer(function (req, res) {
res.setHeader('Custom', ['Header'])
var content = req.url
if (req.headers.accept === '*/*;test/header') {
content += 'header/received'
if (req.url == '/serverRedirect') {
res.statusCode = 301
res.setHeader('Location', 'http://' + req.rawHeaders[1])
res.end()
} else {
res.setHeader('Custom', ['Header'])
var content = req.url
if (req.headers.accept === '*/*;test/header') {
content += 'header/received'
}
res.end(content)
}
res.end(content)
})
var defaultURL = null
@ -297,6 +303,44 @@ describe('webRequest module', function () {
}
})
})
it('follows server redirect', function (done) {
ses.webRequest.onHeadersReceived(function (details, callback) {
var responseHeaders = details.responseHeaders
callback({
responseHeaders: responseHeaders,
})
})
$.ajax({
url: defaultURL + 'serverRedirect',
success: function (data, status, xhr) {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
done()
},
error: function (xhr, errorType) {
done(errorType)
}
})
})
it('can change the header status', function (done) {
ses.webRequest.onHeadersReceived(function (details, callback) {
var responseHeaders = details.responseHeaders
callback({
responseHeaders: responseHeaders,
statusLine: "HTTP/1.1 404 Not Found"
})
})
$.ajax({
url: defaultURL,
success: function (data, status, xhr) {
},
error: function (xhr, errorType) {
assert.equal(xhr.getResponseHeader('Custom'), 'Header')
done()
}
})
})
})
describe('webRequest.onResponseStarted', function () {

View file

@ -0,0 +1,5 @@
<html>
<body>
<img src="../assets/logo.png" />
</body>
</html>

7
spec/fixtures/pages/ping.html vendored Normal file
View file

@ -0,0 +1,7 @@
<html>
<body>
<script type="text/javascript" charset="utf-8">
require('electron').ipcRenderer.send('pong')
</script>
</body>
</html>

View file

@ -0,0 +1,5 @@
<html>
<body>
<webview nodeintegration src="ping.html"/>
</body>
</html>

View file

@ -83,7 +83,7 @@ app.on('ready', function () {
width: 800,
height: 600,
webPreferences: {
javascript: true // Test whether web preferences crashes.
backgroundThrottling: false,
}
})
window.loadURL(url.format({

View file

@ -2,7 +2,7 @@ const assert = require('assert')
const path = require('path')
const http = require('http')
const url = require('url')
const {app, session} = require('electron').remote
const {app, session, ipcMain, BrowserWindow} = require('electron').remote
describe('<webview> tag', function () {
this.timeout(10000)
@ -20,6 +20,15 @@ describe('<webview> tag', function () {
}
})
it('works without script tag in page', function (done) {
let w = new BrowserWindow({show: false})
ipcMain.once('pong', function () {
w.destroy()
done()
})
w.loadURL('file://' + fixtures + '/pages/webview-no-script.html')
})
describe('src attribute', function () {
it('specifies the page to load', function (done) {
webview.addEventListener('console-message', function (e) {
@ -155,6 +164,18 @@ describe('<webview> tag', function () {
webview.src = 'file://' + fixtures + '/pages/e.html'
document.body.appendChild(webview)
})
it('works without script tag in page', function (done) {
var listener = function (e) {
assert.equal(e.message, 'function object object')
webview.removeEventListener('console-message', listener)
done()
}
webview.addEventListener('console-message', listener)
webview.setAttribute('preload', fixtures + '/module/preload.js')
webview.src = 'file://' + fixtures + '/pages/base-page.html'
document.body.appendChild(webview)
})
})
describe('httpreferrer attribute', function () {
@ -763,4 +784,33 @@ describe('<webview> tag', function () {
document.body.appendChild(webview)
})
})
describe('did-get-response-details event', function () {
it('emits for the page and its resources', function (done) {
// expected {fileName: resourceType} pairs
var expectedResources = {
'did-get-response-details.html': 'mainFrame',
'logo.png': 'image'
}
var responses = 0;
webview.addEventListener('did-get-response-details', function (event) {
responses++
var fileName = event.newURL.slice(event.newURL.lastIndexOf('/') + 1)
var expectedType = expectedResources[fileName]
assert(!!expectedType, `Unexpected response details for ${event.newURL}`)
assert(typeof event.status === 'boolean', 'status should be boolean')
assert.equal(event.httpResponseCode, 200)
assert.equal(event.requestMethod, 'GET')
assert(typeof event.referrer === 'string', 'referrer should be string')
assert(!!event.headers, 'headers should be present')
assert(typeof event.headers === 'object', 'headers should be object')
assert.equal(event.resourceType, expectedType, 'Incorrect resourceType')
if (responses === Object.keys(expectedResources).length) {
done()
}
})
webview.src = 'file://' + path.join(fixtures, 'pages', 'did-get-response-details.html')
document.body.appendChild(webview)
})
})
})

2
vendor/brightray vendored

@ -1 +1 @@
Subproject commit 242feb1c817565de6592e9e672c136635bfff453
Subproject commit cedb11316627ac0e01a5dcd38e75bd1c5a6afa17