diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 8ed76e994a1..8cb9d3395e5 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -554,8 +554,16 @@ void Session::CreateInterruptedDownload(const mate::Dictionary& options) { options.Get("lastModified", &last_modified); options.Get("eTag", &etag); options.Get("startTime", &start_time); - if (path.empty() || url_chain.empty() || length == 0 || offset >= length) + if (path.empty() || url_chain.empty() || length == 0) { + isolate()->ThrowException(v8::Exception::Error(mate::StringToV8( + isolate(), "Must pass non-empty path, urlChain and length."))); return; + } + if (offset >= length) { + isolate()->ThrowException(v8::Exception::Error(mate::StringToV8( + isolate(), "Must pass an offset value less than length."))); + return; + } auto download_manager = content::BrowserContext::GetDownloadManager(browser_context()); download_manager->GetDelegate()->GetNextId(base::Bind( diff --git a/spec/api-session-spec.js b/spec/api-session-spec.js index dfb2db5dedd..b785e8cb0ff 100644 --- a/spec/api-session-spec.js +++ b/spec/api-session-spec.js @@ -601,7 +601,7 @@ describe('session module', function () { totalBytes, filename, savePath) { assert.equal(state, 'interrupted') - assert.equal(urlChain, urlChain) + assert.deepEqual(urlChain, urlChain) assert.equal(mimeType, 'application/pdf') assert.equal(receivedBytes, 0) assert.equal(totalBytes, 5242880)