From 855d49100f88afe823fea20fda72e33e71fa95ba Mon Sep 17 00:00:00 2001 From: Robo Date: Wed, 9 Dec 2015 00:51:46 +0530 Subject: [PATCH 01/25] protocol: api to register schemes that can handle service worker --- atom/app/atom_content_client.cc | 34 +++++++++++++++---- atom/app/atom_content_client.h | 3 ++ atom/browser/api/atom_api_protocol.cc | 7 ++++ atom/browser/api/atom_api_protocol.h | 3 ++ atom/browser/atom_browser_client.cc | 12 +++++++ atom/browser/atom_browser_client.h | 3 ++ atom/browser/net/asar/url_request_asar_job.cc | 18 ++++++++-- atom/browser/net/asar/url_request_asar_job.h | 2 ++ atom/common/options_switches.cc | 3 ++ atom/common/options_switches.h | 1 + atom/renderer/atom_renderer_client.cc | 4 +++ docs/api/protocol.md | 4 +++ 12 files changed, 86 insertions(+), 8 deletions(-) diff --git a/atom/app/atom_content_client.cc b/atom/app/atom_content_client.cc index 9f161ac569a6..7a1241f2bcc4 100644 --- a/atom/app/atom_content_client.cc +++ b/atom/app/atom_content_client.cc @@ -17,6 +17,7 @@ #include "content/public/common/pepper_plugin_info.h" #include "content/public/common/user_agent.h" #include "ppapi/shared_impl/ppapi_permissions.h" +#include "url/url_constants.h" namespace atom { @@ -62,6 +63,17 @@ content::PepperPluginInfo CreatePepperFlashInfo(const base::FilePath& path, return plugin; } +void ConvertStringWithSeparatorToVector(std::vector* vec, + const char* separator, + const char* cmd_switch) { + auto command_line = base::CommandLine::ForCurrentProcess(); + auto string_with_separator = command_line->GetSwitchValueASCII(cmd_switch); + if (!string_with_separator.empty()) + *vec = base::SplitString(string_with_separator, separator, + base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY); +} + } // namespace AtomContentClient::AtomContentClient() { @@ -83,12 +95,10 @@ std::string AtomContentClient::GetUserAgent() const { void AtomContentClient::AddAdditionalSchemes( std::vector* standard_schemes, std::vector* savable_schemes) { - auto command_line = base::CommandLine::ForCurrentProcess(); - auto custom_schemes = command_line->GetSwitchValueASCII( - switches::kRegisterStandardSchemes); - if (!custom_schemes.empty()) { - std::vector schemes = base::SplitString( - custom_schemes, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); + std::vector schemes; + ConvertStringWithSeparatorToVector(&schemes, ",", + switches::kRegisterStandardSchemes); + if (!schemes.empty()) { for (const std::string& scheme : schemes) standard_schemes->push_back({scheme.c_str(), url::SCHEME_WITHOUT_PORT}); } @@ -110,4 +120,16 @@ void AtomContentClient::AddPepperPlugins( CreatePepperFlashInfo(flash_path, flash_version)); } +void AtomContentClient::AddServiceWorkerSchemes( + std::set* service_worker_schemes) { + std::vector schemes; + ConvertStringWithSeparatorToVector(&schemes, ",", + switches::kRegisterServiceWorkerSchemes); + if (!schemes.empty()) { + for (const std::string& scheme : schemes) + service_worker_schemes->insert(scheme); + } + service_worker_schemes->insert(url::kFileScheme); +} + } // namespace atom diff --git a/atom/app/atom_content_client.h b/atom/app/atom_content_client.h index 2716b1eea400..76ac37642a71 100644 --- a/atom/app/atom_content_client.h +++ b/atom/app/atom_content_client.h @@ -5,6 +5,7 @@ #ifndef ATOM_APP_ATOM_CONTENT_CLIENT_H_ #define ATOM_APP_ATOM_CONTENT_CLIENT_H_ +#include #include #include @@ -26,6 +27,8 @@ class AtomContentClient : public brightray::ContentClient { std::vector* savable_schemes) override; void AddPepperPlugins( std::vector* plugins) override; + void AddServiceWorkerSchemes( + std::set* service_worker_schemes) override; private: DISALLOW_COPY_AND_ASSIGN(AtomContentClient); diff --git a/atom/browser/api/atom_api_protocol.cc b/atom/browser/api/atom_api_protocol.cc index b1ad7981377a..09da9c71cadb 100644 --- a/atom/browser/api/atom_api_protocol.cc +++ b/atom/browser/api/atom_api_protocol.cc @@ -32,6 +32,8 @@ mate::ObjectTemplateBuilder Protocol::GetObjectTemplateBuilder( v8::Isolate* isolate) { return mate::ObjectTemplateBuilder(isolate) .SetMethod("registerStandardSchemes", &Protocol::RegisterStandardSchemes) + .SetMethod("registerServiceWorkerSchemes", + &Protocol::RegisterServiceWorkerSchemes) .SetMethod("registerStringProtocol", &Protocol::RegisterProtocol) .SetMethod("registerBufferProtocol", @@ -58,6 +60,11 @@ void Protocol::RegisterStandardSchemes( atom::AtomBrowserClient::SetCustomSchemes(schemes); } +void Protocol::RegisterServiceWorkerSchemes( + const std::vector& schemes) { + atom::AtomBrowserClient::SetCustomServiceWorkerSchemes(schemes); +} + void Protocol::UnregisterProtocol( const std::string& scheme, mate::Arguments* args) { CompletionCallback callback; diff --git a/atom/browser/api/atom_api_protocol.h b/atom/browser/api/atom_api_protocol.h index 9f98eb767309..8aef406fbc38 100644 --- a/atom/browser/api/atom_api_protocol.h +++ b/atom/browser/api/atom_api_protocol.h @@ -92,6 +92,9 @@ class Protocol : public mate::Wrappable { // Register schemes to standard scheme list. void RegisterStandardSchemes(const std::vector& schemes); + // Register schemes that can handle service worker. + void RegisterServiceWorkerSchemes(const std::vector& schemes); + // Register the protocol with certain request job. template void RegisterProtocol(const std::string& scheme, diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index b9b186d187d0..1303b91b04d2 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -54,6 +54,8 @@ bool g_suppress_renderer_process_restart = false; // Custom schemes to be registered to standard. std::string g_custom_schemes = ""; +// Custom schemes to be registered to handle service worker. +std::string g_custom_service_worker_schemes = ""; scoped_refptr ImportCertFromFile( const base::FilePath& path) { @@ -87,6 +89,11 @@ void AtomBrowserClient::SetCustomSchemes( g_custom_schemes = base::JoinString(schemes, ","); } +void AtomBrowserClient::SetCustomServiceWorkerSchemes( + const std::vector& schemes) { + g_custom_service_worker_schemes = base::JoinString(schemes, ","); +} + AtomBrowserClient::AtomBrowserClient() : delegate_(nullptr) { } @@ -172,6 +179,11 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( command_line->AppendSwitchASCII(switches::kRegisterStandardSchemes, g_custom_schemes); + // The registered service worker schemes. + if (!g_custom_service_worker_schemes.empty()) + command_line->AppendSwitchASCII(switches::kRegisterServiceWorkerSchemes, + g_custom_service_worker_schemes); + #if defined(OS_WIN) // Append --app-user-model-id. PWSTR current_app_id; diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 75e17494593b..3c54fab40bc1 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -38,6 +38,9 @@ class AtomBrowserClient : public brightray::BrowserClient, static void SuppressRendererProcessRestartForOnce(); // Custom schemes to be registered to standard. static void SetCustomSchemes(const std::vector& schemes); + // Custom schemes to be registered to handle service worker. + static void SetCustomServiceWorkerSchemes( + const std::vector& schemes); protected: // content::ContentBrowserClient: diff --git a/atom/browser/net/asar/url_request_asar_job.cc b/atom/browser/net/asar/url_request_asar_job.cc index 9b9a3c69d27f..d926d1111722 100644 --- a/atom/browser/net/asar/url_request_asar_job.cc +++ b/atom/browser/net/asar/url_request_asar_job.cc @@ -7,13 +7,14 @@ #include #include +#include "atom/common/asar/archive.h" +#include "atom/common/asar/asar_util.h" +#include "atom/common/atom_constants.h" #include "base/bind.h" #include "base/files/file_util.h" #include "base/strings/string_util.h" #include "base/synchronization/lock.h" #include "base/task_runner.h" -#include "atom/common/asar/archive.h" -#include "atom/common/asar/asar_util.h" #include "net/base/file_stream.h" #include "net/base/filename_util.h" #include "net/base/io_buffer.h" @@ -227,6 +228,19 @@ void URLRequestAsarJob::SetExtraRequestHeaders( } } +int URLRequestAsarJob::GetResponseCode() const { + // Request Job gets created only if path exists. + return 200; +} + +void URLRequestAsarJob::GetResponseInfo(net::HttpResponseInfo* info) { + std::string status("HTTP/1.1 200 OK"); + net::HttpResponseHeaders* headers = new net::HttpResponseHeaders(status); + + headers->AddHeader(atom::kCORSHeader); + info->headers = headers; +} + void URLRequestAsarJob::FetchMetaInfo(const base::FilePath& file_path, FileMetaInfo* meta_info) { base::File::Info file_info; diff --git a/atom/browser/net/asar/url_request_asar_job.h b/atom/browser/net/asar/url_request_asar_job.h index 15a723d79e89..29d1afc521d6 100644 --- a/atom/browser/net/asar/url_request_asar_job.h +++ b/atom/browser/net/asar/url_request_asar_job.h @@ -61,6 +61,8 @@ class URLRequestAsarJob : public net::URLRequestJob { net::Filter* SetupFilter() const override; bool GetMimeType(std::string* mime_type) const override; void SetExtraRequestHeaders(const net::HttpRequestHeaders& headers) override; + int GetResponseCode() const override; + void GetResponseInfo(net::HttpResponseInfo* info) override; private: // Meta information about the file. It's used as a member in the diff --git a/atom/common/options_switches.cc b/atom/common/options_switches.cc index a0cb8384a340..0303cf54693e 100644 --- a/atom/common/options_switches.cc +++ b/atom/common/options_switches.cc @@ -119,6 +119,9 @@ const char kDisableHttpCache[] = "disable-http-cache"; // Register schemes to standard. const char kRegisterStandardSchemes[] = "register-standard-schemes"; +// Register schemes to handle service worker. +const char kRegisterServiceWorkerSchemes[] = "register-service-worker-schemes"; + // The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that // TLS fallback will accept. const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min"; diff --git a/atom/common/options_switches.h b/atom/common/options_switches.h index 6960db83bc10..36c2be143146 100644 --- a/atom/common/options_switches.h +++ b/atom/common/options_switches.h @@ -66,6 +66,7 @@ extern const char kPpapiFlashVersion[]; extern const char kClientCertificate[]; extern const char kDisableHttpCache[]; extern const char kRegisterStandardSchemes[]; +extern const char kRegisterServiceWorkerSchemes[]; extern const char kSSLVersionFallbackMin[]; extern const char kCipherSuiteBlacklist[]; extern const char kAppUserModelId[]; diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 7c04c04249a7..e0d40189f204 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -27,6 +27,7 @@ #include "third_party/WebKit/public/web/WebLocalFrame.h" #include "third_party/WebKit/public/web/WebPluginParams.h" #include "third_party/WebKit/public/web/WebKit.h" +#include "third_party/WebKit/public/web/WebSecurityPolicy.h" #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" #include "third_party/WebKit/public/web/WebView.h" @@ -129,6 +130,9 @@ void AtomRendererClient::RenderFrameCreated( content::RenderFrame* render_frame) { new PepperHelper(render_frame); new AtomRenderFrameObserver(render_frame, this); + + // Allow file scheme to handle service worker by default. + blink::WebSecurityPolicy::registerURLSchemeAsAllowingServiceWorkers("file"); } void AtomRendererClient::RenderViewCreated(content::RenderView* render_view) { diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 5f34165fa84a..80597728e650 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -38,6 +38,10 @@ A standard `scheme` adheres to what RFC 3986 calls [generic URI syntax](https://tools.ietf.org/html/rfc3986#section-3). This includes `file:` and `filesystem:`. +### `protocol.registerServiceWorkerSchemes(schemes)` + +* `schemes` Array - Custom schemes to be registered to handle service workers. + ### `protocol.registerFileProtocol(scheme, handler[, completion])` * `scheme` String From d2e63dfc644e323bf23fbd6654f7493ed94d7991 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 9 Dec 2015 18:14:37 +0800 Subject: [PATCH 02/25] Use HTTPS for libchromiumcontent's URL Without using the subdomain we should be able to work around the domain license problem of python. --- script/lib/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/lib/config.py b/script/lib/config.py index c1545e0d27d8..132f5b8d83ec 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -7,7 +7,7 @@ import sys BASE_URL = os.getenv('LIBCHROMIUMCONTENT_MIRROR') or \ - 'http://github-janky-artifacts.s3.amazonaws.com/libchromiumcontent' + 'https://s3.amazonaws.com/github-janky-artifacts/libchromiumcontent' LIBCHROMIUMCONTENT_COMMIT = 'cfbe8ec7e14af4cabd1474386f54e197db1f7ac1' PLATFORM = { From 940289639eeac616c2bfd817b1fd95f2642676c3 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Fri, 4 Dec 2015 20:48:19 -0500 Subject: [PATCH 03/25] protocol: provide upload data when available --- .../native_mate_converters/net_converter.cc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/atom/common/native_mate_converters/net_converter.cc b/atom/common/native_mate_converters/net_converter.cc index 4749a4fedfc2..6089d715e370 100644 --- a/atom/common/native_mate_converters/net_converter.cc +++ b/atom/common/native_mate_converters/net_converter.cc @@ -5,9 +5,14 @@ #include "atom/common/native_mate_converters/net_converter.h" #include +#include #include "atom/common/node_includes.h" #include "native_mate/dictionary.h" +#include "net/base/upload_bytes_element_reader.h" +#include "net/base/upload_data_stream.h" +#include "net/base/upload_element_reader.h" +#include "net/base/upload_file_element_reader.h" #include "net/cert/x509_certificate.h" #include "net/url_request/url_request.h" @@ -20,6 +25,30 @@ v8::Local Converter::ToV8( dict.Set("method", val->method()); dict.Set("url", val->url().spec()); dict.Set("referrer", val->referrer()); + const net::UploadDataStream* upload_data = val->get_upload(); + if (upload_data) { + const ScopedVector* readers = + upload_data->GetElementReaders(); + std::vector upload_data_list; + upload_data_list.reserve(readers->size()); + for (const auto& reader : *readers) { + auto upload_data_dict = mate::Dictionary::CreateEmpty(isolate); + if (reader->AsBytesReader()) { + const net::UploadBytesElementReader* bytes_reader = + reader->AsBytesReader(); + auto bytes = + node::Buffer::Copy(isolate, bytes_reader->bytes(), + bytes_reader->length()).ToLocalChecked(); + upload_data_dict.Set("bytes", bytes); + } else if (reader->AsFileReader()) { + const net::UploadFileElementReader* file_reader = + reader->AsFileReader(); + upload_data_dict.Set("file", file_reader->path().AsUTF8Unsafe()); + } + upload_data_list.push_back(upload_data_dict); + } + dict.Set("uploadData", upload_data_list); + } return mate::ConvertToV8(isolate, dict); } From fbb5091f948279b9a0f19bf9328b5520fabccf92 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sun, 6 Dec 2015 15:27:02 -0500 Subject: [PATCH 04/25] provide option to set content for POST request with url_fetcher --- atom/browser/net/url_request_fetch_job.cc | 10 ++++++++++ docs/api/protocol.md | 7 ++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/atom/browser/net/url_request_fetch_job.cc b/atom/browser/net/url_request_fetch_job.cc index f04ecd4060f0..8ffb6df0122f 100644 --- a/atom/browser/net/url_request_fetch_job.cc +++ b/atom/browser/net/url_request_fetch_job.cc @@ -90,12 +90,14 @@ void URLRequestFetchJob::StartAsync(scoped_ptr options) { std::string url, method, referrer; base::Value* session = nullptr; + base::DictionaryValue* upload_data = nullptr; base::DictionaryValue* dict = static_cast(options.get()); dict->GetString("url", &url); dict->GetString("method", &method); dict->GetString("referrer", &referrer); dict->Get("session", &session); + dict->GetDictionary("uploadData", &upload_data); // Check if URL is valid. GURL formated_url(url); @@ -127,6 +129,14 @@ void URLRequestFetchJob::StartAsync(scoped_ptr options) { else fetcher_->SetReferrer(referrer); + // Set the data needed for POSTs. + if (upload_data && request_type == net::URLFetcher::POST) { + std::string content_type, data; + upload_data->GetString("contentType", &content_type); + upload_data->GetString("data", &data); + fetcher_->SetUploadData(content_type, data); + } + // Use |request|'s headers. fetcher_->SetExtraRequestHeaders( request()->extra_request_headers().ToString()); diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 5f34165fa84a..f76d006a3b5d 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -103,11 +103,16 @@ Registers a protocol of `scheme` that will send a `String` as a response. The Registers a protocol of `scheme` that will send an HTTP request as a response. The `callback` should be called with an object that has the `url`, `method`, -`referrer`, and `session` properties. +`referrer`, `uploadData` and `session` properties. By default the HTTP request will reuse the current session. If you want the request to have a different session you should set `session` to `null`. +POST request should provide an `uploadData` object. +* `uploadData` object + * `contentType` String - MIME type of the content. + * `data` String - Content to be sent. + ### `protocol.unregisterProtocol(scheme[, completion])` * `scheme` String From e80a95dc3768b537f4d3a9b8d977effd14197403 Mon Sep 17 00:00:00 2001 From: Robo Date: Wed, 9 Dec 2015 20:10:34 +0530 Subject: [PATCH 05/25] add test --- spec/api-protocol-spec.coffee | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/spec/api-protocol-spec.coffee b/spec/api-protocol-spec.coffee index 034b9765927c..77eb90259bb2 100644 --- a/spec/api-protocol-spec.coffee +++ b/spec/api-protocol-spec.coffee @@ -1,6 +1,7 @@ assert = require 'assert' http = require 'http' path = require 'path' +qs = require 'querystring' {remote} = require 'electron' {protocol} = remote.require 'electron' @@ -8,6 +9,9 @@ path = require 'path' describe 'protocol module', -> protocolName = 'sp' text = 'valar morghulis' + postData = + name: 'post test' + type: 'string' afterEach (done) -> protocol.unregisterProtocol protocolName, -> @@ -405,6 +409,22 @@ describe 'protocol module', -> error: (xhr, errorType, error) -> done(error) + it 'can receive post data', (done) -> + handler = (request, callback) -> + uploadData = request.uploadData[0].bytes.toString() + callback({data: uploadData}) + protocol.interceptStringProtocol 'http', handler, (error) -> + return done(error) if error + $.ajax + url: "http://fake-host" + type: "POST" + data: postData + success: (data) -> + assert.deepEqual qs.parse(data), postData + done() + error: (xhr, errorType, error) -> + done(error) + describe 'protocol.interceptBufferProtocol', -> it 'can intercept http protocol', (done) -> handler = (request, callback) -> callback(new Buffer(text)) @@ -418,6 +438,55 @@ describe 'protocol module', -> error: (xhr, errorType, error) -> done(error) + it 'can receive post data', (done) -> + handler = (request, callback) -> + uploadData = request.uploadData[0].bytes + callback(uploadData) + protocol.interceptBufferProtocol 'http', handler, (error) -> + return done(error) if error + $.ajax + url: "http://fake-host" + type: "POST" + data: postData + success: (data) -> + assert.equal data, $.param postData + done() + error: (xhr, errorType, error) -> + done(error) + + describe 'protocol.interceptHttpProtocol', -> + it 'can send POST request', (done) -> + server = http.createServer (req, res) -> + body = '' + req.on 'data', (chunk) -> + body += chunk + req.on 'end', -> + res.end body + server.close() + server.listen 0, '127.0.0.1', -> + {port} = server.address() + url = "http://127.0.0.1:#{port}" + handler = (request, callback) -> + data = + url: url + method: 'POST' + uploadData: + contentType: 'application/x-www-form-urlencoded' + data: request.uploadData[0].bytes.toString() + session: null + callback(data) + protocol.interceptHttpProtocol 'http', handler, (error) -> + return done(error) if error + $.ajax + url: "http://fake-host" + type: "POST" + data: postData + success: (data) -> + assert.deepEqual qs.parse(data), postData + done() + error: (xhr, errorType, error) -> + done(error) + describe 'protocol.uninterceptProtocol', -> it 'returns error when scheme does not exist', (done) -> protocol.uninterceptProtocol 'not-exist', (error) -> From 63c0095efb2133484c6c87c0b37611384a99bce4 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Dec 2015 16:45:49 -0800 Subject: [PATCH 06/25] Emit process exit event with app exit code --- atom/browser/api/atom_api_app.cc | 2 +- atom/browser/api/lib/app.coffee | 12 ++++++++++++ atom/browser/lib/init.coffee | 6 ------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 697d6eca6aab..0c3623583c62 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -344,7 +344,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( auto browser = base::Unretained(Browser::Get()); return mate::ObjectTemplateBuilder(isolate) .SetMethod("quit", base::Bind(&Browser::Quit, browser)) - .SetMethod("exit", base::Bind(&Browser::Exit, browser)) + .SetMethod("_exit", base::Bind(&Browser::Exit, browser)) .SetMethod("focus", base::Bind(&Browser::Focus, browser)) .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser)) .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser)) diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index d0ec41c4d23c..fc0a78298c4d 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -34,6 +34,18 @@ app.setAppPath = (path) -> app.getAppPath = -> appPath +appExitCode = undefined +app.exit = (exitCode) -> + appExitCode = exitCode + app._exit(exitCode) + +# Map process.exit to app.exit, which quits gracefully. +process.exit = app.exit + +# Emit a process 'exit' event on app quit. +app.on 'quit', -> + process.emit 'exit', appExitCode + # Routes the events to webContents. for name in ['login', 'certificate-error', 'select-client-certificate'] do (name) -> diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 85faf0f038ad..9487849e5e69 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -51,13 +51,7 @@ process.on 'uncaughtException', (error) -> message = "Uncaught Exception:\n#{stack}" dialog.showErrorBox 'A JavaScript error occurred in the main process', message -# Emit 'exit' event on quit. {app} = require 'electron' -app.on 'quit', -> - process.emit 'exit' - -# Map process.exit to app.exit, which quits gracefully. -process.exit = app.exit # Load the RPC server. require './rpc-server' From aa82eddca8500a6d3fae9b7dbbcc6bfcd6895ddc Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Mon, 7 Dec 2015 17:05:08 -0800 Subject: [PATCH 07/25] Add spec for exit code on event --- spec/api-app-spec.coffee | 19 +++++++++++++++++++ spec/fixtures/api/quit-app/main.js | 9 +++++++++ spec/fixtures/api/quit-app/package.json | 4 ++++ 3 files changed, 32 insertions(+) create mode 100644 spec/fixtures/api/quit-app/main.js create mode 100644 spec/fixtures/api/quit-app/package.json diff --git a/spec/api-app-spec.coffee b/spec/api-app-spec.coffee index 490727488d99..adb64d363eb1 100644 --- a/spec/api-app-spec.coffee +++ b/spec/api-app-spec.coffee @@ -1,4 +1,6 @@ assert = require 'assert' +ChildProcess = require 'child_process' +path = require 'path' {remote} = require 'electron' {app, BrowserWindow} = remote.require 'electron' @@ -29,6 +31,23 @@ describe 'app module', -> it 'should not be empty', -> assert.notEqual app.getLocale(), '' + describe 'app.exit(exitCode)', -> + appProcess = null + afterEach -> + appProcess?.kill() + + it 'emits a process exit event with the code', (done) -> + appPath = path.join(__dirname, 'fixtures', 'api', 'quit-app') + electronPath = remote.getGlobal('process').execPath + appProcess = ChildProcess.spawn(electronPath, [appPath]) + + output = '' + appProcess.stdout.on 'data', (data) -> output += data + appProcess.on 'close', (code) -> + assert.notEqual output.indexOf('Exit event with code: 123'), -1 + assert.equal code, 123 + done() + describe 'BrowserWindow events', -> w = null afterEach -> diff --git a/spec/fixtures/api/quit-app/main.js b/spec/fixtures/api/quit-app/main.js new file mode 100644 index 000000000000..4bdeb93a5e30 --- /dev/null +++ b/spec/fixtures/api/quit-app/main.js @@ -0,0 +1,9 @@ +var app = require('electron').app + +app.on('ready', function () { + app.exit(123) +}) + +process.on('exit', function (code) { + console.log('Exit event with code: ' + code) +}) diff --git a/spec/fixtures/api/quit-app/package.json b/spec/fixtures/api/quit-app/package.json new file mode 100644 index 000000000000..ea5bb1643b9b --- /dev/null +++ b/spec/fixtures/api/quit-app/package.json @@ -0,0 +1,4 @@ +{ + "name": "quit-app", + "main": "main.js" +} From 92433be8888e3d5eaaaaf93599aab7bcd1e568d6 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:09:59 -0800 Subject: [PATCH 08/25] Include exit code with quit event --- atom/browser/api/atom_api_app.cc | 6 +++--- atom/browser/api/atom_api_app.h | 2 +- atom/browser/api/lib/app.coffee | 9 ++------- atom/browser/atom_browser_main_parts.cc | 4 ++++ atom/browser/atom_browser_main_parts.h | 3 +++ atom/browser/browser.cc | 3 ++- atom/browser/browser_observer.h | 2 +- spec/api-app-spec.coffee | 1 + spec/fixtures/api/quit-app/main.js | 2 +- spec/static/index.html | 1 + 10 files changed, 19 insertions(+), 14 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 0c3623583c62..81ec3fefd510 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -180,8 +180,8 @@ void App::OnWindowAllClosed() { Emit("window-all-closed"); } -void App::OnQuit() { - Emit("quit"); +void App::OnQuit(const int code) { + Emit("quit", code); if (process_singleton_.get()) { process_singleton_->Cleanup(); @@ -344,7 +344,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( auto browser = base::Unretained(Browser::Get()); return mate::ObjectTemplateBuilder(isolate) .SetMethod("quit", base::Bind(&Browser::Quit, browser)) - .SetMethod("_exit", base::Bind(&Browser::Exit, browser)) + .SetMethod("exit", base::Bind(&Browser::Exit, browser)) .SetMethod("focus", base::Bind(&Browser::Focus, browser)) .SetMethod("getVersion", base::Bind(&Browser::GetVersion, browser)) .SetMethod("setVersion", base::Bind(&Browser::SetVersion, browser)) diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index a6f99d65e0af..f04a19e67cdf 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -42,7 +42,7 @@ class App : public AtomBrowserClient::Delegate, void OnBeforeQuit(bool* prevent_default) override; void OnWillQuit(bool* prevent_default) override; void OnWindowAllClosed() override; - void OnQuit() override; + void OnQuit(int code) override; void OnOpenFile(bool* prevent_default, const std::string& file_path) override; void OnOpenURL(const std::string& url) override; void OnActivate(bool has_visible_windows) override; diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index fc0a78298c4d..9a7fc6e71141 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -34,17 +34,12 @@ app.setAppPath = (path) -> app.getAppPath = -> appPath -appExitCode = undefined -app.exit = (exitCode) -> - appExitCode = exitCode - app._exit(exitCode) - # Map process.exit to app.exit, which quits gracefully. process.exit = app.exit # Emit a process 'exit' event on app quit. -app.on 'quit', -> - process.emit 'exit', appExitCode +app.on 'quit', (event, exitCode) -> + process.emit 'exit', exitCode # Routes the events to webContents. for name in ['login', 'certificate-error', 'select-client-certificate'] diff --git a/atom/browser/atom_browser_main_parts.cc b/atom/browser/atom_browser_main_parts.cc index fd72f5e4ae9a..eadd52ac44c8 100644 --- a/atom/browser/atom_browser_main_parts.cc +++ b/atom/browser/atom_browser_main_parts.cc @@ -61,6 +61,10 @@ bool AtomBrowserMainParts::SetExitCode(int code) { return true; } +int AtomBrowserMainParts::GetExitCode() { + return exit_code_ != nullptr ? *exit_code_ : 0; +} + base::Closure AtomBrowserMainParts::RegisterDestructionCallback( const base::Closure& callback) { auto iter = destructors_.insert(destructors_.end(), callback); diff --git a/atom/browser/atom_browser_main_parts.h b/atom/browser/atom_browser_main_parts.h index fbc59f7f811d..c1c0c89c6786 100644 --- a/atom/browser/atom_browser_main_parts.h +++ b/atom/browser/atom_browser_main_parts.h @@ -34,6 +34,9 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts { // Sets the exit code, will fail if the the message loop is not ready. bool SetExitCode(int code); + // Gets the exit code + int GetExitCode(); + // Register a callback that should be destroyed before JavaScript environment // gets destroyed. // Returns a closure that can be used to remove |callback| from the list. diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index c77f359760c9..ee00efa07110 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -72,7 +72,8 @@ void Browser::Shutdown() { is_shutdown_ = true; is_quiting_ = true; - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); + int exitCode = AtomBrowserMainParts::Get()->GetExitCode(); + FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit(exitCode)); if (base::MessageLoop::current()) { base::MessageLoop::current()->PostTask( diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index f6d76bc13fb3..f3ae2e364de4 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -24,7 +24,7 @@ class BrowserObserver { virtual void OnWindowAllClosed() {} // The browser is quitting. - virtual void OnQuit() {} + virtual void OnQuit(const int code) {} // The browser has opened a file by double clicking in Finder or dragging the // file to the Dock icon. (OS X only) diff --git a/spec/api-app-spec.coffee b/spec/api-app-spec.coffee index adb64d363eb1..7b7e5fa483df 100644 --- a/spec/api-app-spec.coffee +++ b/spec/api-app-spec.coffee @@ -44,6 +44,7 @@ describe 'app module', -> output = '' appProcess.stdout.on 'data', (data) -> output += data appProcess.on 'close', (code) -> + console.log output assert.notEqual output.indexOf('Exit event with code: 123'), -1 assert.equal code, 123 done() diff --git a/spec/fixtures/api/quit-app/main.js b/spec/fixtures/api/quit-app/main.js index 4bdeb93a5e30..85939acd7348 100644 --- a/spec/fixtures/api/quit-app/main.js +++ b/spec/fixtures/api/quit-app/main.js @@ -5,5 +5,5 @@ app.on('ready', function () { }) process.on('exit', function (code) { - console.log('Exit event with code: ' + code) + console.log('Exit event with code: ' + JSON.stringify(code, null, 2)) }) diff --git a/spec/static/index.html b/spec/static/index.html index ea86f6ee302d..2053ca41355c 100644 --- a/spec/static/index.html +++ b/spec/static/index.html @@ -56,6 +56,7 @@ mocha.ui('bdd').reporter(isCi ? 'tap' : 'html'); var query = Mocha.utils.parseQuery(window.location.search || ''); + query.grep = 'app.exit' if (query.grep) mocha.grep(query.grep); if (query.invert) mocha.invert(); From fc724b51e8c206fe10a648bfd73ad0593e277601 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:11:38 -0800 Subject: [PATCH 09/25] Move event forwarding back to init --- atom/browser/api/lib/app.coffee | 7 ------- atom/browser/lib/init.coffee | 6 ++++++ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/atom/browser/api/lib/app.coffee b/atom/browser/api/lib/app.coffee index 9a7fc6e71141..d0ec41c4d23c 100644 --- a/atom/browser/api/lib/app.coffee +++ b/atom/browser/api/lib/app.coffee @@ -34,13 +34,6 @@ app.setAppPath = (path) -> app.getAppPath = -> appPath -# Map process.exit to app.exit, which quits gracefully. -process.exit = app.exit - -# Emit a process 'exit' event on app quit. -app.on 'quit', (event, exitCode) -> - process.emit 'exit', exitCode - # Routes the events to webContents. for name in ['login', 'certificate-error', 'select-client-certificate'] do (name) -> diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 9487849e5e69..41cd6fb22ca2 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -51,7 +51,13 @@ process.on 'uncaughtException', (error) -> message = "Uncaught Exception:\n#{stack}" dialog.showErrorBox 'A JavaScript error occurred in the main process', message +# Emit a process 'exit' event on app quit. {app} = require 'electron' +app.on 'quit', (event, exitCode) -> + process.emit 'exit', exitCode + +# Map process.exit to app.exit, which quits gracefully. +process.exit = app.exit # Load the RPC server. require './rpc-server' From c4389ad70f63b1aec9430b225bd084bf8b99833c Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:12:19 -0800 Subject: [PATCH 10/25] Remove grep value setting --- spec/static/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/static/index.html b/spec/static/index.html index 2053ca41355c..ea86f6ee302d 100644 --- a/spec/static/index.html +++ b/spec/static/index.html @@ -56,7 +56,6 @@ mocha.ui('bdd').reporter(isCi ? 'tap' : 'html'); var query = Mocha.utils.parseQuery(window.location.search || ''); - query.grep = 'app.exit' if (query.grep) mocha.grep(query.grep); if (query.invert) mocha.invert(); From 3e5caf7e544ca006a7a63660c10e9fbffbded505 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:19:51 -0800 Subject: [PATCH 11/25] Get exit code from within App::OnQuit --- atom/browser/api/atom_api_app.cc | 5 +++-- atom/browser/api/atom_api_app.h | 2 +- atom/browser/browser.cc | 3 +-- atom/browser/browser_observer.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 81ec3fefd510..256ecff53e10 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -180,8 +180,9 @@ void App::OnWindowAllClosed() { Emit("window-all-closed"); } -void App::OnQuit(const int code) { - Emit("quit", code); +void App::OnQuit() { + int exitCode = AtomBrowserMainParts::Get()->GetExitCode(); + Emit("quit", exitCode); if (process_singleton_.get()) { process_singleton_->Cleanup(); diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index f04a19e67cdf..a6f99d65e0af 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -42,7 +42,7 @@ class App : public AtomBrowserClient::Delegate, void OnBeforeQuit(bool* prevent_default) override; void OnWillQuit(bool* prevent_default) override; void OnWindowAllClosed() override; - void OnQuit(int code) override; + void OnQuit() override; void OnOpenFile(bool* prevent_default, const std::string& file_path) override; void OnOpenURL(const std::string& url) override; void OnActivate(bool has_visible_windows) override; diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index ee00efa07110..c77f359760c9 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -72,8 +72,7 @@ void Browser::Shutdown() { is_shutdown_ = true; is_quiting_ = true; - int exitCode = AtomBrowserMainParts::Get()->GetExitCode(); - FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit(exitCode)); + FOR_EACH_OBSERVER(BrowserObserver, observers_, OnQuit()); if (base::MessageLoop::current()) { base::MessageLoop::current()->PostTask( diff --git a/atom/browser/browser_observer.h b/atom/browser/browser_observer.h index f3ae2e364de4..f6d76bc13fb3 100644 --- a/atom/browser/browser_observer.h +++ b/atom/browser/browser_observer.h @@ -24,7 +24,7 @@ class BrowserObserver { virtual void OnWindowAllClosed() {} // The browser is quitting. - virtual void OnQuit(const int code) {} + virtual void OnQuit() {} // The browser has opened a file by double clicking in Finder or dragging the // file to the Dock icon. (OS X only) From ea1479a651bfbe4666e13f4e68e2b1177f3f512e Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:20:32 -0800 Subject: [PATCH 12/25] Revert comment tweak --- atom/browser/lib/init.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/lib/init.coffee b/atom/browser/lib/init.coffee index 41cd6fb22ca2..c3d56d9c7c82 100644 --- a/atom/browser/lib/init.coffee +++ b/atom/browser/lib/init.coffee @@ -51,7 +51,7 @@ process.on 'uncaughtException', (error) -> message = "Uncaught Exception:\n#{stack}" dialog.showErrorBox 'A JavaScript error occurred in the main process', message -# Emit a process 'exit' event on app quit. +# Emit 'exit' event on quit. {app} = require 'electron' app.on 'quit', (event, exitCode) -> process.emit 'exit', exitCode From e1654ee334962c9786756fab314f3b6649a34bb0 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:22:54 -0800 Subject: [PATCH 13/25] :memo: Document quit event includes exit code --- docs/api/app.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/api/app.md b/docs/api/app.md index 3faf4a1f0ac6..f21f37039705 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -64,6 +64,11 @@ the `will-quit` and `window-all-closed` events. ### Event: 'quit' +Returns: + +* `event` Event +* `exitCode` Integer + Emitted when the application is quitting. ### Event: 'open-file' _OS X_ From 516ff0644c9aca8e921c46fc70a928f0d1388966 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:23:50 -0800 Subject: [PATCH 14/25] Just include exit code in spec output --- spec/api-app-spec.coffee | 1 - spec/fixtures/api/quit-app/main.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/api-app-spec.coffee b/spec/api-app-spec.coffee index 7b7e5fa483df..adb64d363eb1 100644 --- a/spec/api-app-spec.coffee +++ b/spec/api-app-spec.coffee @@ -44,7 +44,6 @@ describe 'app module', -> output = '' appProcess.stdout.on 'data', (data) -> output += data appProcess.on 'close', (code) -> - console.log output assert.notEqual output.indexOf('Exit event with code: 123'), -1 assert.equal code, 123 done() diff --git a/spec/fixtures/api/quit-app/main.js b/spec/fixtures/api/quit-app/main.js index 85939acd7348..4bdeb93a5e30 100644 --- a/spec/fixtures/api/quit-app/main.js +++ b/spec/fixtures/api/quit-app/main.js @@ -5,5 +5,5 @@ app.on('ready', function () { }) process.on('exit', function (code) { - console.log('Exit event with code: ' + JSON.stringify(code, null, 2)) + console.log('Exit event with code: ' + code) }) From f5774e3fb24ca403de481e446c3bf68fa78b2c47 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Dec 2015 18:39:59 -0800 Subject: [PATCH 15/25] Exit from a setImmediate callback --- spec/fixtures/api/quit-app/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/fixtures/api/quit-app/main.js b/spec/fixtures/api/quit-app/main.js index 4bdeb93a5e30..e2f97affe6de 100644 --- a/spec/fixtures/api/quit-app/main.js +++ b/spec/fixtures/api/quit-app/main.js @@ -1,7 +1,10 @@ var app = require('electron').app app.on('ready', function () { - app.exit(123) + // This setImmediate call gets the spec passing on Linux + setImmediate(function () { + app.exit(123) + }) }) process.on('exit', function (code) { From 388a18b265de0a6af702ade4c870787c6eac6f25 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 11:22:55 +0800 Subject: [PATCH 16/25] Don't emit `will-quit` event when calling app.exit --- atom/browser/browser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/browser.cc b/atom/browser/browser.cc index c77f359760c9..7a2c22ea9d23 100644 --- a/atom/browser/browser.cc +++ b/atom/browser/browser.cc @@ -55,7 +55,7 @@ void Browser::Exit(int code) { // Must destroy windows before quitting, otherwise bad things can happen. atom::WindowList* window_list = atom::WindowList::GetInstance(); if (window_list->size() == 0) { - NotifyAndShutdown(); + Shutdown(); } else { // Unlike Quit(), we do not ask to close window, but destroy the window // without asking. From 2d940b7df7ca7e842eec94769f451afe88fab542 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 11:27:41 +0800 Subject: [PATCH 17/25] Don't add the "Enter Full Screen" menu item automatically --- atom/browser/mac/atom_application_delegate.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atom/browser/mac/atom_application_delegate.mm b/atom/browser/mac/atom_application_delegate.mm index a18d2fe40fcd..7662162ab618 100644 --- a/atom/browser/mac/atom_application_delegate.mm +++ b/atom/browser/mac/atom_application_delegate.mm @@ -21,6 +21,9 @@ } - (void)applicationWillFinishLaunching:(NSNotification*)notify { + // Don't add the "Enter Full Screen" menu item automatically. + [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"NSFullScreenMenuItemEverywhere"]; + atom::Browser::Get()->WillFinishLaunching(); } From aa8efd90cca62624131f2f53e137dd5312bfaa1c Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:09:46 +0800 Subject: [PATCH 18/25] Bring back AppVeyor --- appveyor.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000000..c2b3cca29ced --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,29 @@ +# appveyor file +# http://www.appveyor.com/docs/appveyor-yml +version: "{build}" + +init: + - git config --global core.autocrlf input + +environment: + matrix: + - nodejs_version: '4' + +platform: + - x86 + - x64 + +install: + - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) + - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% + - cmd: SET PATH=C:\python27;%PATH% + - cmd: python script/bootstrap.py --dev + - cmd: python script/build.py -c D + +test_script: + - node --version + - npm --version + - cmd: python script/cpplint.py + - cmd: python script/coffeelint.py + +build: off From 33db4a6ac1094492b5f9c262ce8dba87b3e62f7b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:21:52 +0800 Subject: [PATCH 19/25] Run cibuild --- appveyor.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index c2b3cca29ced..5e6a1b2b68ca 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -17,8 +17,7 @@ install: - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% - cmd: SET PATH=C:\python27;%PATH% - - cmd: python script/bootstrap.py --dev - - cmd: python script/build.py -c D + - cmd: python script/cibuild test_script: - node --version From cb806aa3627f5845a429321ca76ab5a35df05003 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:22:46 +0800 Subject: [PATCH 20/25] Use default node 0.12.7 Otherwise we would spend some time reinstalling node. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 5e6a1b2b68ca..85071979a0e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,7 +7,7 @@ init: environment: matrix: - - nodejs_version: '4' + - nodejs_version: '0.12.7' platform: - x86 From 8c31148f7d17340672d43d945a51f1391f10efcc Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:35:22 +0800 Subject: [PATCH 21/25] Remove unneeded things --- appveyor.yml | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 85071979a0e9..37a50bdf3517 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,24 +5,11 @@ version: "{build}" init: - git config --global core.autocrlf input -environment: - matrix: - - nodejs_version: '0.12.7' - platform: - x86 - x64 install: - - ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% - cmd: SET PATH=C:\python27;%PATH% - cmd: python script/cibuild - -test_script: - - node --version - - npm --version - - cmd: python script/cpplint.py - - cmd: python script/coffeelint.py - -build: off From f11f408420be35454b19a230b5e2cc88de889cbf Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:48:10 +0800 Subject: [PATCH 22/25] Do not automatically build everything --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 37a50bdf3517..9f4cde8aa5de 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,3 +13,5 @@ install: - cmd: SET PATH=C:\Program Files (x86)\MSBuild\12.0\bin\;%PATH% - cmd: SET PATH=C:\python27;%PATH% - cmd: python script/cibuild + +build: off From 5cf369086cd98289f09360d72bacc4d81f1c5483 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 12:58:29 +0800 Subject: [PATCH 23/25] Also disable test phase --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 9f4cde8aa5de..a3fd51925588 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,4 +14,6 @@ install: - cmd: SET PATH=C:\python27;%PATH% - cmd: python script/cibuild +# disable build and test pahses build: off +test: off From bf5c3bc9ddc03929c4009fefc445e764ed7eac74 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 13:18:23 +0800 Subject: [PATCH 24/25] Avoid duplicate building for PR --- appveyor.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index a3fd51925588..0fa0c0d9bddd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -14,6 +14,10 @@ install: - cmd: SET PATH=C:\python27;%PATH% - cmd: python script/cibuild +branches: + only: + - master + # disable build and test pahses build: off test: off From b42695a0b5e6dec92fe86b8a7f40ec0d0b7c8db7 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 10 Dec 2015 14:37:09 +0800 Subject: [PATCH 25/25] win: Don't attach console for third party terms Close #3692. --- atom/app/atom_main.cc | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/atom/app/atom_main.cc b/atom/app/atom_main.cc index 5b5df448dfa8..1ffab8d9225a 100644 --- a/atom/app/atom_main.cc +++ b/atom/app/atom_main.cc @@ -7,10 +7,6 @@ #include #if defined(OS_WIN) -#include -#include -#include - #include #include #include @@ -56,12 +52,6 @@ bool IsRunAsNode() { } #if defined(OS_WIN) -bool IsCygwin() { - std::string os; - scoped_ptr env(base::Environment::Create()); - return env->GetVar("OS", &os) && os == "cygwin"; -} - // Win8.1 supports monitor-specific DPI scaling. bool SetProcessDpiAwarenessWrapper(PROCESS_DPI_AWARENESS value) { typedef HRESULT(WINAPI *SetProcessDpiAwarenessPtr)(PROCESS_DPI_AWARENESS); @@ -109,7 +99,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { wchar_t** wargv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); // Make output work in console if we are not in cygiwn. - if (!IsCygwin() && !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) { + if (!IsEnvSet("TERM") && !IsEnvSet("ELECTRON_NO_ATTACH_CONSOLE")) { AttachConsole(ATTACH_PARENT_PROCESS); FILE* dontcare;