From: Cheng Zhao Date: Mon, 29 Sep 2014 08:58:54 +0000 (+0800) Subject: spec: asar: Testing getting file in web page X-Git-Tag: v0.17.0~6^2~8 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=2bf2ad094cd38c364c638dafe0d71091fd454946;p=electron.git spec: asar: Testing getting file in web page --- diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index e1286f93..0144b9a9 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -261,3 +261,30 @@ describe 'asar package', -> p = path.join fixtures, 'asar', 'a.asar', 'not-exist' throws = -> child_process.fork p assert.throws throws, /ENOENT/ + + describe 'asar protocol', -> + it 'can request a file in package', (done) -> + p = path.resolve fixtures, 'asar', 'a.asar', 'file1' + $.get "asar:#{p}", (data) -> + assert.equal data, 'file1\n' + done() + + it 'can request a linked file in package', (done) -> + p = path.resolve fixtures, 'asar', 'a.asar', 'link2', 'link1' + $.get "asar:#{p}", (data) -> + assert.equal data, 'file1\n' + done() + + it 'can request a file in filesystem', (done) -> + p = path.resolve fixtures, 'asar', 'file' + $.get "asar:#{p}", (data) -> + assert.equal data, 'file\n' + done() + + it 'gets 404 when file is not found', (done) -> + p = path.resolve fixtures, 'asar', 'a.asar', 'no-exist' + $.ajax + url: "asar:#{p}" + error: (err) -> + assert.equal err.status, 404 + done() diff --git a/spec/fixtures/asar/file b/spec/fixtures/asar/file new file mode 100644 index 00000000..f73f3093 --- /dev/null +++ b/spec/fixtures/asar/file @@ -0,0 +1 @@ +file