From 0410a184ceca003eadffd508e1ae52cb7ddefb8d Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 10 Oct 2016 05:00:38 +0530 Subject: [PATCH 01/15] webContents: handle POST navigation for new windows --- atom/browser/api/atom_api_app.cc | 17 ++-- atom/browser/api/atom_api_app.h | 14 +-- atom/browser/api/atom_api_web_contents.cc | 18 +++- atom/browser/api/atom_api_web_contents.h | 14 ++- atom/browser/atom_browser_client.cc | 4 +- atom/browser/atom_browser_client.h | 39 ++++---- .../content_converter.cc | 99 +++++++++++++++++++ .../content_converter.h | 10 ++ lib/browser/api/browser-window.js | 8 +- lib/browser/guest-window-manager.js | 13 ++- 10 files changed, 187 insertions(+), 49 deletions(-) diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 1d4d67f11cdf..149d98c6e662 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -528,12 +528,14 @@ void App::OnLogin(LoginHandler* login_handler, login_handler->CancelAuth(); } -void App::OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - const std::vector& features, - int render_process_id, - int render_frame_id) { +void App::OnCreateWindow( + const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + const std::vector& features, + const scoped_refptr& body, + int render_process_id, + int render_frame_id) { v8::Locker locker(isolate()); v8::HandleScope handle_scope(isolate()); content::RenderFrameHost* rfh = @@ -545,7 +547,8 @@ void App::OnCreateWindow(const GURL& target_url, api_web_contents->OnCreateWindow(target_url, frame_name, disposition, - features); + features, + body); } } diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index b11c68077560..f3b662f3c17b 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -48,12 +48,14 @@ class App : public AtomBrowserClient::Delegate, v8::Local prototype); // Called when window with disposition needs to be created. - void OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - const std::vector& features, - int render_process_id, - int render_frame_id); + void OnCreateWindow( + const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + const std::vector& features, + const scoped_refptr& body, + int render_process_id, + int render_frame_id); #if defined(USE_NSS_CERTS) void OnCertificateManagerModelCreated( diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index a1dc5203b68d..f495ed80fa4e 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -387,12 +387,14 @@ bool WebContents::AddMessageToConsole(content::WebContents* source, } } -void WebContents::OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - const std::vector& features) { +void WebContents::OnCreateWindow( + const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + const std::vector& features, + const scoped_refptr& body) { if (type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) - Emit("-new-window", target_url, frame_name, disposition, features); + Emit("-new-window", target_url, frame_name, disposition, features, body); else Emit("new-window", target_url, frame_name, disposition, features); } @@ -855,6 +857,12 @@ void WebContents::LoadURL(const GURL& url, const mate::Dictionary& options) { if (options.Get("extraHeaders", &extra_headers)) params.extra_headers = extra_headers; + scoped_refptr body; + if (options.Get("postData", &body)) { + params.post_data = body; + params.load_type = content::NavigationController::LOAD_TYPE_HTTP_POST; + } + params.transition_type = ui::PAGE_TRANSITION_TYPED; params.should_clear_history_list = true; params.override_user_agent = content::NavigationController::UA_OVERRIDE_TRUE; diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index c7b92f54727d..ff2823a282db 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -26,6 +26,10 @@ namespace brightray { class InspectableWebContents; } +namespace content { +class ResourceRequestBodyImpl; +} + namespace mate { class Arguments; class Dictionary; @@ -176,10 +180,12 @@ class WebContents : public mate::TrackableObject, bool allowed); // Create window with the given disposition. - void OnCreateWindow(const GURL& target_url, - const std::string& frame_name, - WindowOpenDisposition disposition, - const std::vector& features); + void OnCreateWindow( + const GURL& target_url, + const std::string& frame_name, + WindowOpenDisposition disposition, + const std::vector& features, + const scoped_refptr& body); // Returns the web preferences of current WebContents. v8::Local GetWebPreferences(v8::Isolate* isolate); diff --git a/atom/browser/atom_browser_client.cc b/atom/browser/atom_browser_client.cc index ca994edf0d15..030ad1402b11 100644 --- a/atom/browser/atom_browser_client.cc +++ b/atom/browser/atom_browser_client.cc @@ -30,6 +30,7 @@ #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/renderer_host/pepper/widevine_cdm_message_filter.h" #include "chrome/browser/speech/tts_message_filter.h" +#include "content/common/resource_request_body_impl.h" #include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/client_certificate_delegate.h" #include "content/public/browser/geolocation_delegate.h" @@ -319,7 +320,7 @@ bool AtomBrowserClient::CanCreateWindow( WindowOpenDisposition disposition, const blink::WebWindowFeatures& features, const std::vector& additional_features, - const scoped_refptr& body, + const scoped_refptr& body, bool user_gesture, bool opener_suppressed, content::ResourceContext* context, @@ -342,6 +343,7 @@ bool AtomBrowserClient::CanCreateWindow( frame_name, disposition, additional_features, + body, render_process_id, opener_render_frame_id)); } diff --git a/atom/browser/atom_browser_client.h b/atom/browser/atom_browser_client.h index 208855bc7228..90c223db0e1f 100644 --- a/atom/browser/atom_browser_client.h +++ b/atom/browser/atom_browser_client.h @@ -13,8 +13,6 @@ #include "brightray/browser/browser_client.h" #include "content/public/browser/render_process_host_observer.h" -using content::ResourceRequestBodyImpl; - namespace content { class QuotaPermissionContext; class ClientCertificateDelegate; @@ -81,24 +79,25 @@ class AtomBrowserClient : public brightray::BrowserClient, net::SSLCertRequestInfo* cert_request_info, std::unique_ptr delegate) override; void ResourceDispatcherHostCreated() override; - bool CanCreateWindow(const GURL& opener_url, - const GURL& opener_top_level_frame_url, - const GURL& source_origin, - WindowContainerType container_type, - const std::string& frame_name, - const GURL& target_url, - const content::Referrer& referrer, - WindowOpenDisposition disposition, - const blink::WebWindowFeatures& features, - const std::vector& additional_features, - const scoped_refptr& body, - bool user_gesture, - bool opener_suppressed, - content::ResourceContext* context, - int render_process_id, - int opener_render_view_id, - int opener_render_frame_id, - bool* no_javascript_access) override; + bool CanCreateWindow( + const GURL& opener_url, + const GURL& opener_top_level_frame_url, + const GURL& source_origin, + WindowContainerType container_type, + const std::string& frame_name, + const GURL& target_url, + const content::Referrer& referrer, + WindowOpenDisposition disposition, + const blink::WebWindowFeatures& features, + const std::vector& additional_features, + const scoped_refptr& body, + bool user_gesture, + bool opener_suppressed, + content::ResourceContext* context, + int render_process_id, + int opener_render_view_id, + int opener_render_frame_id, + bool* no_javascript_access) override; void GetAdditionalAllowedSchemesForFileSystem( std::vector* schemes) override; diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index d244ec7a27b7..8646ec99eb60 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -14,10 +14,14 @@ #include "atom/common/native_mate_converters/gurl_converter.h" #include "atom/common/native_mate_converters/string16_converter.h" #include "atom/common/native_mate_converters/ui_base_types_converter.h" +#include "atom/common/native_mate_converters/value_converter.h" +#include "content/common/resource_request_body_impl.h" #include "content/public/browser/web_contents.h" #include "content/public/common/context_menu_params.h" #include "native_mate/dictionary.h" +using content::ResourceRequestBodyImpl; + namespace { void ExecuteCommand(content::WebContents* web_contents, @@ -195,6 +199,101 @@ bool Converter::FromV8( return true; } +// static +v8::Local +Converter>::ToV8( + v8::Isolate* isolate, + const scoped_refptr& val) { + if (!val) + return v8::Null(isolate); + std::unique_ptr list(new base::ListValue); + for (const auto& element : *(val->elements())) { + std::unique_ptr post_data_dict( + new base::DictionaryValue); + auto type = element.type(); + if (type == ResourceRequestBodyImpl::Element::TYPE_BYTES) { + std::unique_ptr bytes( + base::BinaryValue::CreateWithCopiedBuffer( + element.bytes(), static_cast(element.length()))); + post_data_dict->SetString("type", "data"); + post_data_dict->Set("bytes", std::move(bytes)); + } else if (type == ResourceRequestBodyImpl::Element::TYPE_FILE) { + post_data_dict->SetString("type", "file"); + post_data_dict->SetStringWithoutPathExpansion( + "filePath", element.path().AsUTF8Unsafe()); + post_data_dict->SetInteger("offset", static_cast(element.offset())); + post_data_dict->SetInteger("length", static_cast(element.length())); + post_data_dict->SetDouble( + "modificationTime", element.expected_modification_time().ToDoubleT()); + } else if (type == ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { + post_data_dict->SetString("type", "fileSystem"); + post_data_dict->SetStringWithoutPathExpansion( + "fileSystemURL", element.filesystem_url().spec()); + post_data_dict->SetInteger("offset", static_cast(element.offset())); + post_data_dict->SetInteger("length", static_cast(element.length())); + post_data_dict->SetDouble( + "modificationTime", element.expected_modification_time().ToDoubleT()); + } else if (type == ResourceRequestBodyImpl::Element::TYPE_BLOB) { + post_data_dict->SetString("type", "blob"); + post_data_dict->SetString("blobUUID", element.blob_uuid()); + } + list->Append(std::move(post_data_dict)); + } + return ConvertToV8(isolate, *list); +} + +// static +bool Converter>::FromV8( + v8::Isolate* isolate, + v8::Local val, + scoped_refptr* out) { + std::unique_ptr list(new base::ListValue); + if (!ConvertFromV8(isolate, val, list.get())) + return false; + *out = new content::ResourceRequestBodyImpl(); + for (int i = 0; i < list->GetSize(); ++i) { + base::DictionaryValue* dict = nullptr; + std::string type; + list->GetDictionary(i, &dict); + dict->GetString("type", &type); + if (type == "data") { + base::BinaryValue* bytes = nullptr; + dict->GetBinary("bytes", &bytes); + (*out)->AppendBytes(bytes->GetBuffer(), bytes->GetSize()); + } else if (type == "file") { + std::string file; + int offset, length; + double modification_time; + dict->GetStringWithoutPathExpansion("filePath", &file); + dict->GetInteger("offset", &offset); + dict->GetInteger("file", &length); + dict->GetDouble("modificationTime", &modification_time); + (*out)->AppendFileRange(base::FilePath::FromUTF8Unsafe(file), + static_cast(offset), + static_cast(length), + base::Time::FromDoubleT(modification_time)); + } else if (type == "fileSystem") { + std::string file_system_url; + int offset, length; + double modification_time; + dict->GetStringWithoutPathExpansion("fileSystemURL", &file_system_url); + dict->GetInteger("offset", &offset); + dict->GetInteger("file", &length); + dict->GetDouble("modificationTime", &modification_time); + (*out)->AppendFileSystemFileRange( + GURL(file_system_url), + static_cast(offset), + static_cast(length), + base::Time::FromDoubleT(modification_time)); + } else if (type == "blob") { + std::string uuid; + dict->GetString("blobUUID", &uuid); + (*out)->AppendBlob(uuid); + } + } + return true; +} + // static v8::Local Converter::ToV8( v8::Isolate* isolate, content::WebContents* val) { diff --git a/atom/common/native_mate_converters/content_converter.h b/atom/common/native_mate_converters/content_converter.h index dd27450b36aa..7d00f105c190 100644 --- a/atom/common/native_mate_converters/content_converter.h +++ b/atom/common/native_mate_converters/content_converter.h @@ -15,6 +15,7 @@ namespace content { struct ContextMenuParams; +class ResourceRequestBodyImpl; class WebContents; } @@ -47,6 +48,15 @@ struct Converter { const content::PermissionType& val); }; +template<> +struct Converter> { + static v8::Local ToV8( + v8::Isolate* isolate, + const scoped_refptr& val); + static bool FromV8(v8::Isolate* isolate, v8::Local val, + scoped_refptr* out); +}; + template<> struct Converter { static bool FromV8(v8::Isolate* isolate, v8::Local val, diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 237d655b8a66..32a9f0f426ae 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -18,13 +18,17 @@ BrowserWindow.prototype._init = function () { } // Make new windows requested by links behave like "window.open" - this.webContents.on('-new-window', (event, url, frameName, disposition, additionalFeatures) => { + this.webContents.on('-new-window', (event, url, frameName, + disposition, additionalFeatures, + postData) => { const options = { show: true, width: 800, height: 600 } - ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options, additionalFeatures) + ipcMain.emit('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', + event, url, frameName, disposition, + options, additionalFeatures, postData) }) this.webContents.on('-web-contents-created', (event, webContents, url, diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index d0fa3cd4e23b..6ccdb4f7642f 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -84,7 +84,7 @@ const setupGuest = function (embedder, frameName, guest, options) { } // Create a new guest created by |embedder| with |options|. -const createGuest = function (embedder, url, frameName, options) { +const createGuest = function (embedder, url, frameName, options, postData) { let guest = frameToGuest[frameName] if (frameName && (guest != null)) { guest.loadURL(url) @@ -119,7 +119,10 @@ const createGuest = function (embedder, url, frameName, options) { // // The above code would not work if a navigation to "about:blank" is done // here, since the window would be cleared of all changes in the next tick. - guest.loadURL(url) + const loadOptions = {} + if (postData) + loadOptions.postData = postData + guest.loadURL(url, loadOptions) } return setupGuest(embedder, frameName, guest, options) @@ -140,7 +143,9 @@ const getGuestWindow = function (guestId) { } // Routed window.open messages. -ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, disposition, options, additionalFeatures) { +ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, + disposition, options, + additionalFeatures, postData) { options = mergeBrowserWindowOptions(event.sender, options) event.sender.emit('new-window', event, url, frameName, disposition, options, additionalFeatures) const newGuest = event.newGuest @@ -151,7 +156,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, fr event.returnValue = null } } else { - event.returnValue = createGuest(event.sender, url, frameName, options) + event.returnValue = createGuest(event.sender, url, frameName, options, postData) } }) From 2d7ceae320243cb3bb996e6704440ed69f9acea1 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 10 Oct 2016 18:28:56 +0530 Subject: [PATCH 02/15] fix js lint error --- lib/browser/guest-window-manager.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 6ccdb4f7642f..0bb7970f82e9 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -120,8 +120,9 @@ const createGuest = function (embedder, url, frameName, options, postData) { // The above code would not work if a navigation to "about:blank" is done // here, since the window would be cleared of all changes in the next tick. const loadOptions = {} - if (postData) + if (postData) { loadOptions.postData = postData + } guest.loadURL(url, loadOptions) } From 2044208fd6fb7470524cb90b9ffa398e900fe3d5 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 10 Oct 2016 18:29:34 +0530 Subject: [PATCH 03/15] add docs --- docs/api/browser-window.md | 23 +++++++++++++++++++++++ docs/api/web-contents.md | 23 +++++++++++++++++++++++ docs/api/web-view-tag.md | 23 +++++++++++++++++++++++ 3 files changed, 69 insertions(+) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 4a2c541a14ee..a8d43cd293c9 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -969,6 +969,29 @@ Same as `webContents.capturePage([rect, ]callback)`. * `httpReferrer` String (optional) - A HTTP Referrer url. * `userAgent` String (optional) - A user agent originating the request. * `extraHeaders` String (optional) - Extra headers separated by "\n" + * `postData` Array (optional) - An array of `upload` objects which + provides the request body for `POST` navigation. + +* `upload` Object + * `type` String - `data`, `file`, `filsSystem`, `blob`. + +If `type` is `data` then `upload` object must contain: + * `bytes` Buffer - Raw data to be uploaded. + +If `type` is `file` then `upload` object must contain: + * `filePath` String - Path of file to be uploaded. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `fileSystem` then `upload` object must contain: + * `filsSystemURL` String - FileSystem url to read data for upload. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `blob` then `upload` object must contain: + * `blobUUID` String - UUID of blob data to upload. Same as `webContents.loadURL(url[, options])`. diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 249188eac8bd..d122587cc630 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -490,6 +490,29 @@ win.loadURL('http://github.com') * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" + * `postData` Array - An array of `upload` objects which + provides the request body for `POST` navigation. + +* `upload` Object + * `type` String - `data`, `file`, `filsSystem`, `blob`. + +If `type` is `data` then `upload` object must contain: + * `bytes` Buffer - Raw data to be uploaded. + +If `type` is `file` then `upload` object must contain: + * `filePath` String - Path of file to be uploaded. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `fileSystem` then `upload` object must contain: + * `filsSystemURL` String - FileSystem url to read data for upload. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `blob` then `upload` object must contain: + * `blobUUID` String - UUID of blob data to upload. Loads the `url` in the window. The `url` must contain the protocol prefix, e.g. the `http://` or `file://`. If the load should bypass http cache then diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 0c8c1bb94cb0..f9e47f0c3835 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -265,6 +265,29 @@ webview.addEventListener('dom-ready', () => { * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" + * `postData` Array - An array of `upload` objects which + provides the request body for `POST` navigation. + +* `upload` Object + * `type` String - `data`, `file`, `filsSystem`, `blob`. + +If `type` is `data` then `upload` object must contain: + * `bytes` Buffer - Raw data to be uploaded. + +If `type` is `file` then `upload` object must contain: + * `filePath` String - Path of file to be uploaded. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `fileSystem` then `upload` object must contain: + * `filsSystemURL` String - FileSystem url to read data for upload. + * `offset` Integer + * `length` Integer + * `modificationTime` Double + +If `type` is `blob` then `upload` object must contain: + * `blobUUID` String - UUID of blob data to upload. Loads the `url` in the webview, the `url` must contain the protocol prefix, e.g. the `http://` or `file://`. From ad5f944185c749f74b2301f151af10583432e301 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 12 Oct 2016 22:56:53 +0530 Subject: [PATCH 04/15] add spec --- .../content_converter.cc | 3 +- spec/api-browser-window-spec.js | 46 ++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index 8646ec99eb60..e70c65699c43 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -254,7 +254,8 @@ bool Converter>::FromV8( for (int i = 0; i < list->GetSize(); ++i) { base::DictionaryValue* dict = nullptr; std::string type; - list->GetDictionary(i, &dict); + if (!list->GetDictionary(i, &dict)) + return false; dict->GetString("type", &type); if (type == "data") { base::BinaryValue* bytes = nullptr; diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index b81ec2f790d6..f4bb529b605c 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -4,6 +4,7 @@ const assert = require('assert') const fs = require('fs') const path = require('path') const os = require('os') +const qs = require('querystring') const http = require('http') const {closeWindow} = require('./window-helpers') @@ -21,11 +22,47 @@ const {protocol} = remote describe('browser-window module', function () { var fixtures = path.resolve(__dirname, 'fixtures') var w = null - var server + var server, postData before(function (done) { + const filePath = path.join(fixtures, 'pages', 'a.html') + const fileStats = fs.statSync(filePath) + postData = [ + { + 'type': 'data', + 'bytes': new Buffer('username=test&file=') + }, + { + 'type': 'file', + 'filePath': filePath, + 'offset': 0, + 'length': fileStats.size, + 'modificationTime': fileStats.mtime.getTime() / 1000 + } + ] server = http.createServer(function (req, res) { - function respond () { res.end('') } + function respond () { + if (req.method === 'POST') { + let body = '' + req.on('data', (data) => { + if (data) { + body += data + } + }) + req.on('end', () => { + let parsedData = qs.parse(body) + fs.readFile(filePath, (err, data) => { + if (err) return + if (parsedData.username === 'test' && + parsedData.file === data.toString()) { + res.end() + } + }) + }) + } else { + res.end() + } + } setTimeout(respond, req.url.includes('slow') ? 200 : 0) }) server.listen(0, '127.0.0.1', function () { @@ -187,6 +224,11 @@ describe('browser-window module', function () { }) w.loadURL('http://127.0.0.1:11111') }) + + it('can initiate POST navigation', function (done) { + w.webContents.on('did-finish-load', () => done()) + w.loadURL(server.url, {'postData': postData}) + }) }) describe('BrowserWindow.show()', function () { From dbe57c4ad46068046f3a3e4b69cc5a33709ef3f9 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Wed, 12 Oct 2016 23:35:35 +0530 Subject: [PATCH 05/15] update docs --- docs/api/browser-window.md | 30 +++-------------------- docs/api/structures/upload-blob.md | 4 +++ docs/api/structures/upload-file-system.md | 9 +++++++ docs/api/structures/upload-file.md | 9 +++++++ docs/api/web-contents.md | 24 +----------------- docs/api/web-view-tag.md | 24 +----------------- 6 files changed, 28 insertions(+), 72 deletions(-) create mode 100644 docs/api/structures/upload-blob.md create mode 100644 docs/api/structures/upload-file-system.md create mode 100644 docs/api/structures/upload-file.md diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index a8d43cd293c9..05fbf1bff26a 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -966,32 +966,10 @@ Same as `webContents.capturePage([rect, ]callback)`. * `url` String * `options` Object (optional) - * `httpReferrer` String (optional) - A HTTP Referrer url. - * `userAgent` String (optional) - A user agent originating the request. - * `extraHeaders` String (optional) - Extra headers separated by "\n" - * `postData` Array (optional) - An array of `upload` objects which - provides the request body for `POST` navigation. - -* `upload` Object - * `type` String - `data`, `file`, `filsSystem`, `blob`. - -If `type` is `data` then `upload` object must contain: - * `bytes` Buffer - Raw data to be uploaded. - -If `type` is `file` then `upload` object must contain: - * `filePath` String - Path of file to be uploaded. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `fileSystem` then `upload` object must contain: - * `filsSystemURL` String - FileSystem url to read data for upload. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `blob` then `upload` object must contain: - * `blobUUID` String - UUID of blob data to upload. + * `httpReferrer` String - A HTTP Referrer url. + * `userAgent` String - A user agent originating the request. + * `extraHeaders` String - Extra headers separated by "\n" + * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Same as `webContents.loadURL(url[, options])`. diff --git a/docs/api/structures/upload-blob.md b/docs/api/structures/upload-blob.md new file mode 100644 index 000000000000..5cd6c15ef5c0 --- /dev/null +++ b/docs/api/structures/upload-blob.md @@ -0,0 +1,4 @@ +# Upload blob Object + +* `type` String - `blob`. +* `blobUUID` String - UUID of blob data to upload. diff --git a/docs/api/structures/upload-file-system.md b/docs/api/structures/upload-file-system.md new file mode 100644 index 000000000000..1e59ade61770 --- /dev/null +++ b/docs/api/structures/upload-file-system.md @@ -0,0 +1,9 @@ +# Upload fileSystem Object + +* `type` String - `fileSystem`. +* `filsSystemURL` String - FileSystem url to read data for upload. +* `offset` Integer - Defaults to `0`. +* `length` Integer - Number of bytes to read from `offset`. + Defaults to `0`. +* `modificationTime` Double - Last Modification time in + number of seconds sine the UNIX epoch. diff --git a/docs/api/structures/upload-file.md b/docs/api/structures/upload-file.md new file mode 100644 index 000000000000..5f5ea67dd108 --- /dev/null +++ b/docs/api/structures/upload-file.md @@ -0,0 +1,9 @@ +# Upload file Object + +* `type` String - `file`. +* `filePath` String - Path of file to be uploaded. +* `offset` Integer - Defaults to `0`. +* `length` Integer - Number of bytes to read from `offset`. + Defaults to `0`. +* `modificationTime` Double - Last Modification time in + number of seconds sine the UNIX epoch. diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index d122587cc630..fc3fec3baf7e 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -490,29 +490,7 @@ win.loadURL('http://github.com') * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" - * `postData` Array - An array of `upload` objects which - provides the request body for `POST` navigation. - -* `upload` Object - * `type` String - `data`, `file`, `filsSystem`, `blob`. - -If `type` is `data` then `upload` object must contain: - * `bytes` Buffer - Raw data to be uploaded. - -If `type` is `file` then `upload` object must contain: - * `filePath` String - Path of file to be uploaded. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `fileSystem` then `upload` object must contain: - * `filsSystemURL` String - FileSystem url to read data for upload. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `blob` then `upload` object must contain: - * `blobUUID` String - UUID of blob data to upload. + * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Loads the `url` in the window. The `url` must contain the protocol prefix, e.g. the `http://` or `file://`. If the load should bypass http cache then diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index f9e47f0c3835..592eb5907ee4 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -265,29 +265,7 @@ webview.addEventListener('dom-ready', () => { * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" - * `postData` Array - An array of `upload` objects which - provides the request body for `POST` navigation. - -* `upload` Object - * `type` String - `data`, `file`, `filsSystem`, `blob`. - -If `type` is `data` then `upload` object must contain: - * `bytes` Buffer - Raw data to be uploaded. - -If `type` is `file` then `upload` object must contain: - * `filePath` String - Path of file to be uploaded. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `fileSystem` then `upload` object must contain: - * `filsSystemURL` String - FileSystem url to read data for upload. - * `offset` Integer - * `length` Integer - * `modificationTime` Double - -If `type` is `blob` then `upload` object must contain: - * `blobUUID` String - UUID of blob data to upload. + * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Loads the `url` in the webview, the `url` must contain the protocol prefix, e.g. the `http://` or `file://`. From a5fd6507a9f2fd0386f515623df103865a659856 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 18 Oct 2016 13:25:46 +0530 Subject: [PATCH 06/15] set default values in converter --- atom/common/native_mate_converters/content_converter.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index e70c65699c43..6b2e02e0dabf 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -263,8 +263,8 @@ bool Converter>::FromV8( (*out)->AppendBytes(bytes->GetBuffer(), bytes->GetSize()); } else if (type == "file") { std::string file; - int offset, length; - double modification_time; + int offset = 0, length = -1; + double modification_time = 0.0; dict->GetStringWithoutPathExpansion("filePath", &file); dict->GetInteger("offset", &offset); dict->GetInteger("file", &length); @@ -275,8 +275,8 @@ bool Converter>::FromV8( base::Time::FromDoubleT(modification_time)); } else if (type == "fileSystem") { std::string file_system_url; - int offset, length; - double modification_time; + int offset = 0, length = -1; + double modification_time = 0.0; dict->GetStringWithoutPathExpansion("fileSystemURL", &file_system_url); dict->GetInteger("offset", &offset); dict->GetInteger("file", &length); From 723a3eda8b75cbf792aef7eba6d4f507048c1b55 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 20 Oct 2016 15:47:16 +0530 Subject: [PATCH 07/15] update docs --- docs/api/structures/upload-blob.md | 2 +- docs/api/structures/upload-file-system.md | 2 +- docs/api/structures/upload-file.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/api/structures/upload-blob.md b/docs/api/structures/upload-blob.md index 5cd6c15ef5c0..655a733de73c 100644 --- a/docs/api/structures/upload-blob.md +++ b/docs/api/structures/upload-blob.md @@ -1,4 +1,4 @@ -# Upload blob Object +# Upload Blob Object * `type` String - `blob`. * `blobUUID` String - UUID of blob data to upload. diff --git a/docs/api/structures/upload-file-system.md b/docs/api/structures/upload-file-system.md index 1e59ade61770..448932cc9511 100644 --- a/docs/api/structures/upload-file-system.md +++ b/docs/api/structures/upload-file-system.md @@ -1,4 +1,4 @@ -# Upload fileSystem Object +# Upload FileSystem Object * `type` String - `fileSystem`. * `filsSystemURL` String - FileSystem url to read data for upload. diff --git a/docs/api/structures/upload-file.md b/docs/api/structures/upload-file.md index 5f5ea67dd108..0c3009a1e4ca 100644 --- a/docs/api/structures/upload-file.md +++ b/docs/api/structures/upload-file.md @@ -1,4 +1,4 @@ -# Upload file Object +# Upload File Object * `type` String - `file`. * `filePath` String - Path of file to be uploaded. From 9536ebc0adc9387ccd077755157bb9ce7c4255d3 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sun, 23 Oct 2016 13:49:41 +0530 Subject: [PATCH 08/15] fix build error --- atom/common/native_mate_converters/content_converter.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index 6b2e02e0dabf..0b07b6d39490 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -251,7 +251,7 @@ bool Converter>::FromV8( if (!ConvertFromV8(isolate, val, list.get())) return false; *out = new content::ResourceRequestBodyImpl(); - for (int i = 0; i < list->GetSize(); ++i) { + for (size_t i = 0; i < list->GetSize(); ++i) { base::DictionaryValue* dict = nullptr; std::string type; if (!list->GetDictionary(i, &dict)) From 61576c39be4e267762d3bd0e3902803de90d3b99 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 24 Oct 2016 15:55:06 +0530 Subject: [PATCH 09/15] uploadData => uploadRawData --- atom/common/native_mate_converters/content_converter.cc | 4 ++-- docs/api/browser-window.md | 2 +- docs/api/structures/upload-raw-data.md | 4 ++++ docs/api/web-contents.md | 2 +- docs/api/web-view-tag.md | 2 +- spec/api-browser-window-spec.js | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 docs/api/structures/upload-raw-data.md diff --git a/atom/common/native_mate_converters/content_converter.cc b/atom/common/native_mate_converters/content_converter.cc index 0b07b6d39490..72f1011a72c3 100644 --- a/atom/common/native_mate_converters/content_converter.cc +++ b/atom/common/native_mate_converters/content_converter.cc @@ -215,7 +215,7 @@ Converter>::ToV8( std::unique_ptr bytes( base::BinaryValue::CreateWithCopiedBuffer( element.bytes(), static_cast(element.length()))); - post_data_dict->SetString("type", "data"); + post_data_dict->SetString("type", "rawData"); post_data_dict->Set("bytes", std::move(bytes)); } else if (type == ResourceRequestBodyImpl::Element::TYPE_FILE) { post_data_dict->SetString("type", "file"); @@ -257,7 +257,7 @@ bool Converter>::FromV8( if (!list->GetDictionary(i, &dict)) return false; dict->GetString("type", &type); - if (type == "data") { + if (type == "rawData") { base::BinaryValue* bytes = nullptr; dict->GetBinary("bytes", &bytes); (*out)->AppendBytes(bytes->GetBuffer(), bytes->GetSize()); diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 05fbf1bff26a..304c24c3a1f0 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -969,7 +969,7 @@ Same as `webContents.capturePage([rect, ]callback)`. * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Same as `webContents.loadURL(url[, options])`. diff --git a/docs/api/structures/upload-raw-data.md b/docs/api/structures/upload-raw-data.md new file mode 100644 index 000000000000..5632d8e2c6ec --- /dev/null +++ b/docs/api/structures/upload-raw-data.md @@ -0,0 +1,4 @@ +# Upload RawData Object + +* `type` String - `rawData`. +* `bytes` Buffer - Data to be uploaded. diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index fc3fec3baf7e..638851da9e57 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -490,7 +490,7 @@ win.loadURL('http://github.com') * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Loads the `url` in the window. The `url` must contain the protocol prefix, e.g. the `http://` or `file://`. If the load should bypass http cache then diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 592eb5907ee4..884e4f39d9d7 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -265,7 +265,7 @@ webview.addEventListener('dom-ready', () => { * `httpReferrer` String - A HTTP Referrer url. * `userAgent` String - A user agent originating the request. * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadData](structures/upload-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] Loads the `url` in the webview, the `url` must contain the protocol prefix, e.g. the `http://` or `file://`. diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index f4bb529b605c..e8a12aae19d9 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -29,7 +29,7 @@ describe('browser-window module', function () { const fileStats = fs.statSync(filePath) postData = [ { - 'type': 'data', + 'type': 'rawData', 'bytes': new Buffer('username=test&file=') }, { From cbb68f69804ee9506629c41a2949fd4e971c9afd Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Wed, 9 Nov 2016 14:21:17 -0800 Subject: [PATCH 10/15] Remove quotes around key --- spec/api-browser-window-spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index e8a12aae19d9..c7a404f9a929 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -227,7 +227,7 @@ describe('browser-window module', function () { it('can initiate POST navigation', function (done) { w.webContents.on('did-finish-load', () => done()) - w.loadURL(server.url, {'postData': postData}) + w.loadURL(server.url, {postData: postData}) }) }) From 5f596b22c7da4c95a85be9e230e3a9d0a448e648 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Thu, 10 Nov 2016 19:25:34 +0530 Subject: [PATCH 11/15] specify content type depending on post data --- lib/browser/guest-window-manager.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 0bb7970f82e9..3240161b2de6 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -122,6 +122,15 @@ const createGuest = function (embedder, url, frameName, options, postData) { const loadOptions = {} if (postData) { loadOptions.postData = postData + loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded' + if (postData.length) { + const postDataFront = postData[0].bytes.toString() + const regex = new RegExp(/^--.*[^-\r\n]/) + const boundary = regex.exec(postDataFront) + if (boundary) { + loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}` + } + } } guest.loadURL(url, loadOptions) } From 50019f39e997386a67f4872946250b1537c8381a Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 11 Nov 2016 09:22:45 -0800 Subject: [PATCH 12/15] :art: --- lib/browser/guest-window-manager.js | 9 ++++----- spec/api-browser-window-spec.js | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index 3240161b2de6..d7d169f40118 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -120,14 +120,13 @@ const createGuest = function (embedder, url, frameName, options, postData) { // The above code would not work if a navigation to "about:blank" is done // here, since the window would be cleared of all changes in the next tick. const loadOptions = {} - if (postData) { + if (postData != null) { loadOptions.postData = postData loadOptions.extraHeaders = 'content-type: application/x-www-form-urlencoded' - if (postData.length) { + if (postData.length > 0) { const postDataFront = postData[0].bytes.toString() - const regex = new RegExp(/^--.*[^-\r\n]/) - const boundary = regex.exec(postDataFront) - if (boundary) { + const boundary = /^--.*[^-\r\n]/.exec(postDataFront) + if (boundary != null) { loadOptions.extraHeaders = `content-type: multipart/form-data; boundary=${boundary[0].substr(2)}` } } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index c7a404f9a929..1214e0817492 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -29,15 +29,15 @@ describe('browser-window module', function () { const fileStats = fs.statSync(filePath) postData = [ { - 'type': 'rawData', - 'bytes': new Buffer('username=test&file=') + type: 'rawData', + bytes: new Buffer('username=test&file=') }, { - 'type': 'file', - 'filePath': filePath, - 'offset': 0, - 'length': fileStats.size, - 'modificationTime': fileStats.mtime.getTime() / 1000 + type: 'file', + filePath: filePath, + offset: 0, + length: fileStats.size, + modificationTime: fileStats.mtime.getTime() / 1000 } ] server = http.createServer(function (req, res) { From 134f8afbe65e5403d3a741b9a8e43ce27dd965a1 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 11 Nov 2016 10:13:06 -0800 Subject: [PATCH 13/15] Add specs for content type on POST forms --- spec/api-browser-window-spec.js | 60 +++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 1214e0817492..84f2b92c627e 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -8,16 +8,11 @@ const qs = require('querystring') const http = require('http') const {closeWindow} = require('./window-helpers') -const remote = require('electron').remote -const screen = require('electron').screen - -const app = remote.require('electron').app -const ipcMain = remote.require('electron').ipcMain -const ipcRenderer = require('electron').ipcRenderer -const BrowserWindow = remote.require('electron').BrowserWindow +const {ipcRenderer, remote, screen} = require('electron') +const {app, ipcMain, BrowserWindow} = remote.require('electron') +const {protocol, session} = remote const isCI = remote.getGlobal('isCi') -const {protocol} = remote describe('browser-window module', function () { var fixtures = path.resolve(__dirname, 'fixtures') @@ -225,9 +220,52 @@ describe('browser-window module', function () { w.loadURL('http://127.0.0.1:11111') }) - it('can initiate POST navigation', function (done) { - w.webContents.on('did-finish-load', () => done()) - w.loadURL(server.url, {postData: postData}) + describe('POST navigations', function () { + afterEach(() => { + w.webContents.session.webRequest.onBeforeSendHeaders(null) + }) + + it('supports specifying POST data', function (done) { + w.webContents.on('did-finish-load', () => done()) + w.loadURL(server.url, {postData: postData}) + }) + + it('sets the content type header on URL encoded forms', function (done) { + w.webContents.on('did-finish-load', () => { + w.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => { + assert.equal(details.requestHeaders['content-type'], 'application/x-www-form-urlencoded') + done() + }) + w.webContents.executeJavaScript(` + form = document.createElement('form') + form.method = 'POST' + form.target = '_blank' + form.submit() + `) + }) + w.loadURL(server.url) + }) + + it('sets the content type header on multi part forms', function (done) { + w.webContents.on('did-finish-load', () => { + w.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => { + assert(details.requestHeaders['content-type'].startsWith('multipart/form-data; boundary=----WebKitFormBoundary')) + done() + }) + w.webContents.executeJavaScript(` + form = document.createElement('form') + form.method = 'POST' + form.target = '_blank' + form.enctype = 'multipart/form-data' + file = document.createElement('input') + file.type = 'file' + file.name = 'file' + form.appendChild(file) + form.submit() + `) + }) + w.loadURL(server.url) + }) }) }) From b9e950f5c7680a6a70eff4013a840c658d402ef9 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Fri, 11 Nov 2016 10:55:13 -0800 Subject: [PATCH 14/15] Mark postData as optional --- docs/api/browser-window.md | 8 ++++---- docs/api/web-contents.md | 8 ++++---- docs/api/web-view-tag.md | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 304c24c3a1f0..7bf02e6599e9 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -966,10 +966,10 @@ Same as `webContents.capturePage([rect, ]callback)`. * `url` String * `options` Object (optional) - * `httpReferrer` String - A HTTP Referrer url. - * `userAgent` String - A user agent originating the request. - * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `httpReferrer` String (optional) - A HTTP Referrer url. + * `userAgent` String (optional) - A user agent originating the request. + * `extraHeaders` String (optional) - Extra headers separated by "\n" + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] (optional) Same as `webContents.loadURL(url[, options])`. diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 638851da9e57..322d8fba4c53 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -487,10 +487,10 @@ win.loadURL('http://github.com') * `url` URL * `options` Object (optional) - * `httpReferrer` String - A HTTP Referrer url. - * `userAgent` String - A user agent originating the request. - * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `httpReferrer` String (optional) - A HTTP Referrer url. + * `userAgent` String (optional) - A user agent originating the request. + * `extraHeaders` String (optional) - Extra headers separated by "\n" + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] (optional) Loads the `url` in the window. The `url` must contain the protocol prefix, e.g. the `http://` or `file://`. If the load should bypass http cache then diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index 884e4f39d9d7..78ed927abca9 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -262,10 +262,10 @@ webview.addEventListener('dom-ready', () => { * `url` URL * `options` Object (optional) - * `httpReferrer` String - A HTTP Referrer url. - * `userAgent` String - A user agent originating the request. - * `extraHeaders` String - Extra headers separated by "\n" - * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] + * `httpReferrer` String (optional) - A HTTP Referrer url. + * `userAgent` String (optional) - A user agent originating the request. + * `extraHeaders` String (optional) - Extra headers separated by "\n" + * `postData` ([UploadRawData](structures/upload-raw-data.md) | [UploadFile](structures/upload-file.md) | [UploadFileSystem](structures/upload-file-system.md) | [UploadBlob](structures/upload-blob.md))[] (optional) Loads the `url` in the webview, the `url` must contain the protocol prefix, e.g. the `http://` or `file://`. From 4deb7c6fa72f863da5ee959daaed911053466895 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sat, 12 Nov 2016 07:16:48 +0530 Subject: [PATCH 15/15] fix lint error --- spec/api-browser-window-spec.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 84f2b92c627e..6810fa79946a 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -9,8 +9,7 @@ const http = require('http') const {closeWindow} = require('./window-helpers') const {ipcRenderer, remote, screen} = require('electron') -const {app, ipcMain, BrowserWindow} = remote.require('electron') -const {protocol, session} = remote +const {app, ipcMain, BrowserWindow, protocol} = remote const isCI = remote.getGlobal('isCi')