diff --git a/spec/api-protocol-spec.coffee b/spec/api-protocol-spec.coffee index b87dc7510f..49dd5e326f 100644 --- a/spec/api-protocol-spec.coffee +++ b/spec/api-protocol-spec.coffee @@ -110,6 +110,27 @@ describe 'protocol module', -> 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 diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index 39aa1e6ebe..031133d2af 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -362,6 +362,12 @@ describe 'asar package', -> 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) -> @@ -431,3 +437,8 @@ describe 'asar package', -> 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} diff --git a/spec/fixtures/asar/unpack.asar b/spec/fixtures/asar/unpack.asar new file mode 100644 index 0000000000..8c1231c1b2 Binary files /dev/null and b/spec/fixtures/asar/unpack.asar differ diff --git a/spec/fixtures/asar/unpack.asar.unpacked/a.txt b/spec/fixtures/asar/unpack.asar.unpacked/a.txt new file mode 100644 index 0000000000..7898192261 --- /dev/null +++ b/spec/fixtures/asar/unpack.asar.unpacked/a.txt @@ -0,0 +1 @@ +a diff --git a/spec/fixtures/asar/unpack.asar.unpacked/atom.png b/spec/fixtures/asar/unpack.asar.unpacked/atom.png new file mode 100644 index 0000000000..a09f048051 Binary files /dev/null and b/spec/fixtures/asar/unpack.asar.unpacked/atom.png differ