assert false, 'Got error: ' + errorType + ' ' + error
protocol.unregisterProtocol 'atom-file-job'
+ it 'returns RequestFileJob should send file from asar archive with unpacked file', (done) ->
+ p = path.join __dirname, 'fixtures', 'asar', 'unpack.asar', 'a.txt'
+ job = new protocol.RequestFileJob(p)
+ handler = remote.createFunctionWithReturnValue job
+ protocol.registerProtocol 'atom-file-job', handler
+
+ $.ajax
+ url: 'atom-file-job://' + p
+ success: (response) ->
+ data = require('fs').readFileSync(p)
+ assert.equal response.length, data.length
+ buf = new Buffer(response.length)
+ buf.write(response)
+ console.log buf, data
+ assert buf.equals(data)
+ protocol.unregisterProtocol 'atom-file-job'
+ done()
+ error: (xhr, errorType, error) ->
+ assert false, 'Got error: ' + errorType + ' ' + error
+ protocol.unregisterProtocol 'atom-file-job'
+
describe 'protocol.isHandledProtocol', ->
it 'returns true if the scheme can be handled', ->
assert.equal protocol.isHandledProtocol('file'), true
assert.equal data, 'file1\n'
done()
+ it 'can request a file in package with unpacked files', (done) ->
+ p = path.resolve fixtures, 'asar', 'unpack.asar', 'a.txt'
+ $.get "file://#{p}", (data) ->
+ assert.equal data, 'a\n'
+ done()
+
it 'can request a linked file in package', (done) ->
p = path.resolve fixtures, 'asar', 'a.asar', 'link2', 'link1'
$.get "file://#{p}", (data) ->
p = path.join fixtures, 'asar', 'logo.asar', 'logo.png'
logo = require('native-image').createFromPath p
assert.deepEqual logo.getSize(), {width: 55, height: 55}
+
+ it 'reads image from asar archive with unpacked files', ->
+ p = path.join fixtures, 'asar', 'unpack.asar', 'atom.png'
+ logo = require('native-image').createFromPath p
+ assert.deepEqual logo.getSize(), {width: 1024, height: 1024}