add spec
This commit is contained in:
		
					parent
					
						
							
								2044208fd6
							
						
					
				
			
			
				commit
				
					
						ad5f944185
					
				
			
		
					 2 changed files with 46 additions and 3 deletions
				
			
		|  | @ -254,7 +254,8 @@ bool Converter<scoped_refptr<ResourceRequestBodyImpl>>::FromV8( | ||||||
|   for (int i = 0; i < list->GetSize(); ++i) { |   for (int i = 0; i < list->GetSize(); ++i) { | ||||||
|     base::DictionaryValue* dict = nullptr; |     base::DictionaryValue* dict = nullptr; | ||||||
|     std::string type; |     std::string type; | ||||||
|     list->GetDictionary(i, &dict); |     if (!list->GetDictionary(i, &dict)) | ||||||
|  |       return false; | ||||||
|     dict->GetString("type", &type); |     dict->GetString("type", &type); | ||||||
|     if (type == "data") { |     if (type == "data") { | ||||||
|       base::BinaryValue* bytes = nullptr; |       base::BinaryValue* bytes = nullptr; | ||||||
|  |  | ||||||
|  | @ -4,6 +4,7 @@ const assert = require('assert') | ||||||
| const fs = require('fs') | const fs = require('fs') | ||||||
| const path = require('path') | const path = require('path') | ||||||
| const os = require('os') | const os = require('os') | ||||||
|  | const qs = require('querystring') | ||||||
| const http = require('http') | const http = require('http') | ||||||
| const {closeWindow} = require('./window-helpers') | const {closeWindow} = require('./window-helpers') | ||||||
| 
 | 
 | ||||||
|  | @ -21,11 +22,47 @@ const {protocol} = remote | ||||||
| describe('browser-window module', function () { | describe('browser-window module', function () { | ||||||
|   var fixtures = path.resolve(__dirname, 'fixtures') |   var fixtures = path.resolve(__dirname, 'fixtures') | ||||||
|   var w = null |   var w = null | ||||||
|   var server |   var server, postData | ||||||
| 
 | 
 | ||||||
|   before(function (done) { |   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) { |     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) |       setTimeout(respond, req.url.includes('slow') ? 200 : 0) | ||||||
|     }) |     }) | ||||||
|     server.listen(0, '127.0.0.1', function () { |     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') |       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 () { |   describe('BrowserWindow.show()', function () { | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 deepak1556
				deepak1556