fix crash when passing empty string to recording (#17698)

This commit is contained in:
Shelley Vohr 2019-04-05 11:19:06 -07:00 committed by GitHub
parent c4020308c9
commit 2b9bd0f56f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -12,6 +12,7 @@
#include "atom/common/promise_util.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/threading/thread_restrictions.h"
#include "content/public/browser/tracing_controller.h"
#include "native_mate/dictionary.h"
@ -58,6 +59,11 @@ scoped_refptr<TracingController::TraceDataEndpoint> GetTraceDataEndpoint(
const base::FilePath& path,
const CompletionCallback& callback) {
base::FilePath result_file_path = path;
// base::CreateTemporaryFile prevents blocking so we need to allow it
// for now since offloading this to a different sequence would require
// changing the api shape
base::ThreadRestrictions::ScopedAllowIO allow_io;
if (result_file_path.empty() && !base::CreateTemporaryFile(&result_file_path))
LOG(ERROR) << "Creating temporary file failed";

View file

@ -214,8 +214,7 @@ describe('contentTracing', () => {
expect(resultFilePath).to.be.a('string').and.be.equal(outputFilePath)
})
// FIXME(alexeykuzmin): https://github.com/electron/electron/issues/16019
xit('creates a temporary file when an empty string is passed', async function () {
it('creates a temporary file when an empty string is passed', async function () {
const resultFilePath = await record(/* options */ {}, /* outputFilePath */ '')
expect(resultFilePath).to.be.a('string').that.is.not.empty()
})